Bug 794212 - Fix "Assertion failure: mInitialized, nsTransferable.cpp" when starting drag and drop in calendar view r=philipp a=philipp
authorStefan Sitter <ssitter@gmail.com>
Thu, 11 Oct 2012 22:51:40 +0200
changeset 13475 2fe681068001e1589ae22daed2123c2aa15614ab
parent 13472 ffe3ddad9bb8e2bf1b10677b65f1e35d85b02b2f
child 13476 fa8ba4cecc9301f85b346a74c9c8e87965509103
push id708
push userssitter@gmail.com
push dateThu, 11 Oct 2012 20:52:03 +0000
treeherdercomm-beta@2fe681068001 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp, philipp
bugs794212
Bug 794212 - Fix "Assertion failure: mInitialized, nsTransferable.cpp" when starting drag and drop in calendar view r=philipp a=philipp
calendar/base/content/calendar-clipboard.js
calendar/base/content/calendar-dnd-listener.js
calendar/base/content/widgets/calendar-widgets.xml
--- a/calendar/base/content/calendar-clipboard.js
+++ b/calendar/base/content/calendar-clipboard.js
@@ -68,16 +68,17 @@ function copyToClipboard(calendarItemArr
     let icsString = icsSerializer.serializeToString();
 
     let clipboard = getClipboard();
     let trans = Components.classes["@mozilla.org/widget/transferable;1"]
                           .createInstance(Components.interfaces.nsITransferable);
 
     if (trans && clipboard) {
         // Register supported data flavors
+        trans.init(null);
         trans.addDataFlavor("text/calendar");
         trans.addDataFlavor("text/unicode");
 
         // Create the data objects
         let icsWrapper = Components.classes["@mozilla.org/supports-string;1"]
                                    .createInstance(Components.interfaces.nsISupportsString);
         icsWrapper.data = icsString;
 
@@ -113,16 +114,17 @@ function pasteFromClipboard() {
     let trans = Components.classes["@mozilla.org/widget/transferable;1"]
                           .createInstance(Components.interfaces.nsITransferable);
 
     if (!trans || !clipboard) {
         return;
     }
 
     // Register the wanted data flavors (highest fidelity first!)
+    trans.init(null);
     trans.addDataFlavor("text/calendar");
     trans.addDataFlavor("text/unicode");
 
     // Get transferable from clipboard
     clipboard.getData(trans, Components.interfaces.nsIClipboard.kGlobalClipboard);
 
     // Ask transferable for the best flavor.
     let flavor = {};
--- a/calendar/base/content/calendar-dnd-listener.js
+++ b/calendar/base/content/calendar-dnd-listener.js
@@ -198,16 +198,17 @@ calDNDBaseObserver.prototype = {
 
     /**
      * Action to take when dropping the event.
      */
 
     onDrop: function calDNDDrop(aEvent, aTransferData, aDragSession) {
         var transferable = Components.classes["@mozilla.org/widget/transferable;1"]
                            .createInstance(Components.interfaces.nsITransferable);
+        transferable.init(null);
         transferable.addDataFlavor("text/calendar");
         transferable.addDataFlavor("text/x-moz-url");
         transferable.addDataFlavor("text/x-moz-message");
         transferable.addDataFlavor("text/unicode");
         transferable.addDataFlavor("application/x-moz-file");
 
         aDragSession.getData(transferable, 0);
 
@@ -543,16 +544,17 @@ calTaskButtonDNDObserver.prototype = {
  * source.
  *
  * @param aItem     The item to drag.
  * @param aXULBox   The XUL box to invoke the drag session from.
  */
 function invokeEventDragSession(aItem, aXULBox) {
     let transfer = Components.classes["@mozilla.org/widget/transferable;1"]
                    .createInstance(Components.interfaces.nsITransferable);
+    transfer.init(null);
     transfer.addDataFlavor("text/calendar");
 
     let flavourProvider = {
         QueryInterface: function(aIID) {
             return doQueryInterface(aXULBox, null, aIID, [Components.interfaces.nsIFlavorDataProvider]);
         },
         item: aItem,
 
--- a/calendar/base/content/widgets/calendar-widgets.xml
+++ b/calendar/base/content/widgets/calendar-widgets.xml
@@ -476,16 +476,17 @@
             // No source node? Not our drag.
             return;
          }
          let item = session.sourceNode.sourceObject.clone();
          this.setAttribute("dropbox", "false");
          let transfer = Components.classes["@mozilla.org/widget/transferable;1"].
                         createInstance(Components.interfaces.nsITransferable);
 
+         transfer.init(null);
          if (isEvent(item)) {
              transfer.addDataFlavor("application/x-moz-cal-event");
          } else {
              transfer.addDataFlavor("application/x-moz-cal-task");
          }
 
          session.getData(transfer, 0);
          let flavor = {};