From cbce100ca0833e013ca005dd5d4831bade8ae6f7 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 7 Dec 2012 13:40:51 +0000 Subject: Fix some memory-management issues --- tikzit/src/gtk/Application.m | 3 ++- tikzit/src/gtk/ToolBox.m | 9 +-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tikzit/src/gtk/Application.m b/tikzit/src/gtk/Application.m index 38ef231..ecaec6d 100644 --- a/tikzit/src/gtk/Application.m +++ b/tikzit/src/gtk/Application.m @@ -109,13 +109,14 @@ Application* app = nil; [BoundingBoxTool tool], [HandTool tool], nil]; + activeTool = [tools objectAtIndex:0]; for (id tool in tools) { [tool loadConfiguration:configFile]; } - activeTool = [[tools objectAtIndex:0] retain]; toolBox = [[ToolBox alloc] initWithTools:tools]; [toolBox loadConfiguration:configFile]; + [toolBox setSelectedTool:activeTool]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectedToolChanged:) diff --git a/tikzit/src/gtk/ToolBox.m b/tikzit/src/gtk/ToolBox.m index 5c7473d..d7c991d 100644 --- a/tikzit/src/gtk/ToolBox.m +++ b/tikzit/src/gtk/ToolBox.m @@ -38,6 +38,7 @@ static void unretain (gpointer data); if (self) { window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_object_ref_sink (window); gtk_window_set_title (GTK_WINDOW (window), "Toolbox"); gtk_window_set_role (GTK_WINDOW (window), "toolbox"); gtk_window_set_type_hint ( @@ -62,8 +63,6 @@ static void unretain (gpointer data); gtk_container_add (GTK_CONTAINER (toolPalette), GTK_WIDGET (toolGroup)); gtk_widget_show (GTK_WIDGET (toolGroup)); - id activeTool = [app activeTool]; - GSList *item_group = NULL; for (id tool in tools) { NSString *tooltip = [NSString stringWithFormat: @@ -86,12 +85,6 @@ static void unretain (gpointer data); [tool retain], unretain); - if (tool == activeTool) { - gtk_toggle_tool_button_set_active ( - GTK_TOGGLE_TOOL_BUTTON (item), - TRUE); - } - g_signal_connect (item, "toggled", G_CALLBACK (tool_button_toggled_cb), self); -- cgit v1.2.3