Welcome! Log In Create A New Profile

Advanced

Assignment 2 Question 4

Posted by william 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Assignment 2 Question 4
June 16, 2008 04:32PM
Hi,

I am struggling with question 4 of assignment 2. The question asks to change the book and book list objects from question 3 so that they derive from DataObject. When I change my book object to derive from the data object I get a segment fault. This happens even if I don't instantiate a book object at all. The only thing I could find was that if I take out the Q_OBJECT macro at the top of the book object the segment faults go away but then the toString method does not pick up my properties.

Any Ideas?

Thanks
William
Anonymous User
Re: Assignment 2 Question 4
June 16, 2008 07:53PM
A segment fault occurs usually when a pointer reference goes awry, I think.
so something->somewhere is not happening.
Re: Assignment 2 Question 4
June 18, 2008 08:46AM
I am also having problems executing the code. The code for q3 works and runs fine but when I change the classes to extend from DataObjects i have problems. I finally got it to compile but when I run the application I get the following error:
"The application failed to initialize properly (0xc0000005). Click on OK to terminate the application."
Re: Assignment 2 Question 4
June 27, 2008 11:20PM
Did you manage to find a solution for this problem yet ?

The reason I ask is because I am experiencing the exact same problem.
Re: Assignment 2 Question 4
June 28, 2008 12:48AM
Well, I found a solution to this problem on the 2007 forum. It seems that the students experienced the exact same problem last year.

Have a look at this post: http://osprey.unisa.ac.za/phorum/read.php?141,57096

I cannot believe that the lectures were not aware of this, I really think it's pathetic that we have to fix up the dodgy code that is provided to us !!!!
Re: Assignment 2 Question 4
June 28, 2008 06:49PM
Ok, the segmentation faults are no longer a problem, but now I am just struggling with the question.

Can any please assist?

What I am currently doing is to read the elements/attribues in the startElement() method of myHandler (derived from QXmlDefaultHandler) and then trying to build a book and then at the end add the book to the book list, but it doesn't seem to be going so well.

Can the reader be done this way, or am I missing something ? Do we actually need to override some of the other methods inorder to complete the question ?

Am I on the right track here ? Can anyone give some guidance please ?
Re: Assignment 2 Question 4
June 28, 2008 07:58PM
Hi esckay

I assume you recompiled the libraries to include the changes. Are you still using Visual Studio I recompiled and it produced the dataobjects.lib.

But I can not get my code to compile it fails on
#include <DataObject>
class Book : public DataObject { with
fatal error C1083: Cannot open include file: 'DataObject': No such file or directory

How did you do your import?

Thanks
Henk
Re: Assignment 2 Question 4
June 28, 2008 08:25PM
I think your include statement is incorrect.

I think it should be:
#include <DataObject.h>
Re: Assignment 2 Question 4
June 28, 2008 08:28PM
Ok, my code can now read the book list from the xml file, but what I am now struggling with is how to access the list.

I build the list in myHandler, but how the hell to I access the list ?

Almost anything I try gives me the following error:
qobject.h:269: error: 'QObject::QObject(const QObject&winking smiley' is private

Can anyone help ? Am I even on the right track ?
Re: Assignment 2 Question 4
June 29, 2008 03:44PM
Hey Esckay

I had that problem as well.
Dunno if there's an easier way around it, but I just wrote a copy constructor for the book class. I also got another error at a later stage and had to overload the = operator.
Re: Assignment 2 Question 4
July 01, 2008 09:06AM
Hi guys,

Sorry for joining in late on the forum, but i just can't do this on my own anymore.smile

I am struggling to implement the 2007 fix.

I would appreciate any help. What i have done is the following:
1) I use QIde (which is the first problem).
2) I added the globals.h
3) I updated the project properties to include "BUILD_DLL".
4) I updated all the header files that open in QIde with "#include "globals.h"

class EXPORT" for each class.
5) But when i build (in QIde) it still does not compile. I get a vtable error or moc errors (i tried a few things).

Is there anything that i am blatantly missing?
Re: Assignment 2 Question 4
July 01, 2008 11:17AM
Hi gerhardusj

In the 2007 post in the second post there is a link pointing to a zip file download. It contains the globals.h but also all the other classes that needed changing. So just download that unzip and dump everything into the current directory and compile.

Just make a backup of your current stuff before doing this.

Cheers
Henk
Re: Assignment 2 Question 4
July 01, 2008 04:20PM
Thank you Henk - i missed the link! confused smiley Pretty smooth for my first post...

I will try it tonight.

Thank you very much,

g
avatar Re: Assignment 2 Question 4
July 01, 2008 06:57PM
QString Book::toString() const {
  return DataObject::toString();
}
3GG
Re: Assignment 2 Question 4
July 08, 2008 01:47PM
Hi all

Got a bit of a problem with the reader. Managed to get it to read the file using the dataobject reader, however dataobject reader returns a dataobject. I need to return a BookList, however if I try to use

bookList = qobject_cast<BookList*>(dataObject)

it just puts 0 in bookList.

What am I doing wrong here.

Ps BookList is derived from the base clall DataObject
Sorry, only registered users may post in this forum.

Click here to login