Bug 2698 - [GTK] Clipboard gets cleared after closing Monodevelop
Summary: [GTK] Clipboard gets cleared after closing Monodevelop
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: unspecified
Hardware: Macintosh Mac OS
: High normal
Target Milestone: ---
Assignee: Mikayla Hutchinson [MSFT]
Depends on:
Reported: 2011-12-30 07:05 UTC by Henning
Modified: 2012-05-14 19:37 UTC (History)
4 users (show)

Tags: gtk
Is this bug a regression?: ---
Last known good build:

proposed patch which implements _gtk_clipboard_store_all (2.91 KB, patch)
2012-04-22 06:20 UTC, Kristian Rietveld (inactive)
Eliminate the gdk warning for compound text selections (1.05 KB, patch)
2012-05-14 15:36 UTC, Christian Kellner

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Henning 2011-12-30 07:05:56 UTC
Copy Code to clipboard then close MonoDevelop.

Open Monodevlop and try to paste the code, its gone.
Comment 1 Mikayla Hutchinson [MSFT] 2012-04-04 19:56:25 UTC
I can reproduce this.
Comment 2 Kristian Rietveld (inactive) 2012-04-11 15:44:54 UTC
Can reproduce this in testtext too, so it is definitely a gtk+ bug.

1. start testtext
2. enter text
3. copy text
4. quit
5. start again
6. paste -- will not work


1. start testtext
2. enter text
3. copy text
4. paste text
5. quit
6. start again
7. paste -- this will work fine

The problem is that if no paste happens before the application is quit, pasteboard:provideDataForType is never called.  According to the documentation for this method, these messages may also be sent when the application is shut down, with as goal to preserve the data on the clipboard when the application is quit.

This is usually done through the terminate: method when the Quit command has been invoked. For GTK+, we need to find a good place to perform this.  It turns out that _gtk_clipboard_store_all() is exactly this place, which is called from the end of gtk_main().  So implementing _gtk_clipboard_store_all() for Quartz should fix this bug.
Comment 3 Kristian Rietveld (inactive) 2012-04-22 06:20:34 UTC
Created attachment 1722 [details]
proposed patch which implements _gtk_clipboard_store_all

This patch makes things work for me using gtk-demo.  testtext is not a good example, because that code clears the clipboard before the main loop is quit (in theory, this should not even retain the clipboard on X11).

With gtk-demo, I can now select text, copy it, quit gtk-demo and still paste it in TextEdit.

Some more testing would be nice. If the patch works fine, we will upstream it.
Comment 4 Miguel de Icaza [MSFT] 2012-04-24 12:30:48 UTC
Setting the priority to high, because we got a patch that we should try out.
Comment 5 Mikayla Hutchinson [MSFT] 2012-04-30 01:01:27 UTC
It works fine, but I do get a GDK warning when quitting MD, if I copied from a GTK textview:
WARNING [2012-04-30 00:59:23Z]: Gtk-Warning: selection_set_compound_text is not implemented
Comment 6 Mikayla Hutchinson [MSFT] 2012-04-30 01:08:05 UTC
I integrated the patch into our patchset anyway, since I think the warning is harmless. But it's probably pointless - does anything use compound clipboard text on MacOS?
Comment 7 Kristian Rietveld (inactive) 2012-04-30 05:39:51 UTC
It is harmless, the warning also occurs when you attempt to obtain the compound text selection using the "Clipboard Viewer" utility.  So in fact it is a separate issue.

I have thought about removing compound text, etc., since these are not used by OS X applications.  However, they can be used between separate GTK+ applications running on OS X if I am not mistaken.
Comment 8 Mikayla Hutchinson [MSFT] 2012-04-30 10:17:06 UTC
Hmm, I'd rather patch it out TBH. That's such a tiny edge case, copying content for which "compound" is the best format between GTK+ apps on MacOS, and people tend to get scared by Gdk warnings when reading logs.
Comment 9 Kristian Rietveld (inactive) 2012-04-30 11:21:33 UTC
I agree.  I will look into patching this out and upstream it.
Comment 10 Christian Kellner 2012-05-14 15:36:47 UTC
Created attachment 1882 [details]
Eliminate the gdk warning for compound text selections

Patching it out was quite simple. Simple one-liner patch is attached.
Comment 11 Christian Kellner 2012-05-14 16:38:00 UTC
On Kris' request, I have pushed both patches to gtk-2-24.
Comment 12 Mikayla Hutchinson [MSFT] 2012-05-14 19:37:58 UTC
Thanks, I've synced the patches into our bockbuild build system. They'll be picked up for our next Mono release.