Delete 'history.json' when uninstalling to avoid corruption

Issue #590 wontfix
Pol Welter created an issue

I recently fixed a bug (f919c6f2) where a specific corruption of the history would make Speedcrunch unable to even start. Both the corruption and the crashes were due to a goof on my side, so it was easy enough to fix.

In general we will never be able to assure that no such disastrous bug goes unnoticed until release. I wondered whether the uninstaller could wipe history.json for good measure. As a user, if suddenly SC crashes at startup, the first thing I'd do is try a reinstall.

Surely, any user who uninstalls SC (with a vaild history) but wishes to reinstall it at some later point will loose the data.

@fk, you are the Windows installer expert; what do you think?

A better way would be to add in a safe mode, which in the event of a failure deletes the history. I have no idea on how to do this reliably. Does SC support exceptions?

Comments (4)

  1. Felix Krull

    Well, the installer and uninstaller run at a "system" level, so to speak, so whose user data would they have to wipe? All the users in the system? Any practical concerns aside: I don't think wiping user data in the uninstaller is a good idea ever. Not to forget, when the installer detects an existing SpeedCrunch installation, it invokes the uninstaller first, so any upgrade would also wipe the history.

    Re: safe mode, exceptions won't really do you much good here, I don't think. Qt doesn't throw any exceptions of its own and instead prefers to fail with error codes and explicit invalid states for objects, which means it fails silently, but generally safely, without crashing. I tried your issue, it seems that was a stack overflow? You can probably trap those (and similar bugs like segfaults) somehow, in a very platform-specific fashion, but then your process is in an undefined state anyway.

    It might be possible to cobble together some crash detection using an empty file that SpeedCrunch creates when it launches and deletes on a safe exit, possibly with the help of QLockFile, but then you get into trouble with running several instances at the same time. The other option would be an explicit safe mode, like Firefox does, with a command-line switch and menu entry, but that'd be kinda hard to find.

    (Sorta OT, it seems evaluator.cpp always defines EVALUATOR_DEBUG? It really shouldn't do that, at least not in release mode.)

  2. Pol Welter reporter

    Yes, I guess we best just put our efforts in not producing bugs in the first place :)

    Close as won't fix?

  3. Log in to comment