Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: Jenna on May 25, 2008, 05:25:39 pm

Title: Batch-build on linux can cause a GTK-CRITICAL
Post by: Jenna on May 25, 2008, 05:25:39 pm
I just submitted a bugreport (http://developer.berlios.de/bugs/?func=detailbug&bug_id=13877&group_id=5358) and a patch (http://developer.berlios.de/patch/?func=detailpatch&patch_id=2483&group_id=5358) at berlios.

Text of bugreport.
Quote
If a batch-build that was invoked from console does some "real work" (this means compiling) and not only write "Nothing to be done" to dialog and console it leads to the following error-message:
"(codeblocks:8054): Gtk-CRITICAL **: gtk_window_set_modal: assertion `GTK_IS_WINDOW (window)' failed".
The "8054" is not always the same address.

This is caused because the dialog gets ended with "EndModal(wxID_OK)", after the "EndModal" it gets destroyed immediately and is set to 0.
I think this leads to the error, because wxWidgets calls internally "gtk_window_set_modal(GTK_WINDOW(m_widget), FALSE);" after the EventLoop, but if the widget is destroyed in this moment.
If nothing has to be done "EndModal()" is reached before "ShowModal()" and destroying the dialog is the right way to close it.

I don't know if that's the real cause for this error, but it can be avoided by only calling "EndModal()" if the dialog really "IsModal()" and otherwise destroy it.

I will submit a patch that does this and is tested on linux 64-bit and does no harm on windows.

Patch:
Code
--- codeblocks-1.0svn.orig/src/src/app.cpp      2008-05-01 07:11:56.000000000 +0200
+++ codeblocks-1.0svn.work/src/src/app.cpp      2008-05-25 12:24:12.000000000 +0200
@@ -780,9 +783,13 @@

     if (m_pBatchBuildDialog && m_BatchWindowAutoClose)
     {
-        m_pBatchBuildDialog->EndModal(wxID_OK);
-        m_pBatchBuildDialog->Destroy();
-        m_pBatchBuildDialog = 0;
+        if(m_pBatchBuildDialog->IsModal())
+            m_pBatchBuildDialog->EndModal(wxID_OK);
+        else
+        {
+            m_pBatchBuildDialog->Destroy();
+            m_pBatchBuildDialog = 0;
+        }
     }
 }