Skip to content

[10510] Factory-reset: close cloud DB and unify flow - #10794

Merged
luapmartin merged 5 commits into
audacity:masterfrom
luapmartin:luapmartin/10510-2
Apr 27, 2026
Merged

luapmartin merged 5 commits into
audacity:masterfrom
luapmartin:luapmartin/10510-2

Conversation

@luapmartin

@luapmartin luapmartin commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Resolves:
Revert to factory setting crash #10510
copy update #9677

  • Unify factory-reset entry points via FactoryResetMode; close CloudProjectsDatabase before wiping config
  • Multi-window restart-confirmation handling; cancel is default
  • Add single- and multi-window action-controller tests; drop unused -R CLI flag

this PR replaces #10518

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

QA:

  • Testflow test cases have been run

@luapmartin luapmartin self-assigned this Apr 24, 2026
@coderabbitai

coderabbitai Bot commented Apr 24, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0738fbd2-f57c-4d8c-a8f1-344176cfd2b7

📥 Commits

Reviewing files that changed from the base of the PR and between d3e47950ac0dd0e4132e4ec62206399c74d0d671 and ac8342b.

📒 Files selected for processing (7)
  • src/app/commandlineparser.cpp
  • src/appshell/iappshellconfiguration.h
  • src/appshell/internal/appshellconfiguration.cpp
  • src/appshell/internal/appshellconfiguration.h
  • src/appshell/tests/mocks/appshellconfigurationmock.h
  • src/au3cloud/internal/au3audiocomservice.cpp
  • src/au3cloud/internal/au3audiocomservice.h

📝 Walkthrough

Summary by CodeRabbit

  • Breaking Changes

    • Removed the --revert-settings command-line option; use --factory-settings instead.
  • Improvements

    • Streamlined factory-reset flow with clearer dialogs and safer restart behavior.
    • Better handling of open projects and multi-window restarts to avoid data loss.
    • More robust cloud-projects behavior during resets and shutdown for improved reliability.

Walkthrough

Enables workspace tests and appshell test toggling in CMake and exposes workspace config paths. Adds CloudProjectsDatabase existence check and explicit CloseConnection(), and guards cloud DB usage in housekeeper and housekeeper shutdown paths. Removes -R/--revert-settings CLI flag and narrows revert-to-factory-settings triggering. Extends IAppShellConfiguration and AppShellConfiguration with an about-to-revert notification and a new notifyOtherInstances parameter on revertToFactorySettings; ApplicationActionController uses async dialogs for the factory-reset flow and calls the updated API. Adds lifecycle deinit() hooks to au3cloud service/module and ensures cloud DB is closed on deinit or before factory reset. Adds appshell unit tests and multiple test mocks, plus some CMake/module cleanup.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Controller as ApplicationActionController
    participant Dialog as InteractiveDialogs
    participant AppConfig as AppShellConfiguration
    participant CloudDB as CloudProjectsDatabase
    participant Project as ProjectFilesController
    participant App as Application
    participant MultiWin as MultiWindowsProvider

    User->>Controller: trigger "revert-factory" action
    Controller->>Dialog: warning() (async)
    Dialog-->>User: show warning
    User->>Dialog: respond
    Dialog->>Controller: resolve(result)

    alt Cancel
        Controller-->>User: no action
    else Confirm
        Controller->>AppConfig: revertToFactorySettings(false,false,false)
        AppConfig->>AppConfig: aboutToRevertToFactorySettings.notify()
        AppConfig->>CloudDB: CloseConnection()
        Controller->>Dialog: question() restart (async)
        Dialog-->>User: show restart prompt
        User->>Dialog: respond
        Dialog->>Controller: resolve(result)

        alt Cancel restart
            Controller-->>User: revert done
        else Confirm restart
            Controller->>Project: closeOpenedProject(false)
            Project-->>Controller: success/failure
            alt close failed
                Controller-->>User: no restart
            else close succeeded
                Controller->>MultiWin: windowCount()
                MultiWin-->>Controller: count
                alt single window
                    Controller->>App: restart()
                else multiple windows
                    Controller->>App: quitAllAndRestartLast()
                    Controller->>App: exit()
                end
            end
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • embarc-gabriel
  • kryksyh
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main changes: factory-reset crash fix (#10510) and cloud DB closure with unified flow.
Description check ✅ Passed The description covers the main changes, includes issue links, and the author has checked all required checklist items except QA Testflow, which is marked as incomplete.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@luapmartin luapmartin changed the title Luapmartin/10510 2 [10510] Factory-reset: close cloud DB and unify flow Apr 24, 2026
@luapmartin luapmartin linked an issue Apr 24, 2026 that may be closed by this pull request
@luapmartin luapmartin mentioned this pull request Apr 24, 2026
5 of 7 tasks
@luapmartin
luapmartin requested a review from kryksyh April 24, 2026 14:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 55468ce9-7d5c-4553-b9c8-0bbb864c1c6f

📥 Commits

Reviewing files that changed from the base of the PR and between 472e90c and c90dcf397c465bff1bb7f06492db789cd5e71dbd.

📒 Files selected for processing (27)
  • CMakeLists.txt
  • au3/libraries/au3-cloud-audiocom/sync/CloudProjectsDatabase.cpp
  • au3/libraries/au3-cloud-audiocom/sync/CloudProjectsDatabase.h
  • au3/libraries/au3-cloud-audiocom/sync/CloudSyncHousekeeper.cpp
  • src/app/commandlineparser.cpp
  • src/app/guiapp.cpp
  • src/appshell/CMakeLists.txt
  • src/appshell/iappshellconfiguration.h
  • src/appshell/internal/applicationactioncontroller.cpp
  • src/appshell/internal/applicationactioncontroller.h
  • src/appshell/internal/appshellconfiguration.cpp
  • src/appshell/internal/appshellconfiguration.h
  • src/appshell/tests/CMakeLists.txt
  • src/appshell/tests/factoryreset_actioncontroller_tests.cpp
  • src/appshell/tests/mocks/appshellconfigurationmock.h
  • src/au3cloud/CMakeLists.txt
  • src/au3cloud/au3cloudmodule.cpp
  • src/au3cloud/au3cloudmodule.h
  • src/au3cloud/iau3audiocomservice.h
  • src/au3cloud/internal/au3audiocomservice.cpp
  • src/au3cloud/internal/au3audiocomservice.h
  • src/effects/effects_base/effectsmodule.cpp
  • src/effects/effects_base/effectsmodule.h
  • src/importexport/export/CMakeLists.txt
  • src/project/tests/mocks/projectfilescontrollermock.h
  • src/stubs/au3cloud/au3audiocomservicestub.cpp
  • src/stubs/au3cloud/au3audiocomservicestub.h
💤 Files with no reviewable changes (4)
  • src/au3cloud/CMakeLists.txt
  • src/effects/effects_base/effectsmodule.cpp
  • src/importexport/export/CMakeLists.txt
  • src/effects/effects_base/effectsmodule.h

Comment on lines +120 to +125
bool CloudProjectsDatabase::DatabaseExists()
{
const auto configDir = FileNames::ConfigDir();
const auto configPath = configDir + databaseFileName;
return wxFileExists(configPath);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

DatabaseExists() introduces a TOCTOU gap for reset/cleanup flows.

A caller can observe true here, then lose the file before the subsequent DB access; later GetConnection() may recreate audiocom_sync.db, which defeats “skip when DB is absent” intent during cleanup/reset. Consider adding an atomic API that checks existence and opens (or declines) under mConnectionMutex in one step, then use that API at call sites.

🧰 Tools
🪛 Cppcheck (2.20.0)

[style] 120-120: The function 'DatabaseExists' is never used.

(unusedFunction)

Comment thread CMakeLists.txt
@@ -110,6 +111,7 @@ option(AU_BUILD_EFFECTS_BUILTIN_TESTS "Build builtin-effect tests" ON)
option(AU_BUILD_EFFECTS_MODULE "Build effects module" ON)
option(AU_BUILD_EFFECTS_TESTS "Build effects tests" ON)
option(AU_BUILD_PLAYBACK_MODULE "Build playback module" ON)
option(AU_BUILD_APPSHELL_TESTS "Build appshell tests" ON)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Keep module options alphabetized to match the local convention.

AU_BUILD_APPSHELL_TESTS is out of order relative to the surrounding AU_BUILD_* options, which makes maintenance noisier in this block.

Comment thread src/app/guiapp.cpp Resolved
Comment on lines +346 to +349
static constexpr bool KEEP_DEFAULT_SETTINGS = false;
static constexpr bool NOTIFY_ABOUT_CHANGES = false;
static constexpr bool NOTIFY_OTHER_INSTANCES = false;
configuration()->revertToFactorySettings(KEEP_DEFAULT_SETTINGS, NOTIFY_ABOUT_CHANGES, NOTIFY_OTHER_INSTANCES);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

MuseScore appshell applicationactioncontroller revertToFactorySettings NOTIFY_OTHER_INSTANCES

💡 Result:

The specific action/controller string you gave — “MuseScore appshell applicationactioncontroller revertToFactorySettings NOTIFY_OTHER_INSTANCES” — does not appear in the authoritative documentation or issues I could locate, and I could not find a source that confirms those exact identifiers. What I can confirm from MuseScore’s official documentation is the supported “revert to factory settings” feature and its invocation mechanisms: 1) In the app UI (MuseScore 4): Help → Revert to factory settings, then choose Revert and Restart. 2) From the command line: MuseScore 4 supports launching with a “-F” option to revert settings; the Handbook describes this as resetting all MuseScore preferences to “factory settings” and immediately launching the app. Sources also show related multi-instance behavior around resets/preferences not syncing fully, but not the specific “NOTIFY_OTHER_INSTANCES” flag. If you want, paste the relevant code snippet or file path where you see “applicationactioncontroller” and “revertToFactorySettings”; with that, I can map it precisely to the corresponding command-line/UI behavior and multi-instance notification behavior in the MuseScore codebase.

Citations:


🏁 Script executed:

#!/bin/bash
# First, locate and read the applicationactioncontroller.cpp file
find . -name "applicationactioncontroller.cpp" -type f

Repository: audacity/audacity

Length of output: 117


🏁 Script executed:

#!/bin/bash
# Search for revertToFactorySettings implementation to understand the parameter
rg -A 10 "void.*revertToFactorySettings" --type cpp

Repository: audacity/audacity

Length of output: 6499


🏁 Script executed:

#!/bin/bash
# Look at the full context around lines 346-362 to understand the control flow
sed -n '340,365p' src/appshell/internal/applicationactioncontroller.cpp

Repository: audacity/audacity

Length of output: 1472


🏁 Script executed:

#!/bin/bash
# Find and examine the restart() function
rg -A 15 "void.*restart\(\)" src/appshell/internal/applicationactioncontroller.cpp

Repository: audacity/audacity

Length of output: 495


🏁 Script executed:

#!/bin/bash
# Find the closeOpenedProject function and understand what returning false means
rg -B 2 -A 10 "closeOpenedProject" src/appshell/internal/applicationactioncontroller.cpp | head -50

Repository: audacity/audacity

Length of output: 1325


🏁 Script executed:

#!/bin/bash
# Find the settings()->reset() implementation
rg -B 5 -A 20 "void.*settings.*reset" --type cpp | head -100

Repository: audacity/audacity

Length of output: 2260


🏁 Script executed:

#!/bin/bash
# Search for all calls to revertToFactorySettings to see parameter patterns
rg "revertToFactorySettings" -B 2 -A 2 --type cpp

Repository: audacity/audacity

Length of output: 8022


🏁 Script executed:

#!/bin/bash
# Check the interface default and any documentation about notifyOtherInstances
cat -n src/appshell/iappshellconfiguration.h | grep -A 5 "revertToFactorySettings"

Repository: audacity/audacity

Length of output: 438


🏁 Script executed:

#!/bin/bash
# Find where notifyOtherInstances is actually used in the settings/reset implementation
rg "notifyOtherInstances" --type cpp -B 3 -A 3

Repository: audacity/audacity

Length of output: 2245


🏁 Script executed:

#!/bin/bash
# Look at the settings implementation to understand what happens with notifyOtherInstances
find . -path "*/src/framework/*" -name "*.cpp" -o -path "*/src/framework/*" -name "*.h" | xargs grep -l "settings.*reset" | head -5

Repository: audacity/audacity

Length of output: 43


🏁 Script executed:

#!/bin/bash
# Check if there are any comments in the test file explaining the design choice
cat -n src/appshell/tests/factoryreset_actioncontroller_tests.cpp | head -100

Repository: audacity/audacity

Length of output: 4659


🏁 Script executed:

#!/bin/bash
# Look at more of the test file to understand the design rationale
sed -n '100,250p' src/appshell/tests/factoryreset_actioncontroller_tests.cpp

Repository: audacity/audacity

Length of output: 4907


🏁 Script executed:

#!/bin/bash
# Search for any issue or comment explaining the design choice for notifyOtherInstances
rg "notifyOtherInstances\|notify.*other.*instance" -B 5 -A 5 --type cpp --type h

Repository: audacity/audacity

Length of output: 43


🏁 Script executed:

#!/bin/bash
# Check all usages in context - maybe CLI and preferences have comments
sed -n '85,95p' src/app/guiapp.cpp
sed -n '230,250p' src/preferences/qml/Audacity/Preferences/preferencesmodel.cpp

Repository: audacity/audacity

Length of output: 1060


Document why NOTIFY_OTHER_INSTANCES = false is intentional.

The test suite explicitly validates that settings are reset (with notifyOtherInstances=false) before the restart prompt appears. This means if a user cancels the restart dialog, other running Audacity instances won't be notified despite having their settings wiped. The test "ConfirmWarning_CancelRestart_NoRestart" confirms this is the intended behavior, but the code lacks any comment explaining why this differs from the default (true) and from other call sites (CLI and preferences both use defaults, resulting in notifyOtherInstances=true). Add a comment clarifying the design rationale.

Comment on lines +33 to +72
void SetUp() override
{
m_controller = new ApplicationActionController(muse::modularity::globalCtx());

m_dispatcher = std::make_shared<NiceMock<muse::actions::ActionsDispatcherMock> >();
m_controller->dispatcher.set(m_dispatcher);

ON_CALL(*m_dispatcher, reg(_, _, testing::An<const ActionCB&>()))
.WillByDefault([this](muse::actions::Actionable*, const muse::actions::ActionCode& code,
const ActionCB& cb) {
m_registeredActions[code] = cb;
});

m_interactive = std::make_shared<NiceMock<InteractiveMock> >();
m_controller->interactive.set(m_interactive);

ON_CALL(*m_interactive, buttonData(IInteractive::Button::Cancel))
.WillByDefault(Return(IInteractive::ButtonData(IInteractive::Button::Cancel, "Cancel")));

m_application = std::make_shared<NiceMock<ApplicationMock> >();
m_controller->application.set(m_application);

m_configuration = std::make_shared<NiceMock<AppShellConfigurationMock> >();
m_controller->configuration.set(m_configuration);

m_projectFilesController = std::make_shared<NiceMock<au::project::ProjectFilesControllerMock> >();
m_controller->projectFilesController.set(m_projectFilesController);

m_multiWindowsProvider = std::make_shared<NiceMock<muse::mi::MultiWindowsProviderMock> >();
m_controller->multiwindowsProvider.set(m_multiWindowsProvider);

setupWarningDialog();

m_controller->init();
}

void TearDown() override
{
delete m_controller;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Nit: prefer std::unique_ptr over raw new/delete.

m_controller can leak if SetUp() throws between new ApplicationActionController(...) and finishing the rest of the setup. Replacing with std::unique_ptr<ApplicationActionController> removes the need for an explicit TearDown() delete and is exception-safe.

♻️ Proposed change
-        m_controller = new ApplicationActionController(muse::modularity::globalCtx());
+        m_controller = std::make_unique<ApplicationActionController>(muse::modularity::globalCtx());
...
-    void TearDown() override
-    {
-        delete m_controller;
-    }
+    // TearDown no longer needed; unique_ptr handles cleanup.
...
-    ApplicationActionController* m_controller = nullptr;
+    std::unique_ptr<ApplicationActionController> m_controller;

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: d80add22-3fa4-4497-87d9-3747ff938bd4

📥 Commits

Reviewing files that changed from the base of the PR and between c90dcf397c465bff1bb7f06492db789cd5e71dbd and d3e47950ac0dd0e4132e4ec62206399c74d0d671.

📒 Files selected for processing (27)
  • CMakeLists.txt
  • au3/libraries/au3-cloud-audiocom/sync/CloudProjectsDatabase.cpp
  • au3/libraries/au3-cloud-audiocom/sync/CloudProjectsDatabase.h
  • au3/libraries/au3-cloud-audiocom/sync/CloudSyncHousekeeper.cpp
  • src/app/commandlineparser.cpp
  • src/app/guiapp.cpp
  • src/appshell/CMakeLists.txt
  • src/appshell/iappshellconfiguration.h
  • src/appshell/internal/applicationactioncontroller.cpp
  • src/appshell/internal/applicationactioncontroller.h
  • src/appshell/internal/appshellconfiguration.cpp
  • src/appshell/internal/appshellconfiguration.h
  • src/appshell/tests/CMakeLists.txt
  • src/appshell/tests/factoryreset_actioncontroller_tests.cpp
  • src/appshell/tests/mocks/appshellconfigurationmock.h
  • src/au3cloud/CMakeLists.txt
  • src/au3cloud/au3cloudmodule.cpp
  • src/au3cloud/au3cloudmodule.h
  • src/au3cloud/iau3audiocomservice.h
  • src/au3cloud/internal/au3audiocomservice.cpp
  • src/au3cloud/internal/au3audiocomservice.h
  • src/effects/effects_base/effectsmodule.cpp
  • src/effects/effects_base/effectsmodule.h
  • src/importexport/export/CMakeLists.txt
  • src/project/tests/mocks/projectfilescontrollermock.h
  • src/stubs/au3cloud/au3audiocomservicestub.cpp
  • src/stubs/au3cloud/au3audiocomservicestub.h
💤 Files with no reviewable changes (4)
  • src/effects/effects_base/effectsmodule.cpp
  • src/au3cloud/CMakeLists.txt
  • src/effects/effects_base/effectsmodule.h
  • src/importexport/export/CMakeLists.txt

Comment thread CMakeLists.txt
@@ -98,6 +98,7 @@ set(MUSE_MODULE_UI_TESTS OFF)
set(MUSE_MODULE_UPDATE ON)
set(MUSE_MODULE_UPDATE_QML ON)
set(MUSE_MODULE_WORKSPACE ON)
set(MUSE_MODULE_WORKSPACE_TESTS ON)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -nP '\b(APP_WORKSPACE_CONFIG_FILE|APP_BUILTIN_WORKSPACES_DIR|MUSE_MODULE_WORKSPACE_TESTS)\b' --type=cmake --type=cpp --type=h

Repository: audacity/audacity

Length of output: 321


🏁 Script executed:

#!/bin/bash
# Search for all references to these variables (including definitions and usage)
echo "=== Searching for APP_WORKSPACE_CONFIG_FILE references ==="
rg -n 'APP_WORKSPACE_CONFIG_FILE' --type=cmake --type=cpp --type=h --type=txt || echo "No references found"

echo ""
echo "=== Searching for APP_BUILTIN_WORKSPACES_DIR references ==="
rg -n 'APP_BUILTIN_WORKSPACES_DIR' --type=cmake --type=cpp --type=h --type=txt || echo "No references found"

echo ""
echo "=== Searching for MUSE_MODULE_WORKSPACE_TESTS references ==="
rg -n 'MUSE_MODULE_WORKSPACE_TESTS' --type=cmake --type=cpp --type=h --type=txt || echo "No references found"

Repository: audacity/audacity

Length of output: 503


🏁 Script executed:

#!/bin/bash
# Check for configure_file or indirect usages
echo "=== Searching for configure_file calls in CMakeLists.txt ==="
rg -n 'configure_file' CMakeLists.txt || echo "No configure_file calls"

echo ""
echo "=== Searching for add_compile_definitions with these variables ==="
rg -n 'add_compile_definitions.*APP_WORKSPACE|add_compile_definitions.*MUSE_MODULE_WORKSPACE' --type=cmake || echo "No matches"

echo ""
echo "=== Checking appshell CMakeLists structure ==="
fd -n 'CMakeLists.txt' | grep -i appshell | head -5

Repository: audacity/audacity

Length of output: 522


🏁 Script executed:

#!/bin/bash
# Check appshell CMakeLists files
echo "=== Finding appshell CMakeLists files ==="
find . -path '*/appshell*' -name 'CMakeLists.txt' 2>/dev/null | head -10

echo ""
echo "=== Check root CMakeLists.txt context around these definitions (lines 90-165) ==="
sed -n '90,165p' CMakeLists.txt | head -80

Repository: audacity/audacity

Length of output: 3281


🏁 Script executed:

#!/bin/bash
echo "=== Contents of appshell tests CMakeLists.txt ==="
cat -n src/appshell/tests/CMakeLists.txt

Repository: audacity/audacity

Length of output: 955


🏁 Script executed:

#!/bin/bash
echo "=== Checking test source file for variable references ==="
rg -n '(APP_WORKSPACE_CONFIG_FILE|APP_BUILTIN_WORKSPACES_DIR|MUSE_MODULE_WORKSPACE_TESTS)' src/appshell/tests/ || echo "No references found"

echo ""
echo "=== Checking if variables appear in any source files outside CMakeLists ==="
rg -n '(APP_WORKSPACE_CONFIG_FILE|APP_BUILTIN_WORKSPACES_DIR)' --type=cpp --type=h || echo "No references found"

Repository: audacity/audacity

Length of output: 236


Remove unused build variables or complete their integration with appshell tests.

MUSE_MODULE_WORKSPACE_TESTS (line 101), APP_WORKSPACE_CONFIG_FILE (line 154), and APP_BUILTIN_WORKSPACES_DIR (line 155) are defined in CMakeLists.txt but never referenced anywhere in the codebase. The appshell tests CMakeLists.txt does not consume these variables, and no source files reference them. Either integrate these variables into the test configuration or remove them to avoid dead code in the build system.

Comment on lines +341 to +366
promise.onResolve(this, [this](const muse::IInteractive::Result& res) {
if (res.isButton(muse::IInteractive::Button::Cancel)) {
return;
}

title = muse::trc("appshell", "Would you like to restart Audacity now?");
question = muse::trc("appshell", "Audacity needs to be restarted for these changes to take effect.");
static constexpr bool KEEP_DEFAULT_SETTINGS = false;
static constexpr bool NOTIFY_ABOUT_CHANGES = false;
static constexpr bool NOTIFY_OTHER_INSTANCES = false;
configuration()->revertToFactorySettings(KEEP_DEFAULT_SETTINGS, NOTIFY_ABOUT_CHANGES, NOTIFY_OTHER_INSTANCES);

int restartBtn = int(muse::IInteractive::Button::Apply);
result = interactive()->questionSync(title, question,
{ interactive()->buttonData(muse::IInteractive::Button::Cancel),
muse::IInteractive::ButtonData(restartBtn, muse::trc("appshell", "Restart"), true) },
restartBtn);
std::string title = muse::trc("appshell", "Would you like to restart Audacity now?");
std::string question = muse::trc("appshell", "Audacity needs to be restarted for these changes to take effect.");

if (result.standardButton() == muse::IInteractive::Button::Cancel) {
return;
}
int restartBtn = int(muse::IInteractive::Button::Apply);
auto promise = interactive()->question(title, question,
{ interactive()->buttonData(muse::IInteractive::Button::Cancel),
muse::IInteractive::ButtonData(restartBtn,
muse::trc("appshell", "Restart"), true) },
restartBtn);

restart();
promise.onResolve(this, [this](const muse::IInteractive::Result& res) {
if (!res.isButton(muse::IInteractive::Button::Cancel)) {
restart();
}
});
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Prefer positive button checks (isButton(Apply)) over negative !isButton(Cancel).

Both nested onResolve handlers gate behavior on !res.isButton(Cancel). If IInteractive::Result ever resolves to any button code other than Cancel/Apply (e.g., a future addition, a dismissed dialog reported as "No button", or a close event that doesn't map to Cancel on some platforms), the logic will proceed to revert/restart. Given the destructive nature of these operations (wiping configuration, restarting the app), positive checks are safer:

♻️ Suggested change
-    promise.onResolve(this, [this](const muse::IInteractive::Result& res) {
-        if (res.isButton(muse::IInteractive::Button::Cancel)) {
-            return;
-        }
+    promise.onResolve(this, [this](const muse::IInteractive::Result& res) {
+        if (!res.isButton(muse::IInteractive::Button::Apply)) {
+            return;
+        }
...
-        promise.onResolve(this, [this](const muse::IInteractive::Result& res) {
-            if (!res.isButton(muse::IInteractive::Button::Cancel)) {
-                restart();
-            }
-        });
+        promise.onResolve(this, [this](const muse::IInteractive::Result& res) {
+            if (res.isButton(muse::IInteractive::Button::Apply)) {
+                restart();
+            }
+        });

Also the inner title, question, and promise locals at lines 351–355 shadow the outer ones of the same name — minor readability nit, renaming (e.g., restartTitle, restartPromise) would help.

Comment on lines +74 to +106
void setupWarningDialog()
{
EXPECT_CALL(*m_interactive, warning(
HasSubstr("revert to factory settings"),
_, _,
static_cast<int>(IInteractive::Button::Cancel),
_, _))
.WillOnce([this](const std::string&, const IInteractive::Text&,
const IInteractive::ButtonDatas&, int,
const IInteractive::Options&, const std::string&) -> WarningPromise {
return WarningPromise([this](WarningPromise::Resolve resolve,
WarningPromise::Reject) -> WarningPromise::Result {
m_warningResolve = resolve;
return WarningPromise::Result::unchecked();
}, muse::async::PromiseType::AsyncByBody);
});
}

void setupRestartDialog()
{
EXPECT_CALL(*m_interactive, question(
HasSubstr("restart Audacity"),
_, _, _, _, _))
.WillOnce([this](const std::string&, const IInteractive::Text&,
const IInteractive::ButtonDatas&, int,
const IInteractive::Options&, const std::string&) -> QuestionPromise {
return QuestionPromise([this](QuestionPromise::Resolve resolve,
QuestionPromise::Reject) -> QuestionPromise::Result {
m_questionResolve = resolve;
return QuestionPromise::Result::unchecked();
}, muse::async::PromiseType::AsyncByBody);
});
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Matching on translated substrings couples tests to translation state.

HasSubstr("revert to factory settings") and HasSubstr("restart Audacity") rely on muse::trc("appshell", ...) returning English when invoked inside the test harness. If the test runner ever initializes a locale (or the translator layer returns an empty string for an unregistered domain), these WillOnce expectations will silently fail to match and the resulting default-constructed std::function resolvers will crash confirmWarningDialog()/cancelRestartDialog(). Consider either:

  • matching on the action code/trigger rather than the dialog title, or
  • making the matcher _ for title and asserting title via a side-channel capture.

Defensive option: assert the resolvers are valid before invoking them, so a missed expectation produces a clear test failure rather than a null std::function call.

 void confirmWarningDialog()
 {
+    ASSERT_TRUE(static_cast<bool>(m_warningResolve)) << "warning() was not invoked";
     int btn = static_cast<int>(IInteractive::Button::Apply);
     IInteractive::Result result(btn);
     (void)m_warningResolve(result);
 }

@luapmartin
luapmartin merged commit 4ef5d38 into audacity:master Apr 27, 2026
8 checks passed
@luapmartin
luapmartin deleted the luapmartin/10510-2 branch April 27, 2026 10:50
@luapmartin luapmartin linked an issue Apr 27, 2026 that may be closed by this pull request
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.

Revert to factory setting crash Revert to factory settings – copy update

2 participants