diff --git a/src/musredit_qt6/mupp/mupp.cpp b/src/musredit_qt6/mupp/mupp.cpp index ef88569b..af5e7dff 100644 --- a/src/musredit_qt6/mupp/mupp.cpp +++ b/src/musredit_qt6/mupp/mupp.cpp @@ -548,11 +548,11 @@ int main(int argc, char *argv[]) if (script.size() > 0) { // script guiFlag = false; } - QCoreApplication *app = createApplication(argc, argv, guiFlag); + QScopedPointer app(createApplication(argc, argv, guiFlag)); std::unique_ptr gui; std::unique_ptr mupp_script; - if (qobject_cast(app)) { // GUI + if (qobject_cast(app.get())) { // GUI gui = std::make_unique(fln); if (gui == nullptr) { std::cerr << std::endl; @@ -565,8 +565,8 @@ int main(int argc, char *argv[]) gui->resize( 800, 500 ); gui->show(); - app->connect( app, SIGNAL( lastWindowClosed() ), app, SLOT( quit() ) ); - app->connect( app, SIGNAL( aboutToQuit() ), gui.get(), SLOT( aboutToQuit() ) ); + app.get()->connect( app.get(), SIGNAL( lastWindowClosed() ), app.get(), SLOT( quit() ) ); + app.get()->connect( app.get(), SIGNAL( aboutToQuit() ), gui.get(), SLOT( aboutToQuit() ) ); } else { // scripting mupp_script = std::make_unique(script); if (mupp_script == nullptr) { @@ -578,7 +578,7 @@ int main(int argc, char *argv[]) } // This will cause the application to exit when the task signals finished. - QObject::connect( mupp_script.get(), SIGNAL( finished() ), app, SLOT( quit() ) ); + QObject::connect( mupp_script.get(), SIGNAL( finished() ), app.get(), SLOT( quit() ) ); // This will run the task from the application event loop. QTimer::singleShot(0, mupp_script.get(), SLOT( executeScript() ) );