From 0c3ba3360de89c60712c45267151e3ed0ea6d0ed Mon Sep 17 00:00:00 2001 From: Morten Welinder Date: Mon, 16 Apr 2018 09:05:04 -0400 Subject: [PATCH] Foreign paste: avoid critials. --- ChangeLog | 8 ++++++++ src/gui-clipboard.c | 18 ++++++++++++++++-- src/workbook-view.c | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb54e2ae0..891122c70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2018-04-16 Morten Welinder + + * src/gui-clipboard.c (gnm_x_claim_clipboard): Plug leak. Debug + improvements. + + * src/workbook-view.c (get_uri_modtime): Fix criticals on paste + from LibreOffice. (Which sends a zipfile over the clipboard.) + 2018-04-14 Morten Welinder * src/func.c (gnm_func_count_args): Rename from diff --git a/src/gui-clipboard.c b/src/gui-clipboard.c index 372266cf7..db9fd4e3f 100644 --- a/src/gui-clipboard.c +++ b/src/gui-clipboard.c @@ -1080,6 +1080,7 @@ gnm_x_claim_clipboard (GdkDisplay *display) GnmCellRegion *content = gnm_app_clipboard_contents_get (); SheetObject *imageable = NULL, *exportable = NULL; GtkTargetEntry *targets = NULL; + gboolean free_targets = FALSE; int n_targets; gboolean ret; GObject *app = gnm_app_get_app (); @@ -1115,14 +1116,18 @@ gnm_x_claim_clipboard (GdkDisplay *display) gtk_target_list_add_table (tl, table_targets, 1); targets = gtk_target_table_new_from_list (tl, &n_targets); gtk_target_list_unref (tl); + free_targets = TRUE; } if (imageable) { GtkTargetList *tl = sheet_object_get_target_list (imageable); /* _add_table prepends to target_list */ gtk_target_list_add_table (tl, targets, (exportable)? n_targets: 1); + if (free_targets) + gtk_target_table_free (targets, n_targets); targets = gtk_target_table_new_from_list (tl, &n_targets); gtk_target_list_unref (tl); + free_targets = TRUE; } /* Register a x_clipboard_clear_cb only for CLIPBOARD, not for * PRIMARY */ @@ -1133,8 +1138,17 @@ gnm_x_claim_clipboard (GdkDisplay *display) (GtkClipboardClearFunc) x_clipboard_clear_cb, app); if (ret) { - if (debug_clipboard ()) + if (debug_clipboard ()) { + int i; g_printerr ("Clipboard successfully claimed.\n"); + g_printerr ("Clipboard targets offered: "); + for (i = 0; i < n_targets; i++) { + g_printerr ("%s%s", + (i ? ", " : ""), + targets[i].target); + } + g_printerr ("\n"); + } g_object_set_data_full (app, APP_CLIP_DISP_KEY, g_slist_prepend (g_object_steal_data (app, APP_CLIP_DISP_KEY), @@ -1154,7 +1168,7 @@ gnm_x_claim_clipboard (GdkDisplay *display) if (debug_clipboard ()) g_printerr ("Failed to claim clipboard.\n"); } - if (exportable || imageable) + if (free_targets) gtk_target_table_free (targets, n_targets); return ret; diff --git a/src/workbook-view.c b/src/workbook-view.c index 93adb0b83..4fa2ba7d2 100644 --- a/src/workbook-view.c +++ b/src/workbook-view.c @@ -1161,7 +1161,7 @@ get_uri_modtime (GsfInput *input, const char *uri) g_date_time_ref (modtime); } - if (!modtime) + if (!modtime && uri) modtime = go_file_get_modtime (uri); if (gnm_debug_flag ("modtime")) { -- 2.11.4.GIT