Skip to content

Fix restart functionality: use exit code mechanism instead of direct process spawning#176

Merged
lzy98276 merged 5 commits intomasterfrom
copilot/fix-restart-functionality
Jan 28, 2026
Merged

Fix restart functionality: use exit code mechanism instead of direct process spawning#176
lzy98276 merged 5 commits intomasterfrom
copilot/fix-restart-functionality

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

Problem

Restart functionality failed because restart_app() attempted to spawn new processes directly with Windows-specific subprocess code and called sys.exit(0), bypassing the existing EXIT_CODE_RESTART mechanism. This broke packaged builds and non-Windows platforms.

Changes

app/view/main/window.py

  • Replaced direct process spawning with QApplication.exit(EXIT_CODE_RESTART)
  • Removed Windows-specific subprocess code and unused imports (-28 lines)

main.py

  • Enhanced restart_application() with platform-specific logic:
    • Windows: subprocess.Popen() with DETACHED_PROCESS flags
    • Linux/Unix/macOS: os.execl() to replace current process
  • Moved subprocess/platform imports to module level

Key change

# Before: window.py tried to restart directly (didn't work)
subprocess.Popen([sys.executable] + args, ...)
sys.exit(0)

# After: window.py signals restart request
QApplication.exit(EXIT_CODE_RESTART)  # main.py handles actual restart

The restart now flows through the proper cleanup and exit handler that checks for EXIT_CODE_RESTART, ensuring resources are released correctly before relaunching.

Original prompt

目前代码“重启”功能有问题,请帮忙修复(确保打包前和打包(actions)后全部正常运行


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 28, 2026 11:54
…nvironments

- Modified restart_app() in window.py to use QApplication.exit(EXIT_CODE_RESTART)
- Updated restart_application() in main.py to handle Windows and Linux properly
- Removed unused subprocess import from window.py
- The restart now properly uses the EXIT_CODE_RESTART mechanism

Co-authored-by: WSXYT <102407247+WSXYT@users.noreply.github.com>
Co-authored-by: WSXYT <102407247+WSXYT@users.noreply.github.com>
…tart exit

- Moved subprocess and platform imports to module level
- Simplified executable assignment (removed redundant condition)
- Added os._exit(0) after successful Windows restart to properly terminate current process

Co-authored-by: WSXYT <102407247+WSXYT@users.noreply.github.com>
- Moved EXIT_CODE_RESTART import to module level in window.py
- Simplified exception handling in restart_application
- Updated comments to clarify macOS support in restart logic

Co-authored-by: WSXYT <102407247+WSXYT@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix restart functionality to ensure proper execution Fix restart functionality: use exit code mechanism instead of direct process spawning Jan 28, 2026
Copilot AI requested a review from WSXYT January 28, 2026 12:03
@lzy98276 lzy98276 marked this pull request as ready for review January 28, 2026 12:07
@lzy98276 lzy98276 merged commit ce583e2 into master Jan 28, 2026
7 of 8 checks passed
@lzy98276 lzy98276 deleted the copilot/fix-restart-functionality branch January 28, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments