GNOME Bugzilla – Bug 651224
null pointer dereferenced due to multiple bugs in gtkclipboard-quartz.c
Last modified: 2013-09-28 17:59:36 UTC
gtk_clipboard_wait_for_contents() returns GtkSelectionData with display member set to 0; I've fixed copying and pasting of text by adding the following lines in gtk_clipboard_wait_for_contents(): selection_data = g_slice_new0 (GtkSelectionData); selection_data->selection = clipboard->selection; selection_data->target = target; //FIX: set display!!!!! selection_data->display=clipboard->display; and selection_data = _gtk_quartz_get_selection_data_from_pasteboard (clipboard->pasteboard, target, clipboard->selection); //FIX: set display!!!!! if(selection_data)selection_data->display=clipboard->display; and now I can copy&paste plain text. However, clipboard demo in gtk3-demos crashes with bus error when I try to drag-and-drop an image.
another bug in gtkdnd-quartz.c Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00000014 0x006c605a in gtk_style_context_save (context=0x14) at gtkstylecontext.c:1727 1727 g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); (gdb) p context $1 = (GtkStyleContext *) 0x14 (gdb) bt
+ Trace 227320
code in gtkdnd-quartz.c near line 352: GtkStyleContext *context; gtk_style_context_save (context);
The second issue, the crash, was fixed with 7cff8c44. What exactly is the problem with having the display set to zero with Quartz? Quartz doesn't support multiple displays. I'm able to use the clipboard without trouble.
quartz supports only one display, but gdk needs this display, not NULL if display is NULL, you will see critical warnings in log: "assertion GTK_IS_DISPLAY(display) failed", and you copy&paste will not work.
Well, yes, in theory. The catch is that selection_data.display isn't used anywhere in the quartz code. It is filled in in most instances (including gtk_quartz_get_selection_data_from_pasteboard(), so your second insertion isn't necessary), so I suppose for completeness we can add it to the TARGETS case as you've proposed.
Can this bug be closed?
Yes. I added setting the settings->display to the special case in gtk_selection_wait_for_display() in mater: 124e814