Prevent paste from empty clipboard throwing an error
authorPasi Kallinen <pasi.kallinen@pttk.fi>
Tue, 23 Jul 2013 07:49:47 +0000 (10:49 +0300)
committerBen Shum <bshum@biblio.org>
Tue, 6 Aug 2013 16:42:31 +0000 (12:42 -0400)
Signed-off-by: Pasi Kallinen <pasi.kallinen@pttk.fi>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/xul/staff_client/chrome/content/util/clipboard.js

index 75d225a..d180611 100644 (file)
@@ -57,7 +57,9 @@ util.clipboard.paste = function() {
         trans.addDataFlavor("text/unicode"); 
         cb.getData(trans, cb.kGlobalClipboard);
         var str = {}; var strLength = {};
-        trans.getTransferData("text/unicode",str,strLength);
+        try {
+            trans.getTransferData("text/unicode",str,strLength);
+        } catch(e) { /* clipboard is empty */ return; }
         if (str) str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
         var clip; if (str) clip = str.data.substring(0, strLength.value / 2);
         n.value = v.substring(0, start) + clip + v.substring(end, v.length);