Skip to content

Fix 200-second sleep blocking configuration wizard launch (#469) - #661

Open
psieg wants to merge 2 commits into
masterfrom
fix/469-wizard-sleep-ms
Open

psieg wants to merge 2 commits into
masterfrom
fix/469-wizard-sleep-ms

Conversation

@psieg

@psieg psieg commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Fixes #469

Root Cause

When launching the configuration wizard from an active Prismatik instance (SettingsWindow::onRunConfigurationWizard_clicked()), a new Prismatik --wizard process is started while the existing instance exits. In LightpackApplication::processCommandLineArguments(), if isRunning() is still true while the previous instance tears down, the loop called QThread::sleep(200);.

Because QThread::sleep takes seconds rather than milliseconds, each iteration slept for 200 seconds (~3.3 minutes) instead of 200 ms, making the wizard appear to hang after the main window and tray icon closed (and spinning indefinitely if the previous instance failed to exit).

Changes

  • Software/src/WizardWaitHelper.hpp (registered in Software/src/src.pro and Software/tests/tests.pro):
    • Extract the bounded polling wait loop into pure C++17 WizardWaitHelper::waitForInstanceQuit(...) with default 10 s timeout (kDefaultQuitTimeoutMs = 10000) and 200 ms poll interval (kDefaultPollIntervalMs = 200).
  • Software/src/LightpackApplication.cpp:
    • Explicitly include <QElapsedTimer>, <QThread>, <cstdint>, <cstdlib>, and "WizardWaitHelper.hpp".
    • Replace QThread::sleep(200); with WizardWaitHelper::waitForInstanceQuit(...) using QElapsedTimer and QThread::msleep(200).
    • On timeout, log via qWarning(), surface the error via outputMessage(...) (so Windows GUI launches also display the message box without opening LogWriter while the old instance still holds Prismatik.0.log), and exit via ::exit(WizardQuitTimeout_ErrorCode).
  • Software/src/LightpackApplication.hpp:
    • Add WizardQuitTimeout_ErrorCode = 6 to LightpackApplication::ErrorCodes.
  • Software/tests/LightpackCommandLineParserTest.{hpp,cpp}:
    • Add unit tests (testCase_wizardWaitImmediateExit, testCase_wizardWaitExitAfterPolls, testCase_wizardWaitTimeout) covering immediate exit (0 sleeps), exit after N polls (including exact timeout boundary during final sleep), and timeout expiry (both default 10 s and 0 ms timeout).

Verification

  • Built Prismatik and LightpackTests with qmake6 -r && make -j2 on Linux (Qt 6.8.2) with zero warnings on the modified files.
  • Ran QT_QPA_PLATFORM=offscreen ./bin/LightpackTests: all 8 test suites passed (0 failed, 0 skipped; LightpackCommandLineParserTest: 12 passed).

This branch has not been deployed

No deployments
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.

Configuration wizard stopped working

1 participant