Skip to content

Commit

Permalink
lp1912129: Always destroy MixxxMainWindow before CoreServices
Browse files Browse the repository at this point in the history
Fixes [lp1912129].

This gets rid of an issue where Mixxx failed with an assertion during
shutdown that complained about leaked controls (that are owned by the
menu bar):

    warning [Main] The following 6 controls were leaked:
    warning [Main] "[VinylControl]" "show_vinylcontrol" QObject(0x0)
    warning [Main] "[Master]" "skin_settings" QObject(0x0)
    warning [Main] "[PreviewDeck]" "show_previewdeck" QObject(0x0)
    warning [Main] "[Master]" "maximize_library" QObject(0x0)
    warning [Main] "[Library]" "show_coverart" QObject(0x0)
    warning [Main] "[Microphone]" "show_microphone" QObject(0x0)
    DEBUG ASSERT: "!"Controls were leaked!"" in function void mixxx::CoreServices::shutdown() at /home/jan/Projects/mixxx/src/coreservices.cpp:582
    Aborted (core dumped)

The issue occurs when shutting down Mixxx by pressing <Super>+q in Pop!
Shell which closes the window immediately. Apparently this is
incomaptible with our `sendPostedEvents()` trick to destroy the menubar
and leads to `CoreServices` being shut down before the Menubar is
actually destroyed, leaving some COs intact and triggering the
assertion.

This fixes the issue by ensuring that `MixxxMainWindow` is always
completely destroyed before `CoreServices::shutdown()` is called.

[lp1912129]: https://bugs.launchpad.net/mixxx/+bug/1912129
  • Loading branch information
Holzhaus committed Aug 16, 2021
1 parent 8438553 commit b1cf8bc
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,36 @@ int runMixxx(MixxxApplication* pApp, const CmdlineArgs& args) {

CmdlineArgs::Instance().parseForUserFeedback();

MixxxMainWindow mainWindow(pCoreServices);
pApp->processEvents();
pApp->installEventFilter(&mainWindow);

QObject::connect(pCoreServices.get(),
&mixxx::CoreServices::initializationProgressUpdate,
&mainWindow,
&MixxxMainWindow::initializationProgressUpdate);
pCoreServices->initialize(pApp);
mainWindow.initialize();

// If startup produced a fatal error, then don't even start the
// Qt event loop.
if (ErrorDialogHandler::instance()->checkError()) {
return kFatalErrorOnStartupExitCode;
} else {
qDebug() << "Displaying main window";
mainWindow.show();

qDebug() << "Running Mixxx";
return pApp->exec();
int exitCode;

// This scope ensures that `MixxxMainWindow` is destroyed *before*
// CoreServices is shut down. Otherwise a debug assertion complaining about
// leaked COs may be triggered.
{
MixxxMainWindow mainWindow(pCoreServices);
pApp->processEvents();
pApp->installEventFilter(&mainWindow);

QObject::connect(pCoreServices.get(),
&mixxx::CoreServices::initializationProgressUpdate,
&mainWindow,
&MixxxMainWindow::initializationProgressUpdate);
pCoreServices->initialize(pApp);
mainWindow.initialize();

// If startup produced a fatal error, then don't even start the
// Qt event loop.
if (ErrorDialogHandler::instance()->checkError()) {
exitCode = kFatalErrorOnStartupExitCode;
} else {
qDebug() << "Displaying main window";
mainWindow.show();

qDebug() << "Running Mixxx";
exitCode = pApp->exec();
}
}
return exitCode;
}

} // anonymous namespace
Expand Down

0 comments on commit b1cf8bc

Please sign in to comment.