Repository navigation
fix(app): keep a second instance off a profile that is still in use - #1047
Open
bartech-lab wants to merge 2 commits into
Open
bartech-lab wants to merge 2 commits into
bartech-lab wants to merge 2 commits into
Conversation
The single-instance check only connects to the local socket. When an earlier process is still alive but its socket is gone, a second instance opened the same WebEngine profile, showed the QR login page and reset the quota database (rafatosta#1038). Take a QLockFile in the data directory before any WebEngine profile is created. While another live process holds it, exit with a message naming that process. Wait up to 10 seconds so the successor of a full restart can start while the old process exits. The lock of a dead process is taken over. Tests: - python -m unittest tests/test_single_instance_lock.py -v - python -m unittest discover -s tests -q (same pre-existing failures as main) - python tests/check_unused_code.py --packages-only - python tests/test_documentation_structure.py -v - python -m compileall -q zapzap tests tools run.py - git diff --check
Exit only when another process holds the lock. A data directory where the lock file cannot be created is not proof of another instance. Skip the lock tests outside Linux, where they rely on XDG_DATA_HOME and a socket file in TMPDIR. Tests: - python -m unittest tests/test_single_instance_lock.py -v - python -m unittest discover -s tests -q (same pre-existing failures as main)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1038.
The single-instance check only connects to the local socket. When an earlier ZapZap process is still alive but its socket is gone, a second instance opens the same WebEngine profile, shows the QR login page and resets the quota database.
This change takes a
QLockFile(instance.lockin the data directory) before any WebEngine profile is created:QLockFilesees that the process is gone and takes the lock over.The socket path is unchanged, so a normal second launch still activates the running window.
Validation
tests/test_single_instance_lock.pyruns real separate instances with a throwaway data and socket directory: live process without socket (the second instance exits with code 1), lock left by a killed process (taken over), and a restart-like handover (successor waits and starts). The first fails if the instance does not exit on a held lock, and the third fails if the wait is removed. They are skipped outside Linux and are not in the CI workflow, which runs named test files only.mainit still reproduces.zapzap zapzap://restartsent to a running instance): the old process exits and the new one holds the lock and listens on the socket.check_unused_code.py,test_documentation_structure.py,compileallandgit diff --check: no new failures. Eight tests fail identically onmainin my environment (dictionaries, zh_CN catalog, macOS packaging, one accounts UI test).I ran the test list from
AGENTS.mdin the Flatpak (com.rtosta.zapzap7.5.1 from Flathub: Python 3.13, Qt 6.11.2, PyQt6 6.11.0) and with the Arch system Python (Qt 6.12, PyQt6 6.12.1, QtWebEngine 6.140), with the same results in both. The reproduction script and the restart check ran with the system Python. CHANGELOG,docs/architecture.mdand thedocs/testing.mdinventory are updated.One limitation: the message goes to stderr only, so a launch from the app menu waits up to 10 seconds and then shows nothing. A dialog would need new translatable strings; I can add one if you prefer.