[gimp] app: g_return_if_fail (shell_selection) on the public API in gimpdisplayshell-selection.c, move free



commit cfd360aa03214c9329e67d78c7a6d949efab88c0
Author: Mikael Magnusson <mikachu src gnome org>
Date:   Sun Jun 16 20:14:35 2013 +0200

    app: g_return_if_fail (shell_selection) on the public API in gimpdisplayshell-selection.c, move free null 
check to gimpdisplayshell's dispose()

 app/display/gimpdisplayshell-selection.c |   41 ++++++++++++++++--------------
 app/display/gimpdisplayshell.c           |    3 +-
 app/widgets/gimpdockbook.c               |    2 +-
 3 files changed, 25 insertions(+), 21 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-selection.c b/app/display/gimpdisplayshell-selection.c
index 0181efd..7362177 100644
--- a/app/display/gimpdisplayshell-selection.c
+++ b/app/display/gimpdisplayshell-selection.c
@@ -116,34 +116,33 @@ void
 gimp_display_shell_selection_free (GimpDisplayShell *shell)
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+  g_return_if_fail (shell->selection != NULL);
 
-  if (shell->selection)
-    {
-      Selection *selection = shell->selection;
+  Selection *selection = shell->selection;
 
-      selection_stop (selection);
+  selection_stop (selection);
 
-      g_signal_handlers_disconnect_by_func (shell,
-                                            selection_window_state_event,
-                                            selection);
-      g_signal_handlers_disconnect_by_func (shell,
-                                            selection_visibility_notify_event,
-                                            selection);
+  g_signal_handlers_disconnect_by_func (shell,
+                                        selection_window_state_event,
+                                        selection);
+  g_signal_handlers_disconnect_by_func (shell,
+                                        selection_visibility_notify_event,
+                                        selection);
 
-      selection_free_segs (selection);
+  selection_free_segs (selection);
 
-      g_slice_free (Selection, selection);
+  g_slice_free (Selection, selection);
 
-      shell->selection = NULL;
-    }
+  shell->selection = NULL;
 }
 
 void
 gimp_display_shell_selection_undraw (GimpDisplayShell *shell)
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+  g_return_if_fail (shell->selection != NULL);
 
-  if (shell->selection && gimp_display_get_image (shell->display))
+  if (gimp_display_get_image (shell->display))
     {
       selection_undraw (shell->selection);
     }
@@ -158,8 +157,9 @@ void
 gimp_display_shell_selection_restart (GimpDisplayShell *shell)
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+  g_return_if_fail (shell->selection != NULL);
 
-  if (shell->selection && gimp_display_get_image (shell->display))
+  if (gimp_display_get_image (shell->display))
     {
       selection_start (shell->selection);
     }
@@ -169,8 +169,9 @@ void
 gimp_display_shell_selection_pause (GimpDisplayShell *shell)
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+  g_return_if_fail (shell->selection != NULL);
 
-  if (shell->selection && gimp_display_get_image (shell->display))
+  if (gimp_display_get_image (shell->display))
     {
       if (shell->selection->paused == 0)
         selection_stop (shell->selection);
@@ -183,8 +184,9 @@ void
 gimp_display_shell_selection_resume (GimpDisplayShell *shell)
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+  g_return_if_fail (shell->selection != NULL);
 
-  if (shell->selection && gimp_display_get_image (shell->display))
+  if (gimp_display_get_image (shell->display))
     {
       shell->selection->paused--;
 
@@ -198,8 +200,9 @@ gimp_display_shell_selection_set_show (GimpDisplayShell *shell,
                                        gboolean          show)
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+  g_return_if_fail (shell->selection != NULL);
 
-  if (shell->selection && gimp_display_get_image (shell->display))
+  if (gimp_display_get_image (shell->display))
     {
       Selection *selection = shell->selection;
 
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index c0e1915..a881e53 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -773,7 +773,8 @@ gimp_display_shell_dispose (GObject *object)
 
   shell->popup_manager = NULL;
 
-  gimp_display_shell_selection_free (shell);
+  if (shell->selection)
+    gimp_display_shell_selection_free (shell);
 
   if (shell->filter_stack)
     gimp_display_shell_filter_set (shell, NULL);
diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c
index 795c5ca..f735edd 100644
--- a/app/widgets/gimpdockbook.c
+++ b/app/widgets/gimpdockbook.c
@@ -1312,7 +1312,7 @@ gimp_dockbook_recreate_tab_widgets (GimpDockbook *dockbook,
       GtkWidget *tab_widget;
 
       if (only_auto &&
-          gimp_dockable_get_tab_style (dockable) != GIMP_TAB_STYLE_AUTOMATIC)
+          ! (gimp_dockable_get_tab_style (dockable) == GIMP_TAB_STYLE_AUTOMATIC))
         continue;
 
       tab_widget = gimp_dockbook_create_tab_widget (dockbook, dockable);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]