I can't figure out this one. It was working, and then I decided to refactor it and everthing went all pear-shaped
First, the code :
/edit : code attached below.
I can't figure out this one. It was working, and then I decided to refactor it and everthing went all pear-shaped
First, the code :
/edit : code attached below.
Last edited by Valheru; 30th September 2006 at 23:54.
The code under Server::addServerTab used to be in ServerList::fetchGroupsSlot(). Then I moved it to the Server class, and now it segfaults. It segfaults on the line
Which seems to indicate that it SwatMw *mw isn't initialized, but it gets initialzed in the constructor which is very confusing. What's going on here?Qt Code:
mw->getServerTabWidget()->addTab( newServerWidget, name );To copy to clipboard, switch view to plain text mode
Last edited by Valheru; 30th September 2006 at 23:55.
I'm sorry, I don't want to be rude, but... do you expect us to read and understand 600 lines of code? What do you expect us to do with it? Couldn't you have pasted it as an attachment instead of displaying them inside posts? Is it really necessary to have all the 600 lines to find the problem? I doubt so...
Did you use a debugger? If not, use one (gdb?) and when the application crashes, check the backtrace (bt) and print values of mw, newServerWidget and mw->getServerTabWidget(). One of them will probably be NULL. Also the backtrace will tell you exactly which functions were called and in what order. Maybe you'll notice something weird. Remember to compile your application in debug mode before feeding it to the debugger.
Well, I didn't think about attatching it to be honest. And what difference does it make as to weather or not I attatch it or inline it if you think that 600 lines is too much in the first place? I gave all the code as I wanted to be complete. Sorry if that made your life unbearable
I also think it's rather gay of you to lambaste me in the thread as well as PM'ing me about it BTW.
I can't sodding debug it because I'm using Arch Linux (switched from Gentoo because my KDE borked) and Qt isn't compiled with debug flags on Arch.
I'll see what I can come up with. I was hoping that maybe someone would spot something glaringly wrong wit hmy code - often after staring at your code for hours on end you tend to miss simple things.
Because I can ignore/grep/delete/print/do_whatever_I_want if it is attached and I have to scroll through all of it if it is inline. That's simply flooding, especially if you make 4 posts out of it when 1 would be enough.
There is nothing wrong with it.... as long as you attach it.I gave all the code as I wanted to be complete.
Oh come on!Sorry if that made your life unbearable![]()
I'm just trying to keep order here.
Very strong words, you should speak them carefully. The PM was a result of an infraction you were given, just a side effect you might say, explaining what you should do to correct the situation (which you haven't done yet anyway).I also think it's rather gay of you to lambaste me in the thread as well as PM'ing me about it BTW.
Hmm... you might try to print those values directly in the application then, without using a debugger. You'll lose the backtrace ability, but if you're right about the place where it crashes (although it probably crashes somewhere inside Qt library), this might be enough.I can't sodding debug it because I'm using Arch Linux (switched from Gentoo because my KDE borked) and Qt isn't compiled with debug flags on Arch.
In 600 lines?I was hoping that maybe someone would spot something glaringly wrong wit hmy codeMy only guess when looking at your code was that if indeed "mw" was null/garbage then maybe because your constructor was invoked with an incorrect parameter (SwatMw* m I think). But it's only a wild guess - debugger helps in such situations, maybe you should consider rebuilding Qt in debug mode.
Well, here are the files as attatchments. I was trying to edit my original posts but apparantly I can't attach files to edits.
I'm busy installing a debug version of Qt as we speak, it's going to take a while though since I am compiling it from source. I'd hoped I was finished with compiling Qt when I switched from Gentoo but apparently not.
Thanks for any/all help.
P.S. You can delete the superflous posts if you want, I can't it seems.
Hmm, when I add mw in the class Server as a watch then it resolves to 0x0 which is plainly _WRONG_...although I can't possibly see how that can be since it is passed to the constructor from ServerList when it is added to the QList. And in ServerList it is initialized before that happens, so it should be right. Something is rotten in the state of Denmark...
Then check whether you really pass a valid pointer to the constructor.
Are you sure that this statement deletes all of these objects?Qt Code:
delete menu, model, connectToServer, newServer, editServer, deleteServer, separator;To copy to clipboard, switch view to plain text mode
Delete does not have anything to do with this. It is the "," (comma) operator which is responsible. It groups statements, not arguments.
http://msdn2.microsoft.com/en-us/library/zs06xbxh.aspx
http://www.cplusplus.com/doc/tutorial/operators.html (scroll down to "comma operator")
Valheru (1st October 2006)
Thanks, I've changed it so that each pointer is deleted seperately. Am I correct in thinking that you could put the pointers in a list and call delete on the list, like so :
Qt Code:
delete {pointer_1, pointer_2,...,pointer_n};To copy to clipboard, switch view to plain text mode
No, you would try to delete the list object. But you can put all pointers into the list and call orQt Code:
for(int i=0;i<list.size();i++) delete list[i];To copy to clipboard, switch view to plain text mode
Valheru (1st October 2006)
Bookmarks