From db08358e3a89a5b97daf4b5126b3e97b42e99022 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 25 May 2016 18:26:37 +0200 Subject: [PATCH] Update to be more compatible with glibmm 2.47.6 and later * gdk/src/types.hg: Glib::ScopedPtr has been deprecated. To be able to build gtkmm with GLIBMM_DISABLE_DEPRECATED, copy Glib::ScopedPtr to Gdk::ScopedPtr. * gdk/src/types.ccg: * gtk/src/clipboard.ccg: * gtk/src/colorselection.ccg: * gtk/src/rc.ccg: * gtk/src/widget.ccg: * demos/gtk-demo/example_dialog.cc: Use Gdk::ScopedPtr instead of Glib::ScopedPtr. * gtk/src/menushell.ccg: Glib::Refptr::operator bool() has been made explicit. It's no longer used in item != 0, where item is a RefPtr. Change the expression to the equivalent !!item. Even with these changes it's not unproblematic to build gtkmm2 with a new version of gmmproc, because _CLASS_BOXEDTYPE and _CLASS_GOBJECT generate move operators but gtkmm2 does not require a C++11 compiler. --- demos/gtk-demo/example_dialog.cc | 2 +- gdk/src/types.ccg | 2 +- gdk/src/types.hg | 24 ++++++++++++++++++++++++ gtk/src/clipboard.ccg | 3 +-- gtk/src/colorselection.ccg | 2 +- gtk/src/menushell.ccg | 2 +- gtk/src/rc.ccg | 5 ++--- gtk/src/widget.ccg | 8 ++++---- 8 files changed, 35 insertions(+), 13 deletions(-) diff --git a/demos/gtk-demo/example_dialog.cc b/demos/gtk-demo/example_dialog.cc index e41aada..b86e1c1 100644 --- a/demos/gtk-demo/example_dialog.cc +++ b/demos/gtk-demo/example_dialog.cc @@ -113,7 +113,7 @@ void Example_Dialog::on_button_message() Glib::ustring strMessage = "This message box has been popped up the following\n" "number of times:\n\n"; { - Glib::ScopedPtr buf (g_strdup_printf("%d", m_count)); + Gdk::ScopedPtr buf (g_strdup_printf("%d", m_count)); strMessage += buf.get(); } Gtk::MessageDialog dialog(strMessage, false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true); //true = modal diff --git a/gdk/src/types.ccg b/gdk/src/types.ccg index a5a28e4..6538d85 100644 --- a/gdk/src/types.ccg +++ b/gdk/src/types.ccg @@ -48,7 +48,7 @@ GdkAtom AtomStringTraits::to_c_type(const std::string& atom_name) std::string AtomStringTraits::to_cpp_type(GdkAtom atom) { if(char *const atom_name = gdk_atom_name(atom)) - return std::string(Glib::ScopedPtr(atom_name).get()); + return std::string(Gdk::ScopedPtr(atom_name).get()); else return std::string(); } diff --git a/gdk/src/types.hg b/gdk/src/types.hg index a05ba0c..bb75c68 100644 --- a/gdk/src/types.hg +++ b/gdk/src/types.hg @@ -127,6 +127,30 @@ struct AtomStringTraits // we don't want it to look like we're calling a template trait, but // a utility function. -Bryan typedef AtomStringTraits AtomString; + +// Glib::ScopedPtr has been deprecated in glibmm 2.47.6. +// We don't want to use the replacement, Glib::make_unique_ptr_gfree(), +// in gtkmm-2, because it requires C++11. Instead, add this identical Gdk::ScopedPtr, +// intended only for internal use in gtkmm. + +/** Helper to deal with memory allocated + * by GLib functions in an exception-safe manner. + */ +template +class ScopedPtr +{ +private: + T* ptr_; + ScopedPtr(const ScopedPtr&); + ScopedPtr& operator=(const ScopedPtr&); + +public: + ScopedPtr() : ptr_(nullptr) {} + explicit ScopedPtr(T* ptr) : ptr_(ptr) {} + ~ScopedPtr() noexcept { g_free(ptr_); } + T* get() const { return ptr_; } + T** addr() { return &ptr_; } +}; #endif //DOXYGEN_SHOULD_SKIP_THIS typedef Glib::ArrayHandle ArrayHandle_AtomString; diff --git a/gtk/src/clipboard.ccg b/gtk/src/clipboard.ccg index 0379162..6b74cf9 100644 --- a/gtk/src/clipboard.ccg +++ b/gtk/src/clipboard.ccg @@ -19,7 +19,6 @@ #include #include -#include //For ScopedPtr<>. #include namespace @@ -320,7 +319,7 @@ std::string Clipboard::wait_for_rich_text(const Glib::RefPtr& buffer { gchar* format_atom_name = gdk_atom_name(format_atom); if(format_atom_name) - format = Glib::ScopedPtr(format_atom_name).get(); //This frees the buffer. + format = Gdk::ScopedPtr(format_atom_name).get(); //This frees the buffer. result = std::string((char*)text, length); g_free(text); diff --git a/gtk/src/colorselection.ccg b/gtk/src/colorselection.ccg index e665200..a91b647 100644 --- a/gtk/src/colorselection.ccg +++ b/gtk/src/colorselection.ccg @@ -86,7 +86,7 @@ Gdk::ArrayHandle_Color ColorSelection::palette_from_string(const Glib::ustring& Glib::ustring ColorSelection::palette_to_string(const Gdk::ArrayHandle_Color& colors) { if(char *const str = gtk_color_selection_palette_to_string(colors.data(), colors.size())) - return Glib::ustring(Glib::ScopedPtr(str).get()); + return Glib::ustring(Gdk::ScopedPtr(str).get()); else return Glib::ustring(); } diff --git a/gtk/src/menushell.ccg b/gtk/src/menushell.ccg index 6ca9db1..be22f0e 100644 --- a/gtk/src/menushell.ccg +++ b/gtk/src/menushell.ccg @@ -118,7 +118,7 @@ MenuList::iterator MenuList::insert(MenuList::iterator position, const Element& { const Glib::RefPtr item = element.get_child(); - g_return_val_if_fail(item != 0, position); + g_return_val_if_fail(!!item, position); g_return_val_if_fail(gparent() != 0, position); int pos = -1; diff --git a/gtk/src/rc.ccg b/gtk/src/rc.ccg index 3fa1215..6211744 100644 --- a/gtk/src/rc.ccg +++ b/gtk/src/rc.ccg @@ -18,7 +18,6 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include #include #include @@ -30,13 +29,13 @@ namespace Gtk void RcStyle::set_name(const Glib::ustring& name) { - const Glib::ScopedPtr old_name (gobj()->name); + const Gdk::ScopedPtr old_name (gobj()->name); gobj()->name = g_strdup(name.c_str()); } void RcStyle::set_bg_pixmap_name(StateType state, const Glib::ustring& name) { - const Glib::ScopedPtr old_name (gobj()->bg_pixmap_name[state]); + const Gdk::ScopedPtr old_name (gobj()->bg_pixmap_name[state]); gobj()->bg_pixmap_name[state] = g_strdup(name.c_str()); } diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg index be3c14d..4c1beb1 100644 --- a/gtk/src/widget.ccg +++ b/gtk/src/widget.ccg @@ -202,8 +202,8 @@ Widget* Widget::get_current_modal_grab() void Widget::path(Glib::ustring& path_arg, Glib::ustring& path_reversed) { guint path_length = 0; - Glib::ScopedPtr path_ptr; - Glib::ScopedPtr rpath_ptr; + Gdk::ScopedPtr path_ptr; + Gdk::ScopedPtr rpath_ptr; gtk_widget_path(gobj(), &path_length, path_ptr.addr(), rpath_ptr.addr()); @@ -214,8 +214,8 @@ void Widget::path(Glib::ustring& path_arg, Glib::ustring& path_reversed) void Widget::class_path(Glib::ustring& path_arg, Glib::ustring& path_reversed) { guint path_length = 0; - Glib::ScopedPtr path_ptr; - Glib::ScopedPtr rpath_ptr; + Gdk::ScopedPtr path_ptr; + Gdk::ScopedPtr rpath_ptr; gtk_widget_class_path(gobj(), &path_length, path_ptr.addr(), rpath_ptr.addr()); From 185abd365c2898ad77dbb33a099341fa28e5a496 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 2 Jul 2015 19:53:16 +0200 Subject: Add #includes needed with glibmm newer than 2.31.0. * gdk/src/color.hg: * gdk/src/pixbufanimationiter.hg: * gdk/src/pixbufformat.hg: * gdk/src/rectangle.hg: * gdk/src/rgbcmap.hg: * gdk/src/types.hg: * gtk/src/enums.hg: * gtk/src/main.hg: * gtk/src/papersize.hg: * gtk/src/textattributes.hg: * gtk/src/treemodel.hg: Add individual includes now that gmmproc does not add #include at the top of every generated header. * gtk/gtkmm/border.h: Add #include to make glibmm/tools/test_scripts/testheaders.sh happy. diff --git a/gdk/src/color.hg b/gdk/src/color.hg index ce22d4b..09c91fc 100644 --- a/gdk/src/color.hg +++ b/gdk/src/color.hg @@ -21,6 +21,8 @@ // the #ifndef GDKMM_DISABLE_DEPRECATED in deprecated classes) is generated: _CONFIGINCLUDE(gdkmmconfig.h) +#include + _DEFS(gdkmm,gdk) namespace Gdk diff --git a/gdk/src/pixbufanimationiter.hg b/gdk/src/pixbufanimationiter.hg index 4e12f52..f89a037 100644 --- a/gdk/src/pixbufanimationiter.hg +++ b/gdk/src/pixbufanimationiter.hg @@ -21,6 +21,7 @@ #include #include +#include #include _DEFS(gdkmm,gdk) diff --git a/gdk/src/pixbufformat.hg b/gdk/src/pixbufformat.hg index c460056..6c7daab 100644 --- a/gdk/src/pixbufformat.hg +++ b/gdk/src/pixbufformat.hg @@ -20,7 +20,7 @@ _DEFS(gdkmm,gdk) #include - +#include #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { typedef struct _GdkPixbufFormat GdkPixbufFormat; } diff --git a/gdk/src/rectangle.hg b/gdk/src/rectangle.hg index f48de5a..01d1959 100644 --- a/gdk/src/rectangle.hg +++ b/gdk/src/rectangle.hg @@ -19,6 +19,7 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include _DEFS(gdkmm,gdk) diff --git a/gdk/src/rgbcmap.hg b/gdk/src/rgbcmap.hg index bfdfdfe..817661f 100644 --- a/gdk/src/rgbcmap.hg +++ b/gdk/src/rgbcmap.hg @@ -24,6 +24,7 @@ _DEFS(gdkmm,gdk) #m4 _POP() #include +#include #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { typedef struct _GdkRgbCmap GdkRgbCmap; } diff --git a/gdk/src/types.hg b/gdk/src/types.hg index fd644b8..a05ba0c 100644 --- a/gdk/src/types.hg +++ b/gdk/src/types.hg @@ -19,6 +19,8 @@ _DEFS(gdkmm,gdk) +#include +#include #include #include diff --git a/gtk/gtkmm/border.h b/gtk/gtkmm/border.h index a64c669..b48017e 100644 --- a/gtk/gtkmm/border.h +++ b/gtk/gtkmm/border.h @@ -22,6 +22,7 @@ */ #include +#include /* For GtkBorder */ namespace Gtk { diff --git a/gtk/src/enums.hg b/gtk/src/enums.hg index 66c3696..ad3d20c 100644 --- a/gtk/src/enums.hg +++ b/gtk/src/enums.hg @@ -19,6 +19,7 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include //For GTKMM_MAEMO_EXTENSIONS_ENABLED _DEFS(gtkmm,gtk) diff --git a/gtk/src/main.hg b/gtk/src/main.hg index c6c05ed..2665445 100644 --- a/gtk/src/main.hg +++ b/gtk/src/main.hg @@ -22,6 +22,7 @@ #include #include //For GdkEventKey +#include _DEFS(gtkmm,gtk) diff --git a/gtk/src/papersize.hg b/gtk/src/papersize.hg index 41fcb3c..3914cd1 100644 --- a/gtk/src/papersize.hg +++ b/gtk/src/papersize.hg @@ -17,6 +17,9 @@ _DEFS(gtkmm,gtk) +#include +#include + namespace Gtk { diff --git a/gtk/src/textattributes.hg b/gtk/src/textattributes.hg index b043f98..3966529 100644 --- a/gtk/src/textattributes.hg +++ b/gtk/src/textattributes.hg @@ -22,6 +22,8 @@ _DEFS(gtkmm,gtk) +#include + namespace Gtk { diff --git a/gtk/src/treemodel.hg b/gtk/src/treemodel.hg index a04d924..360b4ed 100644 --- a/gtk/src/treemodel.hg +++ b/gtk/src/treemodel.hg @@ -18,6 +18,7 @@ */ #include +#include #include _DEFS(gtkmm,gtk) -- cgit v0.10.2 From 9d52f886ffe556f9615f98a280d3a036a9ecf28e Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 5 Jul 2015 15:41:11 +0200 Subject: More fixes to suit newish glibmm. * gtk/src/entrycompletion.hg: Add a missing double quote in _WRAP_PROPERTY("text_column, int), to avoid a warning from gmmproc 2.41.0 or newer. * gtk/src/printunixdialog.hg: get_selected_printer(): Ref-counting correction. Fix a .->, typo to make the refreturn option actually be used. Necessary with gmmproc 2.29.13 or newer. Discussed in bug #657751, comment 5. diff --git a/gtk/src/entrycompletion.hg b/gtk/src/entrycompletion.hg index 3a32e4f..70c5cc7 100644 --- a/gtk/src/entrycompletion.hg +++ b/gtk/src/entrycompletion.hg @@ -218,7 +218,7 @@ dnl _WRAP_PROPERTY("model", Glib::RefPtr) _WRAP_PROPERTY("minimum_key_length", int) - _WRAP_PROPERTY("text_column, int) + _WRAP_PROPERTY("text_column", int) _WRAP_PROPERTY("inline_completion", bool) _WRAP_PROPERTY("popup_completion", bool) _WRAP_PROPERTY("popup_set_width", bool) diff --git a/gtk/src/printunixdialog.hg b/gtk/src/printunixdialog.hg index 87de89f..c05e5c3 100644 --- a/gtk/src/printunixdialog.hg +++ b/gtk/src/printunixdialog.hg @@ -71,7 +71,7 @@ public: #m4 _CONVERSION(`GtkPrinter*',`Glib::RefPtr',`Glib::wrap($3)') _WRAP_METHOD(Glib::RefPtr get_selected_printer(), gtk_print_unix_dialog_get_selected_printer, refreturn) - _WRAP_METHOD(Glib::RefPtr get_selected_printer() const, gtk_print_unix_dialog_get_selected_printer, refreturn. constversion) + _WRAP_METHOD(Glib::RefPtr get_selected_printer() const, gtk_print_unix_dialog_get_selected_printer, refreturn, constversion) void add_custom_tab(const Widget& child, const Glib::ustring& tab_label); _WRAP_METHOD(void add_custom_tab(const Widget& child, const Widget& tab_label), gtk_print_unix_dialog_add_custom_tab) -- cgit v0.10.2 From 4fb3efa910a46364fa8ec4d60fcce557200e4dcb Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 14 Mar 2012 11:41:46 +0100 Subject: PaperSize: Correct the PaperSizeTraits pre-declaration. * gtk/src/papersize.hg: PaperSizeTraits is a struct, not a class. clang++ noticed this while building Glom, though I have not run it on all of gtkmm. diff --git a/gtk/src/papersize.hg b/gtk/src/papersize.hg index 2e5700d..41fcb3c 100644 --- a/gtk/src/papersize.hg +++ b/gtk/src/papersize.hg @@ -21,7 +21,7 @@ namespace Gtk { #ifndef DOXYGEN_SHOULD_SKIP_THIS -class PaperSizeTraits; +struct PaperSizeTraits; #endif /** Common paper names, from PWG 5101.1-2002 PWG: Standard for Media Standardized Names -- cgit v0.10.2 --- a/gtk/src/menushell.ccg 2015-07-16 21:00:55.000000000 +0200 +++ b/gtk/src/menushell.ccg 2015-12-09 01:03:45.127863899 +0100 @@ -43,7 +43,7 @@ MenuShell::MenuShell(GtkMenuShell* casti {} // TODO: Why do we need a custom dtor? -MenuShell::~MenuShell() +MenuShell::~MenuShell() noexcept {} void MenuShell::accelerate(Window& window) --- a/gtk/gtkmm/menushell.cc 2015-09-22 11:41:47.000000000 +0200 +++ b/gtk/gtkmm/menushell.cc 2015-12-09 01:06:27.641701385 +0100 @@ -54,7 +54,7 @@ MenuShell::MenuShell(GtkMenuShell* casti {} // TODO: Why do we need a custom dtor? -MenuShell::~MenuShell() +MenuShell::~MenuShell() noexcept {} void MenuShell::accelerate(Window& window) --- a/gtk/src/widget.ccg 2015-07-16 21:00:55.000000000 +0200 +++ b/gtk/src/widget.ccg 2015-12-09 07:36:47.328538621 +0100 @@ -413,7 +413,7 @@ void Widget_Class::get_preferred_width_f (*base->get_preferred_width_for_height)(self, height, minimum_width, natural_width); } -Widget::~Widget() +Widget::~Widget() noexcept {} void Widget::reparent(Widget& new_parent) --- a/gtk/gtkmm/widget.cc 2015-09-22 11:44:13.000000000 +0200 +++ b/gtk/gtkmm/widget.cc 2015-12-09 07:39:29.318214641 +0100 @@ -423,7 +423,7 @@ void Widget_Class::get_preferred_width_f (*base->get_preferred_width_for_height)(self, height, minimum_width, natural_width); } -Widget::~Widget() +Widget::~Widget() noexcept {} void Widget::reparent(Widget& new_parent) Fixes the following build error: menushell.cc:133:29: error: no match for 'operator!=' (operand types are 'const Glib::RefPtr' and 'int') g_return_val_if_fail(item != 0, position); ~~~~~^~~~ Signed-off-by: Lucas C. Villa Real --- gtkmm-2.24.4/gtk/gtkmm/menushell.cc.orig 2016-08-26 21:55:08.858311055 +0000 +++ gtkmm-2.24.4/gtk/gtkmm/menushell.cc 2016-08-26 21:55:33.206310578 +0000 @@ -130,7 +130,7 @@ MenuList::iterator MenuList::insert(Menu { const Glib::RefPtr item = element.get_child(); - g_return_val_if_fail(item != 0, position); + g_return_val_if_fail(!!item, position); g_return_val_if_fail(gparent() != 0, position); int pos = -1;