[gimp] app: guard against crash due to quitting while DND is processed
- From: Nils Philippsen <nphilipp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: guard against crash due to quitting while DND is processed
- Date: Fri, 10 Jun 2011 16:12:45 +0000 (UTC)
commit b1a2c736bf7e6c75ca1af4b4c3330172dddb269e
Author: Nils Philippsen <nils redhat com>
Date: Fri Jun 10 18:06:02 2011 +0200
app: guard against crash due to quitting while DND is processed
In gimp_display_shell_drop_uri_list(), shell->display is dereferenced in
some places without checking that it's still there. It can be set to
NULL if the user quits the application while a drag and drop action is
being processed and the main loop is iterated during execution of this
function. (Bug #652280)
app/display/gimpdisplayshell-dnd.c | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-dnd.c b/app/display/gimpdisplayshell-dnd.c
index 26cc906..f8e8898 100644
--- a/app/display/gimpdisplayshell-dnd.c
+++ b/app/display/gimpdisplayshell-dnd.c
@@ -479,11 +479,21 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
gpointer data)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
- GimpImage *image = gimp_display_get_image (shell->display);
- GimpContext *context = gimp_get_user_context (shell->display->gimp);
+ GimpImage *image;
+ GimpContext *context;
GList *list;
gboolean open_as_layers;
+ /* If the app is already being torn down, shell->display might be NULL here.
+ * Play it safe. */
+ if (! shell->display)
+ {
+ return;
+ }
+
+ image = gimp_display_get_image (shell->display);
+ context = gimp_get_user_context (shell->display->gimp);
+
GIMP_LOG (DND, NULL);
open_as_layers = (image != NULL);
@@ -495,6 +505,12 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
GError *error = NULL;
gboolean warn = FALSE;
+ if (! shell->display)
+ {
+ /* It seems as if GIMP is being torn down for quitting. Bail out. */
+ return;
+ }
+
if (open_as_layers)
{
GList *new_layers;
@@ -550,7 +566,10 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
warn = TRUE;
}
- if (warn)
+ /* Something above might have run a few rounds of the main loop. Check
+ * that shell->display is still there, otherwise ignore this as the app
+ * is being torn down for quitting. */
+ if (warn && shell->display)
{
gchar *filename = file_utils_uri_display_name (uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]