Bug 463784 - Copy and multiple paste is broken, fails with DUPLICATE_ID error (regression). r=dbo
authorMartin Schroeder <mschroeder@mozilla.x-home.org>
Fri, 14 Nov 2008 15:05:50 +0100
changeset 1107 9413bd7950162a781c8d8c0f2a4df13216752505
parent 1106 c835317a8ff771a89d20fe1248463261e76c5f09
child 1108 ebcb28433bfeff0f3dd9dc84bef905ac42ef1da6
push id839
push usermschroeder@mozilla.x-home.org
push dateFri, 14 Nov 2008 14:05:55 +0000
treeherdercomm-central@9413bd795016 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbo
bugs463784
Bug 463784 - Copy and multiple paste is broken, fails with DUPLICATE_ID error (regression). r=dbo
calendar/base/content/calendar-clipboard.js
--- a/calendar/base/content/calendar-clipboard.js
+++ b/calendar/base/content/calendar-clipboard.js
@@ -85,21 +85,17 @@ function copyToClipboard(calendarItemArr
     if (!calendarItemArray.length) {
         return false;
     }
 
     let calComp = cal.getIcsService().createIcalComponent("VCALENDAR");
     cal.calSetProdidVersion(calComp);
 
     for each (let item in calendarItemArray) {
-        // If we copy an item and paste it again, it will have the same ID as
-        // the original. Therefore, give every item a new ID.
-        let newItem = item.clone();
-        newItem.id = cal.getUUID();
-        calComp.addSubcomponent(newItem.icalComponent);
+        calComp.addSubcomponent(item.icalComponent);
     }
 
     // XXX This might not be enough to be Outlook compatible
     let sTextiCalendar = calComp.serializeToICS();
 
     let clipboard = getClipboard();
     let trans = Components.classes["@mozilla.org/widget/transferable;1"]
                           .createInstance(Components.interfaces.nsITransferable);
@@ -221,16 +217,19 @@ function pasteFromClipboard() {
             earliestDate.isDate = true;
             let offset = firstDate.subtractDate(earliestDate);
             let deltaDST = firstDate.timezoneOffset - earliestDate.timezoneOffset;
             offset.inSeconds += deltaDST;
 
             startBatchTransaction();
             for each (let item in items) {
                 let newItem = item.clone();
+                // Set new UID to allow multiple paste actions of the same
+                // clipboard content.
+                newItem.id = cal.getUUID();
                 if (item.startDate) {
                     newItem.startDate.addDuration(offset);
                     newItem.endDate.addDuration(offset);
                 } else {
                     if (item.entryDate) {
                         newItem.entryDate.addDuration(offset);
                     }
                     if (item.dueDate) {