[Qt-interest] QWidget: Must construct a QApplication before a QPaintDevice [SOLVED]

Andre Somers andre at familiesomers.nl
Tue Sep 1 12:39:55 CEST 2009


Stephen Jackson wrote:
> The Qt source reveals that you get this message if you construct a
> QWidget and QCoreApplication::self is a null pointer.
>
> The Qt source sets this to null
> 	a) On initialisation
> 	b) When a QCoreApplication object is destroyed (perhaps via the
> destruction of a QApplication object)
>
> Are you creating a secondary (core) application object? There is a
> Q_ASSERT_X to guard against this but I haven't checked whether this
> behaves differently between release and debug.
>
> If you are definitely not doing that, then something must be
> overwriting this global pointer - you can get different layout of
> global variables between debug and release. Check for memsets etc. Add
> some debugging statements that show the value of qApp at various
> points.
>
>   
Thanks a lot, this has set me on the right track to find the culprit. I 
am not doing fancy things like creating secundairy application objects, 
but putting in some debug statements allowed me to narrow down the 
issue. I should have come up with that immediately myself, of course... 
Nothing like some old fashioned std::out debugging ;-)

It turns out the problem is not in my own code, but in Yape[1], a 
property editor lib I am using. I can reproduce the problem with the 
example that comes with it if I build that example in release mode. 
Also, if I skip creating the property editor, my own application starts 
properly.

And that reminded me again of J-P Nurmi's comment earlier today:

    A wild guess. Your project consists of an app and some lib, am I
    right? If so, make sure to compile them _both_ in the same mode, ie.
    don't mix debug and release.
      

This lib is also an external lib, that in turn also loads plugins! And 
yes, as it turn out, this lib and it's plugins were compiled in debug 
mode. Re-compiling them in release mode solved the problem. :-)


Everybody: thanks for your help!

André


[1] 
http://www.qt-apps.org/content/show.php/yape+%28Yet+another+property+editor%29?content=100064

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090901/4fda2c26/attachment.html 


More information about the Qt-interest-old mailing list