Keep application in {} block to force deletion of the UI

This commit is contained in:
Klaus Basan
2020-03-30 20:32:23 +02:00
committed by Mat Sutcliffe
parent 2cb10c1835
commit b125d474c7

View File

@@ -6,16 +6,20 @@
* or distributed except according to the terms contained in the LICENSE file. * or distributed except according to the terms contained in the LICENSE file.
*/ */
#include "swiftguistd.h"
#include "swiftguistdapplication.h"
#include "blackgui/enableforframelesswindow.h" #include "blackgui/enableforframelesswindow.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackgui/guiutility.h"
#include "blackmisc/audio/audioutils.h" #include "blackmisc/audio/audioutils.h"
#include "blackmisc/directoryutils.h" #include "blackmisc/directoryutils.h"
#include "blackmisc/crashhandler.h" #include "blackmisc/crashhandler.h"
#include "blackmisc/appstarttime.h" #include "blackmisc/appstarttime.h"
#include "swiftguistd.h"
#include "swiftguistdapplication.h"
#include <stdlib.h> #include <stdlib.h>
#include <iostream>
#include <QApplication> #include <QApplication>
#include <QTextStream> #include <QTextStream>
@@ -33,6 +37,11 @@ int main(int argc, char *argv[])
// initWindowsAudioDevices(); // initWindowsAudioDevices();
CCrashHandler::instance()->init(); CCrashHandler::instance()->init();
// at shutdown the whole application will be "deleted" outside the block
// that should already delete all widgets
int r = 0;
{
CSwiftGuiStdApplication a; // application with contexts CSwiftGuiStdApplication a; // application with contexts
a.setSignalStartupAutomatically(false); // application will signal startup on its own a.setSignalStartupAutomatically(false); // application will signal startup on its own
a.splashScreen(CIcons::swift256()); a.splashScreen(CIcons::swift256());
@@ -48,14 +57,8 @@ int main(int argc, char *argv[])
// show window // show window
CEnableForFramelessWindow::WindowMode windowMode = a.getWindowMode(); CEnableForFramelessWindow::WindowMode windowMode = a.getWindowMode();
SwiftGuiStd w(windowMode); SwiftGuiStd w(windowMode);
w.show(); r = a.exec();
}
const int r = a.exec();
// log we are really closing
QTextStream ts(stdout);
ts << "swift is closing now ......\n";
ts.flush();
// bye // bye
return r; return r;