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

Andreas Pakulat apaku at gmx.de
Thu Jul 29 10:59:15 CEST 2010


On 29.07.10 10:29:06, Davor J. wrote:
> The situation in which this is occurring is not all that standard I think. 
> Basically, what I am doing is redirecting the qWarning() messages to a log 
> and a QMessageBox::warning(...) box with qInstallMsgHandler as explained in 
> the docs. Now, those messages might occur on various occasions during code 
> execution, and QMessageBox::warning dialogs might get executed in all kinds 
> of situations. Anyhow, in some cases the program gives a segmentation fault 
> on running QMessageBox::warning(0, "Warning!", msg). More specifically it 
> crashes somewhere in execution of QWidget::show() which is called on showing 
> the QDialog-based warning message. Digging deeper led me to sending internal 
> events by QCoreApplication::notifyInternal() and there I got lost in 
> recursion...
> 
> I solved my specific crashing by delaying the warning message with 
> Qt::QueuedConnection but as I do not know the cause, I do not know whether 
> this is a real solution either.

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.

Andreas 

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



More information about the Qt-interest-old mailing list