PDA

View Full Version : Debugging start up



koan
9th August 2010, 00:10
Hi

I'm having trouble debugging the processes after the end of construction but presumably before the first resizeEvent. During that time something goes awry and causes a crash. Due to the fact that we are in the event loop (or maybe not) I don't know how I can find out what causes the problem.

I have a QMainWindow and set up the menus, toolbar, main widgets etc in the constructor. However, this was taking too long to finish so I wanted to change to doing basic start up in the constructor and call a second initialisation function via a single shot timer, as suggested here:
http://doc.qt.nokia.com/qtopia2.2/html/quicklaunch.html
so that the main window could open and show a "Please wait" message while the second function finishes loading data etc.

The problem is that after I shift code into the second function then the program crashes some time after calling the single shot timer. As far as I can tell, the constructor exits; the destructor is not called. I would expect resizeEvent would be called as one of the first things in the event loop but it doesn't seem to be. I can't see anything in my constructor that isn't initialised enough so that it would cause the event loop to die (if it actually started).

My program is on a Zaurus running QPE+Qtopia 1.5 with QT/embedded 2.3 so debugging in situ is very difficult. I run it under QT 3 on a Linux desktop but in that environment there are no problems. Another thing is running in portrait or landscape mode on the Zaurus, it should only mean different parameters to resizeEvent but it seems more likely to fail in portrait mode.

Sorry if this explanation doesn't sound clear, I have experimented with various different amounts of start up code in the constructor and am really having trouble forming a logical description of the problem, hence I need help in formulating strategies to debug. So far I have been writing a logfile and output to stderr.

My code is



QPEApplication app(argc, argv);
app.showMainWidget(&myMainWindow);
return(app.exec());

...

myMainWindow::myMainWindow() : QMainWindow()
{
// basic set up
...

QTimer::singleShot(0, this, SLOT(initialise()));
}

Many thanks in advance.

tbscope
9th August 2010, 06:39
Can you post the complete constructor code and initialise() code please?

koan
9th August 2010, 11:12
As I said, the constructor initialises a few member variables before calling the single shot timer. The initialise function is much longer, setting up menu, toolbar, all the mainwindow widgets plus other things.

Previously I had constructor(){ A,B,C,D } but now I have constructor(){ A,singleshot }; initialise() { B,C,D }. So the problem is something happening between the constructor and initialise, i.e. in the event loop.

Apart from setting up timing and drawing widgets, what else is QT doing ? How can I debug to find out what is going wrong ?

tbscope
9th August 2010, 11:18
Can you post the complete constructor code and initialise() code please?
I don't know how you can debug on embedded machines, I have no experience with that. But I might be able to point out problems in your code, if you post it.