From 96308f0534294faeaad8fe915f743ca188f7714f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Jan 2018 00:24:58 +0100 Subject: [PATCH] Use wxGtkObject RAII wrapper for GtkListStore Prefer RAII wrapper class to manual g_object_unref() calls. --- src/gtk/textentry.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gtk/textentry.cpp b/src/gtk/textentry.cpp index 1b7b003deb..66c9c99516 100644 --- a/src/gtk/textentry.cpp +++ b/src/gtk/textentry.cpp @@ -35,6 +35,7 @@ #include #include "wx/gtk/private.h" #include "wx/gtk/private/gtk2-compat.h" +#include "wx/gtk/private/object.h" #include "wx/gtk/private/string.h" //----------------------------------------------------------------------------- @@ -231,7 +232,7 @@ public: DoEnableCompletion(); - GtkListStore * const store = gtk_list_store_new (1, G_TYPE_STRING); + wxGtkObject store(gtk_list_store_new (1, G_TYPE_STRING)); for ( wxArrayString::const_iterator i = strings.begin(); i != strings.end(); @@ -241,7 +242,6 @@ public: } UseModel(store); - g_object_unref (store); } // Takes ownership of the pointer if it is non-NULL. @@ -392,7 +392,7 @@ private: if ( m_completer->Start(prefix) ) { - GtkListStore * const store = gtk_list_store_new (1, G_TYPE_STRING); + wxGtkObject store(gtk_list_store_new (1, G_TYPE_STRING)); for (;;) { @@ -404,7 +404,6 @@ private: } UseModel(store); - g_object_unref (store); m_newCompletionsNeeded = false; }