[gimp/gimp-2-6] 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/gimp-2-6] app: guard against crash due to quitting while DND is processed
- Date: Fri, 10 Jun 2011 19:30:00 +0000 (UTC)
commit eae4804e56dca692014d11dc1e0bf5053936e986
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)
(cherry picked from commit b1a2c736bf7e6c75ca1af4b4c3330172dddb269e)
Conflicts:
app/display/gimpdisplayshell-dnd.c
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 8d210a8..1e67fda 100644
--- a/app/display/gimpdisplayshell-dnd.c
+++ b/app/display/gimpdisplayshell-dnd.c
@@ -458,11 +458,21 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
gpointer data)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
- GimpImage *image = shell->display->image;
- 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 = shell->display->image;
+ context = gimp_get_user_context (shell->display->gimp);
+
GIMP_LOG (DND, NULL);
open_as_layers = (shell->display->image != NULL);
@@ -474,6 +484,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;
@@ -528,7 +544,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]