[gtkmm] Gtk::ApplicationWindow: Hand-code the ctor that takes an application param
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gtk::ApplicationWindow: Hand-code the ctor that takes an application param
- Date: Thu, 3 Dec 2015 15:43:57 +0000 (UTC)
commit c4500fe8c1f2d5d98e04aaabcdafa1e5b794e548
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Thu Dec 3 16:40:54 2015 +0100
Gtk::ApplicationWindow: Hand-code the ctor that takes an application param
* gtk/src/applicationwindow.[hg|ccg]: Hand-code the constructor that takes
an application parameter. Bug #758813.
gtk/src/applicationwindow.ccg | 25 ++++++++++++++++++++++++-
gtk/src/applicationwindow.hg | 3 ++-
2 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/gtk/src/applicationwindow.ccg b/gtk/src/applicationwindow.ccg
index 1043db9..b73ec37 100644
--- a/gtk/src/applicationwindow.ccg
+++ b/gtk/src/applicationwindow.ccg
@@ -19,7 +19,30 @@
namespace Gtk
{
+ApplicationWindow::ApplicationWindow(const Glib::RefPtr<Application>& application)
+:
+ // Mark this class as non-derived to allow C++ vfuncs to be skipped.
+ Glib::ObjectBase(nullptr),
+ Gtk::Window(Glib::ConstructParams(applicationwindow_class_.init()))
+{
+ // Don't set the "application" property in ConstructParams. It would result in
+ // an attempt to set two C++ wrappers on the GApplicationWindow C object,
+ // if "application" is not a plain Gtk::Application, but derived from it.
+ // Like so:
+ // - Glib::Object::Object(const Glib::ConstructParams& construct_params) calls
+ // g_object_newv() to create a new GApplicationWindow.
+ // - In gtk+, gtk_application_add_window() is called. It emits the window_added
+ // signal with the new GApplicationWindow as a parameter.
+ // - Application_signal_window_added_callback() calls Glib::wrap(GWindow*)
+ // before *this has been set as the wrapper. Glib::wrap() then creates a
+ // wrapper (not *this).
+ // - Glib::Object::Object() calls Glib::ObjectBase::initialize(), which calls
+ // Glib::ObjectBase::_set_current_wrapper() to set *this as the C++ wrapper,
+ // but by then another wrapper has already been set.
+ // https://bugzilla.gnome.org/show_bug.cgi?id=758813
-
+ if (application)
+ application->add_window(*this);
+}
} // namespace Gtk
diff --git a/gtk/src/applicationwindow.hg b/gtk/src/applicationwindow.hg
index 8881a7e..48f51d7 100644
--- a/gtk/src/applicationwindow.hg
+++ b/gtk/src/applicationwindow.hg
@@ -78,7 +78,8 @@ class ApplicationWindow
public:
_CTOR_DEFAULT
- _WRAP_CTOR(ApplicationWindow(const Glib::RefPtr<Application>& application), gtk_application_window_new)
+ explicit ApplicationWindow(const Glib::RefPtr<Application>& application);
+ _IGNORE(gtk_application_window_new)
_WRAP_METHOD(void set_show_menubar(bool show_menubar = true), gtk_application_window_set_show_menubar)
_WRAP_METHOD(bool get_show_menubar() const, gtk_application_window_get_show_menubar)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]