mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-15 07:44:10 +00:00
Make application quit on main window close
This causes the main window to signal the application to exit and delete its own pointer on close. This fixes an issue where apparently some windows that aren't explicitly connected to the main window would be left open when the main window was closed because by default Qt will only exit when all windows have been closed. Because it deletes its own pointer, instead of storing it in a std::unique_ptr, use a QPointer because it has an internal mechanism for automatically tracking QObject deletion even if the deletion was not done on the QPointer itself, where as unique_ptr does not have that functionality. In other words, if the pointer is deleted elsewhere for whatever reason, the QPointer will still set that internal pointer value to null. (message and minor modificiations by Jim)
This commit is contained in:
parent
6db316398b
commit
dfa2d992c1
|
@ -261,7 +261,11 @@ bool OBSApp::OBSInit()
|
|||
config_save(globalConfig);
|
||||
}
|
||||
|
||||
mainWindow = move(unique_ptr<OBSBasic>(new OBSBasic()));
|
||||
mainWindow = new OBSBasic();
|
||||
|
||||
mainWindow->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
connect(mainWindow, SIGNAL(destroyed()), this, SLOT(quit()));
|
||||
|
||||
mainWindow->OBSInit();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
#include <QPointer>
|
||||
#include <util/lexer.h>
|
||||
#include <util/util.hpp>
|
||||
#include <string>
|
||||
|
@ -56,7 +57,7 @@ private:
|
|||
std::string locale;
|
||||
ConfigFile globalConfig;
|
||||
TextLookup textLookup;
|
||||
std::unique_ptr<OBSMainWindow> mainWindow;
|
||||
QPointer<OBSMainWindow> mainWindow;
|
||||
|
||||
bool InitGlobalConfig();
|
||||
bool InitGlobalConfigDefaults();
|
||||
|
@ -68,7 +69,7 @@ public:
|
|||
void AppInit();
|
||||
bool OBSInit();
|
||||
|
||||
inline QMainWindow *GetMainWindow() const {return mainWindow.get();}
|
||||
inline QMainWindow *GetMainWindow() const {return mainWindow.data();}
|
||||
|
||||
inline config_t GlobalConfig() const {return globalConfig;}
|
||||
|
||||
|
|
Loading…
Reference in a new issue