From 8215ba7a1d5c850e8e2382f56e8af8d6b32b2df9 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 15 Sep 2017 00:46:04 -0400 Subject: [PATCH] Crash Zotero on note-saving error Closes #1277, Crash note if not saving properly --- chrome/content/zotero/bindings/noteeditor.xml | 34 +++++++++++++------ chrome/content/zotero/itemPane.xul | 2 +- chrome/content/zotero/note.js | 11 ++++++ chrome/content/zotero/note.xul | 2 +- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/chrome/content/zotero/bindings/noteeditor.xml b/chrome/content/zotero/bindings/noteeditor.xml index b7c8ccc684..cae6638951 100644 --- a/chrome/content/zotero/bindings/noteeditor.xml +++ b/chrome/content/zotero/bindings/noteeditor.xml @@ -65,6 +65,11 @@ switch (val) { case 'view': case 'merge': + // If there's an existing editor, mark it as read-only. This allows for + // disabling an existing editable note (e.g., if there's a save error). + if (this.noteField) { + this.noteField.onInit(ed => ed.setMode('readonly')); + } break; case 'edit': @@ -243,9 +248,9 @@ - - - + this.item = item; + } + catch (e) { + Zotero.logError(e); + + if (this.hasAttribute('onerror')) { + let fn = new Function("", this.getAttribute('onerror')); + fn.call(this) + } + if (this.onError) { + this.onError(e); + } + } + }.bind(this)); + ]]> diff --git a/chrome/content/zotero/itemPane.xul b/chrome/content/zotero/itemPane.xul index 3609daa1b6..8f40a346bb 100644 --- a/chrome/content/zotero/itemPane.xul +++ b/chrome/content/zotero/itemPane.xul @@ -113,7 +113,7 @@ --> + onerror="ZoteroPane.displayErrorMessage(); this.mode = 'view'"/>