switched from raw to QScopedPointer pointer in mupp.cpp.

This commit is contained in:
suter_a 2025-04-01 14:10:59 +02:00
parent e26fa4eea2
commit e5ff0fa743

View File

@ -548,11 +548,11 @@ int main(int argc, char *argv[])
if (script.size() > 0) { // script if (script.size() > 0) { // script
guiFlag = false; guiFlag = false;
} }
QCoreApplication *app = createApplication(argc, argv, guiFlag); QScopedPointer<QCoreApplication> app(createApplication(argc, argv, guiFlag));
std::unique_ptr<PmuppGui> gui; std::unique_ptr<PmuppGui> gui;
std::unique_ptr<PmuppScript> mupp_script; std::unique_ptr<PmuppScript> mupp_script;
if (qobject_cast<QApplication *>(app)) { // GUI if (qobject_cast<QApplication *>(app.get())) { // GUI
gui = std::make_unique<PmuppGui>(fln); gui = std::make_unique<PmuppGui>(fln);
if (gui == nullptr) { if (gui == nullptr) {
std::cerr << std::endl; std::cerr << std::endl;
@ -565,8 +565,8 @@ int main(int argc, char *argv[])
gui->resize( 800, 500 ); gui->resize( 800, 500 );
gui->show(); gui->show();
app->connect( app, SIGNAL( lastWindowClosed() ), app, SLOT( quit() ) ); app.get()->connect( app.get(), SIGNAL( lastWindowClosed() ), app.get(), SLOT( quit() ) );
app->connect( app, SIGNAL( aboutToQuit() ), gui.get(), SLOT( aboutToQuit() ) ); app.get()->connect( app.get(), SIGNAL( aboutToQuit() ), gui.get(), SLOT( aboutToQuit() ) );
} else { // scripting } else { // scripting
mupp_script = std::make_unique<PmuppScript>(script); mupp_script = std::make_unique<PmuppScript>(script);
if (mupp_script == nullptr) { 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. // 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. // This will run the task from the application event loop.
QTimer::singleShot(0, mupp_script.get(), SLOT( executeScript() ) ); QTimer::singleShot(0, mupp_script.get(), SLOT( executeScript() ) );