PDA

View Full Version : segfault while trying to access QList



Raven24
2nd March 2010, 21:19
I am a bit stuck on a small project I am working on. It's supposed to access a SugarCRM instance via SOAP.

Now I have implemented most of the stuff I need, but there is one thing that keeps crashing the app since I last refactored.
There are Accounts and Contacts and both can have Notes. So i implemented the method for fetching Notes in a common class the Accounts and Contacts can inherit from. Since my C++ is anything else but professional, the attempt to access said Notes fails in a segfault.

In http://github.com/Raven24/FSugar/blob/widgets/abstractitem.cpp on line 27 the method populating the Notes starts. http://github.com/Raven24/FSugar/blob/widgets/abstractitemdetail.cpp on line 74 the Notes are put into a model and should be displayed in a QTableView. The model is in http://github.com/Raven24/FSugar/blob/widgets/notesmodel.cpp and the segfault happens while attempting to sort the list in the method on line 128.

The people at #qt already told me that in AbstractItemDetail the member 'item' probably doesn't get initialised. That should be taken care of by the subclass AccountDetail - at least that's what I think it does.
Any help is gladly appreciated!

P.S: When you want to checkout the whole project, make sure you use the 'widgets' branch. 'master' doesn't work...

Raven24
3rd March 2010, 06:53
lastest research in the interwebs has shown, that the problem seems to be me shadowing the 'item' from AbstractItemDetail in AccountDetail. Thus methods in AbstractItemDetail can only access an uninitialised pointer... I have to look into dynamic inheritance and polymorphism again, I guess.