bug 546387 - Don't try to set the GTK clipboard with null items r=karlt draft
authorChris H-C <chutten@mozilla.com>
Fri, 26 May 2017 11:50:13 -0400
changeset 589624 52bdb98c98e5d2b5b07d54e998b6c19dbd3f860e
parent 589544 4dd1d17ba22660b8f5869a707f2e4e9f9dd5be5b
child 631961 6e02824cae47d42436797f4ec88fa935c53bde0a
push id62458
push userbmo:chutten@mozilla.com
push dateTue, 06 Jun 2017 15:28:35 +0000
reviewerskarlt
bugs546387
milestone55.0a1
bug 546387 - Don't try to set the GTK clipboard with null items r=karlt It causes an assert failure in gtk which prints to the console. MozReview-Commit-ID: A4106Z4rT36
widget/gtk/nsClipboard.cpp
--- a/widget/gtk/nsClipboard.cpp
+++ b/widget/gtk/nsClipboard.cpp
@@ -241,17 +241,18 @@ nsClipboard::SetData(nsITransferable *aT
     
     // Get GTK clipboard (CLIPBOARD or PRIMARY)
     GtkClipboard *gtkClipboard = gtk_clipboard_get(GetSelectionAtom(aWhichClipboard));
   
     gint numTargets;
     GtkTargetEntry *gtkTargets = gtk_target_table_new_from_list(list, &numTargets);
           
     // Set getcallback and request to store data after an application exit
-    if (gtk_clipboard_set_with_data(gtkClipboard, gtkTargets, numTargets, 
+    if (gtkTargets &&
+        gtk_clipboard_set_with_data(gtkClipboard, gtkTargets, numTargets,
                                     clipboard_get_cb, clipboard_clear_cb, this))
     {
         // We managed to set-up the clipboard so update internal state
         // We have to set it now because gtk_clipboard_set_with_data() calls clipboard_clear_cb()
         // which reset our internal state 
         if (aWhichClipboard == kSelectionClipboard) {
             mSelectionOwner = aOwner;
             mSelectionTransferable = aTransferable;