From 849ffe0133c8022a1e0fada4d14babda4da4dcac Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 29 Mar 2024 07:19:58 -0400 Subject: [PATCH] Don't try to register command line handler if already registered Avoids an error when reiniting during tests --- .../zotero/xpcom/commandLineHandler.js | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/xpcom/commandLineHandler.js b/chrome/content/zotero/xpcom/commandLineHandler.js index 8f40cf689e..3e752c9d47 100644 --- a/chrome/content/zotero/xpcom/commandLineHandler.js +++ b/chrome/content/zotero/xpcom/commandLineHandler.js @@ -130,14 +130,17 @@ var ZoteroCommandLineHandler = { }; const Cm = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); -Cm.registerFactory( - ZoteroCommandLineHandler.classID, - "command-line-handler", - ZoteroCommandLineHandler.contractID, - ZoteroCommandLineHandler -); -const catman = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager); - -catman.addCategoryEntry("command-line-handler", - "m-zotero", - ZoteroCommandLineHandler.contractID, false, true); +// Don't register if already registered (e.g., after a reinit() in tests) +if (!Cm.isCIDRegistered(ZoteroCommandLineHandler.classID)) { + Cm.registerFactory( + ZoteroCommandLineHandler.classID, + "command-line-handler", + ZoteroCommandLineHandler.contractID, + ZoteroCommandLineHandler + ); + const catman = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager); + + catman.addCategoryEntry("command-line-handler", + "m-zotero", + ZoteroCommandLineHandler.contractID, false, true); +}