mirror of https://github.com/GNOME/gimp.git
app: Handle gimp_image_window_get_active_shell() returning NULL
When rearranging the UI it is pretty common that gimp_image_window_get_active_shell() returns NULL so check for that.
This commit is contained in:
parent
fc3c368f96
commit
75ee76ecb6
|
@ -273,7 +273,10 @@ action_data_get_gimp (gpointer data)
|
|||
if (GIMP_IS_DISPLAY (data))
|
||||
return ((GimpDisplay *) data)->gimp;
|
||||
else if (GIMP_IS_IMAGE_WINDOW (data))
|
||||
return gimp_image_window_get_active_shell (data)->display->gimp;
|
||||
{
|
||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (data);
|
||||
return shell ? shell->display->gimp : NULL;
|
||||
}
|
||||
else if (GIMP_IS_GIMP (data))
|
||||
return data;
|
||||
else if (GIMP_IS_DOCK (data))
|
||||
|
@ -307,7 +310,10 @@ action_data_get_context (gpointer data)
|
|||
if (GIMP_IS_DISPLAY (data))
|
||||
return gimp_get_user_context (((GimpDisplay *) data)->gimp);
|
||||
else if (GIMP_IS_IMAGE_WINDOW (data))
|
||||
return gimp_get_user_context (gimp_image_window_get_active_shell (data)->display->gimp);
|
||||
{
|
||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (data);
|
||||
return shell ? gimp_get_user_context (shell->display->gimp) : NULL;
|
||||
}
|
||||
else if (GIMP_IS_GIMP (data))
|
||||
return gimp_get_user_context (data);
|
||||
else if (GIMP_IS_DOCK (data))
|
||||
|
@ -341,7 +347,10 @@ action_data_get_image (gpointer data)
|
|||
if (GIMP_IS_DISPLAY (data))
|
||||
display = (GimpDisplay *) data;
|
||||
else if (GIMP_IS_IMAGE_WINDOW (data))
|
||||
display = gimp_image_window_get_active_shell (data)->display;
|
||||
{
|
||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (data);
|
||||
display = shell ? shell->display : NULL;
|
||||
}
|
||||
else if (GIMP_IS_GIMP (data))
|
||||
context = gimp_get_user_context (data);
|
||||
else if (GIMP_IS_DOCK (data))
|
||||
|
@ -377,7 +386,10 @@ action_data_get_display (gpointer data)
|
|||
if (GIMP_IS_DISPLAY (data))
|
||||
return data;
|
||||
else if (GIMP_IS_IMAGE_WINDOW (data))
|
||||
return gimp_image_window_get_active_shell (data)->display;
|
||||
{
|
||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (data);
|
||||
return shell ? shell->display : NULL;
|
||||
}
|
||||
else if (GIMP_IS_GIMP (data))
|
||||
context = gimp_get_user_context (data);
|
||||
else if (GIMP_IS_DOCK (data))
|
||||
|
|
|
@ -411,7 +411,8 @@ gimp_image_window_delete_event (GtkWidget *widget,
|
|||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
||||
|
||||
/* FIXME multiple shells */
|
||||
gimp_display_shell_close (shell, FALSE);
|
||||
if (shell)
|
||||
gimp_display_shell_close (shell, FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -444,7 +445,7 @@ gimp_image_window_configure_event (GtkWidget *widget,
|
|||
/* FIXME multiple shells */
|
||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
||||
|
||||
if (gimp_display_get_image (shell->display))
|
||||
if (shell && gimp_display_get_image (shell->display))
|
||||
shell->size_allocate_from_configure_event = TRUE;
|
||||
}
|
||||
|
||||
|
@ -459,6 +460,9 @@ gimp_image_window_window_state_event (GtkWidget *widget,
|
|||
GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
|
||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
||||
|
||||
if (! shell)
|
||||
return FALSE;
|
||||
|
||||
private->window_state = event->new_window_state;
|
||||
|
||||
if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
|
||||
|
@ -517,16 +521,21 @@ static void
|
|||
gimp_image_window_style_set (GtkWidget *widget,
|
||||
GtkStyle *prev_style)
|
||||
{
|
||||
GimpImageWindow *window = GIMP_IMAGE_WINDOW (widget);
|
||||
GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
|
||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
||||
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
||||
GtkRequisition requisition;
|
||||
GdkGeometry geometry;
|
||||
GdkWindowHints geometry_mask;
|
||||
GimpImageWindow *window = GIMP_IMAGE_WINDOW (widget);
|
||||
GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
|
||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
||||
GimpStatusbar *statusbar = NULL;
|
||||
GtkRequisition requisition = { 0, };
|
||||
GdkGeometry geometry = { 0, };
|
||||
GdkWindowHints geometry_mask = 0;
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
|
||||
|
||||
if (! shell)
|
||||
return;
|
||||
|
||||
statusbar = gimp_display_shell_get_statusbar (shell);
|
||||
|
||||
gtk_widget_size_request (GTK_WIDGET (statusbar), &requisition);
|
||||
|
||||
geometry.min_height = 23;
|
||||
|
@ -824,6 +833,9 @@ gimp_image_window_shrink_wrap (GimpImageWindow *window,
|
|||
|
||||
active_shell = gimp_image_window_get_active_shell (window);
|
||||
|
||||
if (!active_shell)
|
||||
return;
|
||||
|
||||
image = gimp_display_get_image (active_shell->display);
|
||||
|
||||
widget = GTK_WIDGET (window);
|
||||
|
@ -951,7 +963,12 @@ gimp_image_window_show_tooltip (GimpUIManager *manager,
|
|||
GimpImageWindow *window)
|
||||
{
|
||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
||||
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
||||
GimpStatusbar *statusbar = NULL;
|
||||
|
||||
if (! shell)
|
||||
return;
|
||||
|
||||
statusbar = gimp_display_shell_get_statusbar (shell);
|
||||
|
||||
gimp_statusbar_push (statusbar, "menu-tooltip",
|
||||
NULL, "%s", tooltip);
|
||||
|
@ -962,7 +979,12 @@ gimp_image_window_hide_tooltip (GimpUIManager *manager,
|
|||
GimpImageWindow *window)
|
||||
{
|
||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
||||
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
||||
GimpStatusbar *statusbar = NULL;
|
||||
|
||||
if (! shell)
|
||||
return;
|
||||
|
||||
statusbar = gimp_display_shell_get_statusbar (shell);
|
||||
|
||||
gimp_statusbar_pop (statusbar, "menu-tooltip");
|
||||
}
|
||||
|
@ -974,6 +996,9 @@ gimp_image_window_shell_events (GtkWidget *widget,
|
|||
{
|
||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
||||
|
||||
if (! shell)
|
||||
return FALSE;
|
||||
|
||||
return gimp_display_shell_events (widget, event, shell);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue