[Qt-interest] Segmentation faults whenexecuting QMessageBox::warning or similar.

Davor J. DavorJ at live.com
Thu Jul 29 14:05:41 CEST 2010


"Andreas Pakulat" <apaku at gmx.de> wrote in message 
news:20100729085915.GC19978 at neo.apaku.dnsalias.org...
> Sounds like you're using qWarning from a thread that is not the GUI 
> thread.
> If thats the case its normal for all kind of weirdness to happen if
> qWarning suddenly triggers GUI code. Execution of GUI code is only
> supported in the main/GUI thread (the one in which you created your
> QApplication instance). So yes using a queued-connection or a custom event
> for showing the warning, to make sure its executed in the GUI thread is 
> the
> right solution.
>

Thanks for the quick reply Andreas.

That's actually the weird thing. AFAIR I noticed in the Qt-code explicit 
checking for main/GUI thread execution. So if that was the case I would 
expect an abort or something. But the only extra thread we are using is the 
database thread, and for this specific error I dug into that thread wasn't 
even running. Also, the redirection to the log and warning dialogs happens 
with signals/slots. AFAIK those automatically use Qt::QueuedConnection 
between threads.

My point is that I am pretty sure that the initiator of qDebug() and 
qWarning() is running in the main thread. And even if it was not, the 
execution of QMessageBox::warning(...) box would be in the main thread 
because it's executed in a slot running in the main thread.

Also, this error I had is far from common, but is always reproducible once 
found.

> Andreas
>
> -- 
> Your true value depends entirely on what you are compared with. 





More information about the Qt-interest-old mailing list