Crash Zotero on note-saving error
Closes #1277, Crash note if not saving properly
This commit is contained in:
parent
18c62be6a4
commit
8215ba7a1d
4 changed files with 36 additions and 13 deletions
|
@ -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 @@
|
|||
</method>
|
||||
|
||||
<method name="save">
|
||||
<body>
|
||||
<![CDATA[
|
||||
return Zotero.spawn(function* () {
|
||||
<body><![CDATA[
|
||||
return Zotero.spawn(function* () {
|
||||
try {
|
||||
if (this._mode == 'view') {
|
||||
Zotero.debug("Not saving read-only note");
|
||||
return;
|
||||
|
@ -262,10 +267,6 @@
|
|||
if (this.item) {
|
||||
// If note field doesn't match item, abort save and run error handler
|
||||
if (noteField.getAttribute('itemID') != this.item.id) {
|
||||
if (this.hasAttribute('onerror')) {
|
||||
let fn = new Function("", this.getAttribute('onerror'));
|
||||
fn.call(this)
|
||||
}
|
||||
throw new Error("Note field doesn't match current item");
|
||||
}
|
||||
|
||||
|
@ -298,10 +299,21 @@
|
|||
}
|
||||
}
|
||||
|
||||
this.item = yield Zotero.Items.getAsync(id);
|
||||
}.bind(this));
|
||||
]]>
|
||||
</body>
|
||||
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));
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- Used to insert a tab manually -->
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
-->
|
||||
<zoteronoteeditor id="zotero-note-editor" flex="1" notitle="1"
|
||||
previousfocus="zotero-items-tree"
|
||||
onerror="ZoteroPane.displayErrorMessage()"/>
|
||||
onerror="ZoteroPane.displayErrorMessage(); this.mode = 'view'"/>
|
||||
<button id="zotero-view-note-button" label="&zotero.notes.separate;" oncommand="ZoteroPane_Local.openNoteWindow(this.getAttribute('noteID')); if(this.hasAttribute('sourceID')) ZoteroPane_Local.selectItem(this.getAttribute('sourceID'));"/>
|
||||
</groupbox>
|
||||
|
||||
|
|
|
@ -75,6 +75,17 @@ function onLoad() {
|
|||
});
|
||||
}
|
||||
|
||||
// If there's an error saving a note, close the window and crash the app
|
||||
function onError() {
|
||||
try {
|
||||
window.opener.ZoteroPane.displayErrorMessage();
|
||||
}
|
||||
catch (e) {
|
||||
Zotero.logError(e);
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
|
||||
function onUnload()
|
||||
{
|
||||
if(noteEditor && noteEditor.value)
|
||||
|
|
|
@ -23,5 +23,5 @@
|
|||
</keyset>
|
||||
<command id="cmd_close" oncommand="window.close();"/>
|
||||
|
||||
<zoteronoteeditor id="zotero-note-editor" flex="1"/>
|
||||
<zoteronoteeditor id="zotero-note-editor" flex="1" onerror="onError()"/>
|
||||
</window>
|
Loading…
Add table
Reference in a new issue