From 517ca6f342eeb5bcc0c1a58cf787ee27573575f9 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 7 Aug 2013 17:42:15 -0400 Subject: [PATCH] Force quit after zapping cache files to prevent destroying prefs --- chrome/content/zotero/standalone/standalone.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js index a94e81277..1204bcc8e 100644 --- a/chrome/content/zotero/standalone/standalone.js +++ b/chrome/content/zotero/standalone/standalone.js @@ -157,18 +157,23 @@ const ZoteroStandalone = new function() { getService(Components.interfaces.nsIEnvironment); var user = env.get("USER") || env.get("USERNAME"); if(user === "root") { - // Zap cache files - try { - Services.dirsvc.get("ProfLD", Components.interfaces.nsIFile).remove(true); - } catch(e) {} - // Warn user never to do this again + // Show warning if(Services.prompt.confirmEx(null, "", Zotero.getString("standalone.rootWarning"), Services.prompt.BUTTON_POS_0*Services.prompt.BUTTON_TITLE_IS_STRING | Services.prompt.BUTTON_POS_1*Services.prompt.BUTTON_TITLE_IS_STRING, Zotero.getString("standalone.rootWarning.exit"), Zotero.getString("standalone.rootWarning.continue"), null, null, {}) == 0) { - goQuitApplication(); + Components.utils.import("resource://gre/modules/ctypes.jsm"); + var exit = Zotero.IPC.getLibc().declare("exit", ctypes.default_abi, + ctypes.void_t, ctypes.int); + // Zap cache files + try { + Services.dirsvc.get("ProfLD", Components.interfaces.nsIFile).remove(true); + } catch(e) {} + // Exit Zotero without giving XULRunner the opportunity to figure out the + // cache is missing. Otherwise XULRunner will zap the prefs + exit(0); } } }