[gtkmm] Application: Don't call add_window() before the application is registered.



commit e05d9666464e90c8e6cf347d7ef63680e0a44b2c
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Wed Aug 29 19:32:28 2012 +0200

    Application: Don't call add_window() before the application is registered.
    
    * gtk/src/application.[hg|ccg]: Move the call to add_window() from
    run(Window& window, int argc, char** argv) and run(Window& window) to
    on_activate_show_main_window() and rename it to
    on_activate_add_and_show_main_window(). Bug #681323.

 ChangeLog               |    9 +++++++++
 gtk/src/application.ccg |   23 ++++++++++++-----------
 gtk/src/application.hg  |    2 +-
 3 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c547c90..99908b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-08-29  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
+	Application: Don't call add_window() before the application is registered.
+
+	* gtk/src/application.[hg|ccg]: Move the call to add_window() from
+	run(Window& window, int argc, char** argv) and run(Window& window) to
+	on_activate_show_main_window() and rename it to
+	on_activate_add_and_show_main_window(). Bug #681323.
+
 2012-07-16  Murray Cumming  <murrayc murrayc com>
 
 	Show get_type() in the API documentation.
diff --git a/gtk/src/application.ccg b/gtk/src/application.ccg
index 83a8e3d..cd79dcd 100644
--- a/gtk/src/application.ccg
+++ b/gtk/src/application.ccg
@@ -129,13 +129,12 @@ int Application::run(int argc, char** argv)
 
 int Application::run(Window& window, int argc, char** argv)
 {
-  add_window(window);
-  
-  //We cannot show the window until GApplication::activate has been
-  //called, or we will crash because the application has not been "registered".
+  //We cannot add and show the window until the GApplication::activate signal
+  //has been emitted, or we will crash because the application has not been
+  //registered. (At least if window is an ApplicationWindow.)
   signal_activate().connect(
     sigc::bind(
-      sigc::mem_fun(*this, &Application::on_activate_show_main_window),
+      sigc::mem_fun(*this, &Application::on_activate_add_and_show_main_window),
       &window));
 
   const int result = Gio::Application::run(argc, argv);
@@ -148,13 +147,12 @@ int Application::run(Window& window)
   g_assert(m_argc);
   g_assert(m_argv);
 
-  add_window(window);
-
-  //We cannot show the window until GApplication::activate has been
-  //called, or we will crash because the application has not been "registered".
+  //We cannot add and show the window until the GApplication::activate signal
+  //has been emitted, or we will crash because the application has not been
+  //registered. (At least if window is an ApplicationWindow.)
   signal_activate().connect(
     sigc::bind(
-      sigc::mem_fun(*this, &Application::on_activate_show_main_window),
+      sigc::mem_fun(*this, &Application::on_activate_add_and_show_main_window),
       &window));
 
   const int result = Gio::Application::run(m_argc, m_argv);
@@ -170,10 +168,13 @@ int Application::run()
   return result;
 }
 
-void Application::on_activate_show_main_window(Window* window)
+void Application::on_activate_add_and_show_main_window(Window* window)
 {
   if(window)
+  {
+    add_window(*window);
     window->show();
+  }
 }
 
 
diff --git a/gtk/src/application.hg b/gtk/src/application.hg
index eb3a794..87fae52 100644
--- a/gtk/src/application.hg
+++ b/gtk/src/application.hg
@@ -268,7 +268,7 @@ private:
    */
   const Glib::Class& custom_class_init();
   
-  void on_activate_show_main_window(Window* window);
+  void on_activate_add_and_show_main_window(Window* window);
   void on_window_hide(Window* window);
   
   //We need these to call g_application_run(), 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]