macOS: keep a plain vorta run alive after its window is closed - #2556
Merged
Conversation
When Vorta is started from a venv rather than from the app bundle, macOS sends the process a quit Apple Event about two seconds after its last window is closed, so closing the main window terminates the app instead of leaving it in the tray. This only happens to processes with the Regular activation policy (Dock icon); the bundle is an LSUIElement, i.e. runs with the Accessory policy, and is never asked to quit. Give non-frozen runs the same policy as the bundle. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Description
Started from a venv (
vorta,vorta --development, or the test suite) rather than from the app bundle, Vorta terminates about two seconds after its main window is closed instead of staying in the tray. The cause is outside Vorta: macOS sends a process that runs with the Regular activation policy (Dock icon) aquitApple Event (aevt/quit, no sender PID) ~1.6 s after its last window goes away; AppKit turns that intoapplicationShouldTerminate:and Qt into aQEvent::Quit. The bundle hasLSUIElement=1, runs with the Accessory policy, and is never asked.setQuitOnLastWindowClosed(False)has no say in this, and neither hasQEventLoopLockerorNSProcessInfo.disableAutomaticTermination:(all tried).This gives non-frozen macOS runs the bundle's policy right after the
QApplicationis created. Side effect, by design: a venv run no longer shows a Dock icon — exactly like the shipped app.Related Issue
Found while testing #2555 from a venv; the behaviour is the same on
master. No separate issue.Motivation and Context
Developers testing tray behaviour from a checkout currently get a spurious quit whenever they close the window.
How Has This Been Tested?
QMainWindow,setQuitOnLastWindowClosed(False)): hiding the window →applicationShouldTerminateAfterLastWindowClosed:(answered NO) → 1.6 s later anaevt/quitApple Event → quit. Same on PyQt6 6.6.1, 6.10.0 and 6.11.0; gone with the Accessory policy.vorta --development <dir>fromvorta-env, macOS 15.7): before,aboutToQuit1.7 s afterclose()on bothmasterand this branch's parent; with this change the app is still running 8 s after the close and opens the window again from the tray.tests/unit/test_application.py(macOS only) asserts the policy;pytest tests/unit: 265 passed, 7 skipped (macOS).Types of changes
Checklist:
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.
🤖 Generated with Claude Code