From 012087762382bd316aa8c2ec936025447a032f4e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 23 Jun 2022 05:33:47 -0400 Subject: [PATCH] fx-compat: Avoid automatic safe mode from Ctrl-C Pressing Ctrl-C via the terminal is counted as a crash, and after three recent crashes automatic safe mode is triggered. In Firefox, this displays a prompt: > Firefox closed unexpectedly while starting. This might be caused by > add-ons or other problems. You can try to resolve the problem by > troubleshooting in Safe Mode. For us, that dialog doesn't appear for some reason (maybe we could make it?) and Zotero just automatically opens in Safe Mode, which causes state not to be restored and results in an annoying process fork that breaks Ctrl-C. We might as well keep the automatic-safe-mode behavior for end users, but we don't want to trigger it while working via the terminal, so we just clear the recent crash counter when using `-ZoteroDebug` or `-ZoteroDebugText`. (`extensions.zotero.debug.log` won't trigger it, so it's best to use `-ZoteroDebugText`, which is included automatically via the `build_and_run` script.) --- components/zotero-service.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/zotero-service.js b/components/zotero-service.js index 68154b683d..1c955363d7 100644 --- a/components/zotero-service.js +++ b/components/zotero-service.js @@ -494,6 +494,12 @@ ZoteroCommandLineHandler.prototype = { else if (cmdLine.handleFlag("ZoteroDebugText", false)) { zInitOptions.forceDebugLog = 1; } + // Pressing Ctrl-C via the terminal is interpreted as a crash, and after three crashes + // Firefox starts up in automatic safe mode. To avoid this, we clear the crash counter when + // using one of the debug-logging flags, which generally imply terminal usage. + if (zInitOptions.forceDebugLog) { + Services.prefs.getBranch("toolkit.startup.").clearUserPref('recent_crashes'); + } zInitOptions.forceDataDir = cmdLine.handleFlagWithParam("datadir", false);