Kouhei Sutou 2017-11-13 23:23:49 +0900 (Mon, 13 Nov 2017)
New Revision: 725cdceceac7aca471e8623cdd00b8c8d351a545
https://github.com/ruby-gnome2/ruby-gnome2/commit/725cdceceac7aca471e8623cdd00b8c8d351a545
Message:
gtk3: mark top-level windows
GitHub: fix #1103
Reported by cedlemo. Thanks!!!
Added files:
gtk3/ext/gtk3/rb-gtk3-window.c
Modified files:
gtk3/ext/gtk3/rb-gtk3-private.h
gtk3/ext/gtk3/rb-gtk3.c
Modified: gtk3/ext/gtk3/rb-gtk3-private.h (+2 -1)
===================================================================
--- gtk3/ext/gtk3/rb-gtk3-private.h 2017-11-10 00:26:02 +0900 (704c772fd)
+++ gtk3/ext/gtk3/rb-gtk3-private.h 2017-11-13 23:23:49 +0900 (2bb2d097a)
@@ -1,6 +1,6 @@
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/*
- * Copyright (C) 2015 Ruby-GNOME2 Project Team
+ * Copyright (C) 2015-2017 Ruby-GNOME2 Project Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -32,5 +32,6 @@ G_GNUC_INTERNAL void rbgtk3_spin_button_init(void);
G_GNUC_INTERNAL void rbgtk3_tree_model_init(void);
G_GNUC_INTERNAL void rbgtk3_tree_view_init(void);
G_GNUC_INTERNAL void rbgtk3_widget_init(void);
+G_GNUC_INTERNAL void rbgtk3_window_init(void);
#endif
Added: gtk3/ext/gtk3/rb-gtk3-window.c (+78 -0) 100644
===================================================================
--- /dev/null
+++ gtk3/ext/gtk3/rb-gtk3-window.c 2017-11-13 23:23:49 +0900 (02fc79a75)
@@ -0,0 +1,78 @@
+/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (C) 2017 Ruby-GNOME2 Project Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include "rb-gtk3-private.h"
+
+typedef struct {
+ int dummy;
+} ToplevelWindowMarkerData;
+
+static void
+toplevel_window_marker_mark(G_GNUC_UNUSED void *_)
+{
+ GList *list = gtk_window_list_toplevels();
+ GList *node;
+ for (node = list; node; node = g_list_next(node)) {
+ rbgobj_gc_mark_instance(node->data);
+ }
+ g_list_free(list);
+}
+
+static void
+toplevel_window_marker_free(void *data)
+{
+ xfree(data);
+}
+
+static const rb_data_type_t toplevel_window_marker_type = {
+ "Gtk::ToplevelsMarker",
+ {
+ toplevel_window_marker_mark,
+ toplevel_window_marker_free,
+ NULL,
+ {
+ NULL,
+ NULL,
+ },
+ },
+ NULL,
+ NULL,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+
+void
+rbgtk3_window_init(void)
+{
+ VALUE mGtk;
+ VALUE toplevel_window_marker_class;
+ VALUE toplevel_window_marker;
+ ToplevelWindowMarkerData *data;
+
+ mGtk = rb_const_get(rb_cObject, rb_intern("Gtk"));
+ toplevel_window_marker_class =
+ rb_define_class_under(mGtk, "ToplevelWindowMarker", rb_cData);
+ toplevel_window_marker =
+ TypedData_Make_Struct(toplevel_window_marker_class,
+ ToplevelWindowMarkerData,
+ &toplevel_window_marker_type,
+ data);
+ rb_gc_register_mark_object(toplevel_window_marker);
+}
Modified: gtk3/ext/gtk3/rb-gtk3.c (+2 -1)
===================================================================
--- gtk3/ext/gtk3/rb-gtk3.c 2017-11-10 00:26:02 +0900 (8a866f62a)
+++ gtk3/ext/gtk3/rb-gtk3.c 2017-11-13 23:23:49 +0900 (94761eb81)
@@ -1,6 +1,6 @@
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/*
- * Copyright (C) 2015 Ruby-GNOME2 Project Team
+ * Copyright (C) 2015-2017 Ruby-GNOME2 Project Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -639,6 +639,7 @@ Init_gtk3(void)
rbgtk3_tree_model_init();
rbgtk3_tree_view_init();
rbgtk3_widget_init();
+ rbgtk3_window_init();
rbgobj_boxed_not_copy_obj(GTK_TYPE_SELECTION_DATA);
setlocale(LC_NUMERIC, "C");
|