From 4fb9c2877f8ac27ffbfba46556b4285e8ef80146 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 19 Oct 2011 22:27:17 +0000 Subject: [PATCH] Fix error when changing item types --- chrome/content/zotero/xpcom/data/item.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 5dc2efb48..db02ae09b 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -425,12 +425,6 @@ Zotero.Item.prototype.setType = function(itemTypeID, loadIn) { if (loadIn) { throw ('Cannot change type in loadIn mode in Zotero.Item.setType()'); } - } - - this._itemTypeID = itemTypeID; - - // If there's an existing type - if (oldItemTypeID) { if (!this._itemDataLoaded && this.id) { this._loadItemData(); } @@ -460,7 +454,7 @@ Zotero.Item.prototype.setType = function(itemTypeID, loadIn) { for each(var oldFieldID in obsoleteFields) { // Try to get a base type for this field var baseFieldID = - Zotero.ItemFields.getBaseIDFromTypeAndField(this.itemTypeID, oldFieldID); + Zotero.ItemFields.getBaseIDFromTypeAndField(oldItemTypeID, oldFieldID); if (baseFieldID) { var newFieldID = @@ -504,7 +498,12 @@ Zotero.Item.prototype.setType = function(itemTypeID, loadIn) { copiedFields.push([fieldID, this.getField(fieldID)]); } } - + } + + this._itemTypeID = itemTypeID; + + // If there's an existing type + if (oldItemTypeID) { // Reset custom creator types to the default var creators = this.getCreators(); if (creators) { @@ -765,7 +764,7 @@ Zotero.Item.prototype.setField = function(field, value, loadIn) { return false; } else { - throw (msg); + throw new Error(msg); } }