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.)
This commit is contained in:
Dan Stillman 2022-06-23 05:33:47 -04:00
parent 3805f901cf
commit 0120877623

View file

@ -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);