[gimp/gimp-2-10] Issue #1441 - Copy paste issue, internal clipboard blocks global clipboard
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] Issue #1441 - Copy paste issue, internal clipboard blocks global clipboard
- Date: Fri, 8 Jun 2018 09:43:14 +0000 (UTC)
commit 22ae38d024f703e9d5d4d11849ac556ba97cf40d
Author: Michael Natterer <mitch gimp org>
Date: Fri Jun 8 11:36:53 2018 +0200
Issue #1441 - Copy paste issue, internal clipboard blocks global clipboard
Never return an internal image/buffer/svg/curve from any
gimp_clipboard function if we are not the owner of the display's
clipboard. The clipboard is supposed to be a global thing, and we must
only offer to ourselves what would be pasted in any other app.
(cherry picked from commit 7d3a129dddfe986fa4efe59cd6c88c1855cc1441)
app/widgets/gimpclipboard.c | 182 ++++++++++++++++++++++++++------------------
1 file changed, 110 insertions(+), 72 deletions(-)
---
diff --git a/app/widgets/gimpclipboard.c b/app/widgets/gimpclipboard.c
index e56afc2a70..1a3123bf6f 100644
--- a/app/widgets/gimpclipboard.c
+++ b/app/widgets/gimpclipboard.c
@@ -244,11 +244,15 @@ gimp_clipboard_has_image (Gimp *gimp)
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
- if (clipboard &&
- gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp) &&
- gimp_clipboard_wait_for_image (gimp) != GDK_NONE)
+ if (clipboard &&
+ gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp))
{
- return TRUE;
+ if (gimp_clipboard_wait_for_image (gimp) != GDK_NONE)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
}
gimp_clip = gimp_clipboard_get (gimp);
@@ -279,11 +283,15 @@ gimp_clipboard_has_buffer (Gimp *gimp)
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
- if (clipboard &&
- gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp) &&
- gimp_clipboard_wait_for_buffer (gimp) != GDK_NONE)
+ if (clipboard &&
+ gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp))
{
- return TRUE;
+ if (gimp_clipboard_wait_for_buffer (gimp) != GDK_NONE)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
}
gimp_clip = gimp_clipboard_get (gimp);
@@ -312,11 +320,15 @@ gimp_clipboard_has_svg (Gimp *gimp)
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
- if (clipboard &&
- gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp) &&
- gimp_clipboard_wait_for_svg (gimp) != GDK_NONE)
+ if (clipboard &&
+ gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp))
{
- return TRUE;
+ if (gimp_clipboard_wait_for_svg (gimp) != GDK_NONE)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
}
gimp_clip = gimp_clipboard_get (gimp);
@@ -345,11 +357,15 @@ gimp_clipboard_has_curve (Gimp *gimp)
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
- if (clipboard &&
- gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp) &&
- gimp_clipboard_wait_for_curve (gimp) != GDK_NONE)
+ if (clipboard &&
+ gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp))
{
- return TRUE;
+ if (gimp_clipboard_wait_for_curve (gimp) != GDK_NONE)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
}
gimp_clip = gimp_clipboard_get (gimp);
@@ -402,7 +418,6 @@ gimp_clipboard_get_image (Gimp *gimp)
{
GimpClipboard *gimp_clip;
GtkClipboard *clipboard;
- GdkAtom atom;
GimpImage *image = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
@@ -410,24 +425,30 @@ gimp_clipboard_get_image (Gimp *gimp)
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
- if (clipboard &&
- gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp) &&
- (atom = gimp_clipboard_wait_for_image (gimp)) != GDK_NONE)
+ if (clipboard &&
+ gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp))
{
- GtkSelectionData *data;
+ GdkAtom atom = gimp_clipboard_wait_for_image (gimp);
+
+ if (atom != GDK_NONE)
+ {
+ GtkSelectionData *data;
- gimp_set_busy (gimp);
+ gimp_set_busy (gimp);
- data = gtk_clipboard_wait_for_contents (clipboard, atom);
+ data = gtk_clipboard_wait_for_contents (clipboard, atom);
- if (data)
- {
- image = gimp_selection_data_get_xcf (data, gimp);
+ if (data)
+ {
+ image = gimp_selection_data_get_xcf (data, gimp);
- gtk_selection_data_free (data);
+ gtk_selection_data_free (data);
+ }
+
+ gimp_unset_busy (gimp);
}
- gimp_unset_busy (gimp);
+ return image;
}
gimp_clip = gimp_clipboard_get (gimp);
@@ -456,7 +477,6 @@ gimp_clipboard_get_buffer (Gimp *gimp)
{
GimpClipboard *gimp_clip;
GtkClipboard *clipboard;
- GdkAtom atom;
GimpBuffer *buffer = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
@@ -464,31 +484,37 @@ gimp_clipboard_get_buffer (Gimp *gimp)
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
- if (clipboard &&
- gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp) &&
- (atom = gimp_clipboard_wait_for_buffer (gimp)) != GDK_NONE)
+ if (clipboard &&
+ gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp))
{
- GtkSelectionData *data;
+ GdkAtom atom = gimp_clipboard_wait_for_buffer (gimp);
- gimp_set_busy (gimp);
-
- data = gtk_clipboard_wait_for_contents (clipboard, atom);
-
- if (data)
+ if (atom != GDK_NONE)
{
- GdkPixbuf *pixbuf = gtk_selection_data_get_pixbuf (data);
+ GtkSelectionData *data;
- gtk_selection_data_free (data);
+ gimp_set_busy (gimp);
- if (pixbuf)
+ data = gtk_clipboard_wait_for_contents (clipboard, atom);
+
+ if (data)
{
- buffer = gimp_buffer_new_from_pixbuf (pixbuf, _("Clipboard"),
- 0, 0);
- g_object_unref (pixbuf);
+ GdkPixbuf *pixbuf = gtk_selection_data_get_pixbuf (data);
+
+ gtk_selection_data_free (data);
+
+ if (pixbuf)
+ {
+ buffer = gimp_buffer_new_from_pixbuf (pixbuf, _("Clipboard"),
+ 0, 0);
+ g_object_unref (pixbuf);
+ }
}
+
+ gimp_unset_busy (gimp);
}
- gimp_unset_busy (gimp);
+ return buffer;
}
gimp_clip = gimp_clipboard_get (gimp);
@@ -518,38 +544,45 @@ gimp_clipboard_get_svg (Gimp *gimp,
{
GimpClipboard *gimp_clip;
GtkClipboard *clipboard;
- GdkAtom atom;
gchar *svg = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (svg_length != NULL, NULL);
+ *svg_length = 0;
+
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
- if (clipboard &&
- gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp) &&
- (atom = gimp_clipboard_wait_for_svg (gimp)) != GDK_NONE)
+ if (clipboard &&
+ gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp))
{
- GtkSelectionData *data;
+ GdkAtom atom = gimp_clipboard_wait_for_svg (gimp);
- gimp_set_busy (gimp);
+ if (atom != GDK_NONE)
+ {
+ GtkSelectionData *data;
- data = gtk_clipboard_wait_for_contents (clipboard, atom);
+ gimp_set_busy (gimp);
- if (data)
- {
- const guchar *stream;
+ data = gtk_clipboard_wait_for_contents (clipboard, atom);
- stream = gimp_selection_data_get_stream (data, svg_length);
+ if (data)
+ {
+ const guchar *stream;
- if (stream)
- svg = g_memdup (stream, *svg_length);
+ stream = gimp_selection_data_get_stream (data, svg_length);
- gtk_selection_data_free (data);
+ if (stream)
+ svg = g_memdup (stream, *svg_length);
+
+ gtk_selection_data_free (data);
+ }
+
+ gimp_unset_busy (gimp);
}
- gimp_unset_busy (gimp);
+ return svg;
}
gimp_clip = gimp_clipboard_get (gimp);
@@ -580,7 +613,6 @@ gimp_clipboard_get_curve (Gimp *gimp)
{
GimpClipboard *gimp_clip;
GtkClipboard *clipboard;
- GdkAtom atom;
GimpCurve *curve = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
@@ -588,24 +620,30 @@ gimp_clipboard_get_curve (Gimp *gimp)
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
- if (clipboard &&
- gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp) &&
- (atom = gimp_clipboard_wait_for_curve (gimp)) != GDK_NONE)
+ if (clipboard &&
+ gtk_clipboard_get_owner (clipboard) != G_OBJECT (gimp))
{
- GtkSelectionData *data;
+ GdkAtom atom = gimp_clipboard_wait_for_curve (gimp);
- gimp_set_busy (gimp);
+ if (atom != GDK_NONE)
+ {
+ GtkSelectionData *data;
- data = gtk_clipboard_wait_for_contents (clipboard, atom);
+ gimp_set_busy (gimp);
- if (data)
- {
- curve = gimp_selection_data_get_curve (data);
+ data = gtk_clipboard_wait_for_contents (clipboard, atom);
- gtk_selection_data_free (data);
+ if (data)
+ {
+ curve = gimp_selection_data_get_curve (data);
+
+ gtk_selection_data_free (data);
+ }
+
+ gimp_unset_busy (gimp);
}
- gimp_unset_busy (gimp);
+ return curve;
}
gimp_clip = gimp_clipboard_get (gimp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]