Wrap g_object_unref
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 22 Jul 2017 11:36:30 +0000 (21:36 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 31 Jul 2017 12:35:48 +0000 (22:35 +1000)
16 files changed:
contrib/brushexport/interface.cpp
contrib/sunplug/sunplug.cpp
libs/gtkutil/glwidget.cpp
libs/uilib/uilib.h
radiant/build.cpp
radiant/camwindow.cpp
radiant/commands.cpp
radiant/entityinspector.cpp
radiant/feedback.cpp
radiant/map.cpp
radiant/patchdialog.cpp
radiant/preferences.cpp
radiant/textureentry.cpp
radiant/textureentry.h
radiant/texwindow.cpp
radiant/xywindow.cpp

index 83bc5be..c08ce71 100644 (file)
@@ -7,10 +7,10 @@
 
 #define GLADE_HOOKUP_OBJECT( component,widget,name ) \
        g_object_set_data_full( G_OBJECT( component ), name, \
-                                                       g_object_ref( widget ), (GDestroyNotify) g_object_unref )
+                                                       g_object_ref( (void *) widget ), (GDestroyNotify) g_object_unref )
 
 #define GLADE_HOOKUP_OBJECT_NO_REF( component,widget,name )    \
-       g_object_set_data( G_OBJECT( component ), name, widget )
+       g_object_set_data( G_OBJECT( component ), name, (void *) widget )
 
 // created by glade
 GtkWidget*
@@ -208,7 +208,7 @@ void CreateWindow( void ){
        // list store
        ui::ListStore ignorelist = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
        gtk_tree_view_set_model( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), GTK_TREE_MODEL( ignorelist ) );
-       g_object_unref( ignorelist );
+    ignorelist.unref();
 
        gtk_widget_show_all( wnd );
        g_brushexp_window = wnd;
index 6895bf2..a692853 100644 (file)
@@ -272,7 +272,7 @@ void about_plugin_window(){
        gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, FALSE, 2 ); // insert the label in the box
 
        button = ui::Button( "OK" ); // create a button with text
-       g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( gtk_widget_destroy ), window ); // connect the click event to close the window
+       g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( gtk_widget_destroy ), (void *) window ); // connect the click event to close the window
        gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 ); // insert the button in the box
 
        gtk_window_set_position( GTK_WINDOW( window ), GTK_WIN_POS_CENTER ); // center the window on screen
index 8a7a733..0e4d75b 100644 (file)
@@ -203,7 +203,7 @@ gint glwidget_context_destroyed( ui::Widget widget, gpointer data ){
 
                GLWidget_sharedContextDestroyed();
 
-               g_object_unref( g_shared );
+               g_shared.unref();
                g_shared = ui::Widget(nullptr);
        }
        return FALSE;
index 6a35f46..925384e 100644 (file)
@@ -176,8 +176,14 @@ namespace ui {
         explicit operator void *() const
         { return _handle; }
 
+        void unref()
+        { g_object_unref(_handle); }
+
         template<class Lambda>
         gulong connect(char const *detailed_signal, Lambda &&c_handler, void *data);
+
+        template<class Lambda>
+        gulong connect(char const *detailed_signal, Lambda &&c_handler, Object data);
     };
     static_assert(sizeof(Object) == sizeof(Object::native), "object slicing");
 
@@ -544,6 +550,12 @@ namespace ui {
     }
 
     template<class Lambda>
+    gulong Object::connect(char const *detailed_signal, Lambda &&c_handler, Object data)
+    {
+        return g_signal_connect(G_OBJECT(this), detailed_signal, c_handler, (_GtkObject *) data);
+    }
+
+    template<class Lambda>
     void IContainer::foreach(Lambda &&lambda)
     {
         GtkCallback cb = [](_GtkWidget *widget, void *data) -> void {
index a2b80de..9b24958 100644 (file)
@@ -892,7 +892,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi
 
                                        view.connect( "key_press_event", G_CALLBACK( project_key_press ), &projectList );
 
-                                       g_object_unref( G_OBJECT( store ) );
+                                       store.unref();
                                }
                        }
                }
@@ -925,7 +925,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi
 
                                        scr.add(view);
 
-                                       g_object_unref( G_OBJECT( store ) );
+                                       store.unref();
 
                                        view.connect( "key_press_event", G_CALLBACK( commands_key_press ), store );
 
index f64691a..df3bf3c 100644 (file)
@@ -1196,7 +1196,7 @@ CamWnd::~CamWnd(){
        g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_sizeHandler );
        g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_exposeHandler );
 
-       g_object_unref( m_gl_widget );
+       m_gl_widget.unref();
 
        m_window_observer->release();
 }
index b3def07..6b2fe8e 100644 (file)
@@ -460,7 +460,7 @@ public:
                                GlobalShortcuts_foreach( visitor );
                        }
 
-                       g_object_unref( G_OBJECT( store ) );
+                       store.unref();
                }
        }
 
index 800ee91..1e8aaa7 100644 (file)
@@ -882,7 +882,7 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){
                        gtk_table_attach( g_spawnflagsTable, widget, i % 4, i % 4 + 1, i / 4, i / 4 + 1,
                                                          (GtkAttachOptions)( GTK_FILL ),
                                                          (GtkAttachOptions)( GTK_FILL ), 0, 0 );
-                       g_object_unref( widget );
+                       widget.unref();
 
                        gtk_label_set_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN(widget)) ), str.c_str() );
                }
@@ -1341,7 +1341,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
 
                                        scr.add(view);
 
-                                       g_object_unref( G_OBJECT( store ) );
+                                       store.unref();
                                        g_entityClassList = view;
                                        g_entlist_store = store;
                                }
@@ -1429,7 +1429,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
 
                                                scr.add(view);
 
-                                               g_object_unref( G_OBJECT( store ) );
+                                               store.unref();
 
                                                g_entprops_store = store;
                                        }
index 5a10687..e1c3c48 100644 (file)
@@ -321,7 +321,7 @@ ui::Window CDbgDlg::BuildDialog(){
 
                scr.add(view);
 
-               g_object_unref( G_OBJECT( store ) );
+               store.unref();
 
                m_clist = store;
        }
index 7b36255..c767cc2 100644 (file)
@@ -885,7 +885,7 @@ void DoMapInfo(){
                }
        }
 
-       g_object_unref( G_OBJECT( EntityBreakdownWalker ) );
+       EntityBreakdownWalker.unref();
 
        char tmp[16];
        sprintf( tmp, "%u", Unsigned( g_brushCount.get() ) );
index a44fc10..9432187 100644 (file)
@@ -888,7 +888,7 @@ ui::Window PatchInspector::BuildDialog(){
                                                                                          (GtkAttachOptions)( GTK_FILL ),
                                                                                          (GtkAttachOptions)( 0 ), 0, 0 );
                                                        gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 );
-                                                       g_object_set_data( G_OBJECT( window ), "hshift_entry", entry );
+                                                       g_object_set_data( G_OBJECT( window ), "hshift_entry", (void *) entry );
                                                        // we fill in this data, if no patch is selected the widgets are unmodified when the inspector is raised
                                                        // so we need to have at least one initialisation somewhere
                                                        entry_set_float( entry, g_pi_globals.shift[0] );
index 6af5d58..ba5e75c 100644 (file)
@@ -730,7 +730,7 @@ ui::Window PrefsDlg::BuildDialog(){
 
 
                                {
-                                       GtkTreeStore* store = gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER );
+                                       auto store = gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER );
 
                                        ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) ));
                                        gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
index f692717..96a46dc 100644 (file)
 
 #include <gtk/gtk.h>
 
-template
-class EntryCompletion<TextureNameList>;
-
-template
-class EntryCompletion<ShaderList>;
-
 template<class StringList>
 void EntryCompletion<StringList>::connect(ui::Entry entry)
 {
@@ -72,3 +66,9 @@ void EntryCompletion<StringList>::update()
     clear();
     fill();
 }
+
+template
+class EntryCompletion<TextureNameList>;
+
+template
+class EntryCompletion<ShaderList>;
index 7045b29..d36aff6 100644 (file)
@@ -43,7 +43,7 @@ public:
 
     void append(const char *string);
 
-    typedef MemberCaller1<EntryCompletion, const char *, &EntryCompletion::append> AppendCaller;
+    using AppendCaller = MemberCaller1<EntryCompletion, const char *, &EntryCompletion::append>;
 
     void fill();
 
@@ -51,7 +51,7 @@ public:
 
     void update();
 
-    typedef MemberCaller<EntryCompletion, &EntryCompletion::update> UpdateCaller;
+    using UpdateCaller = MemberCaller<EntryCompletion, &EntryCompletion::update>;
 };
 
 class TextureNameList {
index 880347f..6081d14 100644 (file)
@@ -2139,7 +2139,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
                        auto renderer = ui::CellRendererText();
 
                        g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) ));
-                       g_object_unref( G_OBJECT( g_TextureBrowser.m_assigned_store ) );
+                       g_TextureBrowser.m_assigned_store.unref();
                        g_TextureBrowser.m_assigned_tree.connect( "row-activated", (GCallback) TextureBrowser_removeTags, NULL );
                        gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), FALSE );
 
@@ -2167,7 +2167,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
                        auto renderer = ui::CellRendererText();
 
                        g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) ));
-                       g_object_unref( G_OBJECT( g_TextureBrowser.m_available_store ) );
+                       g_TextureBrowser.m_available_store.unref();
                        g_TextureBrowser.m_available_tree.connect( "row-activated", (GCallback) TextureBrowser_assignTags, NULL );
                        gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), FALSE );
 
@@ -2233,7 +2233,7 @@ void TextureBrowser_destroyWindow(){
        g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_sizeHandler );
        g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_exposeHandler );
 
-       g_object_unref( g_TextureBrowser.m_gl_widget );
+       g_TextureBrowser.m_gl_widget.unref();
 }
 
 const Vector3& TextureBrowser_getBackgroundColour( TextureBrowser& textureBrowser ){
index 81b6d3d..8250115 100644 (file)
@@ -867,7 +867,7 @@ XYWnd::~XYWnd(){
        g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_sizeHandler );
        g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_exposeHandler );
 
-       g_object_unref( m_gl_widget );
+       m_gl_widget.unref();
 
        m_window_observer->release();
 }