Author Topic: Undocked (floating) windows can cause GTK-Critical on linux  (Read 4257 times)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
I just filed the following bug-report at berlios:
Quote
When starting Code::Blocks from console on linux (debian sid) with undocked windows (for example Symbols browser), I get the following error-message:
"(codeblocks:<PID_of_C::B>): Gtk-CRITICAL **: gtk_window_realize_icon: assertion `info->icon_pixmap == NULL' failed".
This happens in "app.cpp" in line 543, when "frame->Show()" is called.

The error occurs, because in the ctor of MainFrame the variable "m_StartupDone" is set to "true" and "DoUpdateLayout()" is called. The layout-update leads to a call of the function "Show()" for the undocked (free-floating) windows, before "Show()" is called for the main window ("MainFrame*").

Here's the linkt to the bug-report: http://developer.berlios.de/bugs/?func=detailbug&bug_id=13982&group_id=5358.


I also submitted a patch that avoids this behaviour, by setting "m_StartupDone" after "frame->Show()" via a function-call.

Here's the link to the patch: http://developer.berlios.de/patch/?func=detailpatch&patch_id=2490&group_id=5358.

Here comes the patch itself:

Code
--- codeblocks-1.0svn.orig/src/src/main.h       2008-03-01 09:47:48.000000000 +0100
+++ codeblocks-1.0svn.work/src/src/main.h       2008-06-07 11:26:46.000000000 +0200
@@ -52,6 +52,8 @@
         wxAcceleratorTable* m_pAccel;
         MainFrame(wxWindow* parent = (wxWindow*)NULL);
         ~MainFrame();
+        // Needed to make sure DoUpdateLayout() is not called before MainFrame is shown
+        void StartupDone();

         // needed for binding with SqPlus
         MainFrame(const MainFrame& rhs){ cbThrow(_T("Can't use MainFrame's copy constructor")); }
--- codeblocks-1.0svn.orig/src/src/main.cpp     2008-05-23 11:24:19.000000000 +0200
+++ codeblocks-1.0svn.work/src/src/main.cpp     2008-06-07 11:49:01.000000000 +0200
@@ -527,8 +527,9 @@
     RegisterScriptFunctions();
     RunStartupScripts();

-    m_StartupDone = true;
-    DoUpdateLayout();
+//    Don't allow updates before the MainFrame is shown, because this leads to a Gtk-CRITICAL if child-windows are not docked.
+//    m_StartupDone = true;
+//    DoUpdateLayout();

 //    if (Manager::Get()->GetLogManager()->HasErrors())
 //    {
@@ -559,6 +560,12 @@
     //Manager::Get()->Free();
 }

+void MainFrame::StartupDone()
+{
+    m_StartupDone = true;
+    DoUpdateLayout();
+}
+
 void MainFrame::RegisterEvents()
 {
     Manager* pm = Manager::Get();
--- codeblocks-1.0svn.orig/src/src/app.cpp      2008-06-03 09:33:37.000000000 +0200
+++ codeblocks-1.0svn.work/src/src/app.cpp      2008-06-07 11:53:01.000000000 +0200
@@ -542,6 +542,8 @@
         SetTopWindow(frame);
         frame->Show();

+               frame->StartupDone(); // this function tells the MainFrame that Laout Updates are allowed
+
         frame->ShowTips(); // this func checks if the user wants tips, so no need to check here

         if(platform::windows)