Qt: only init new UI the first time it is about to be shown

This commit is contained in:
Brad Parker 2018-05-01 17:47:12 -04:00
parent f0d25d2fd9
commit e3712182bd
2 changed files with 13 additions and 3 deletions

View File

@ -95,7 +95,9 @@ AppHandler::~AppHandler()
void AppHandler::exit()
{
app_exiting = true;
qApp->closeAllWindows();
if (qApp)
qApp->closeAllWindows();
}
bool AppHandler::isExiting() const

View File

@ -131,7 +131,7 @@ void ui_companion_driver_init_first(void)
ui_companion = (ui_companion_driver_t*)ui_companion_init_first();
#ifdef HAVE_QT
if (settings->bools.desktop_menu_enable)
if (settings->bools.desktop_menu_enable && settings->bools.ui_companion_toggle)
{
ui_companion_qt_data = ui_companion_qt.init();
qt_is_inited = true;
@ -159,8 +159,16 @@ void ui_companion_driver_toggle(bool force)
#ifdef HAVE_QT
if (settings->bools.desktop_menu_enable)
if (ui_companion_qt.toggle)
{
if ((settings->bools.ui_companion_toggle || force) && !qt_is_inited)
{
ui_companion_qt_data = ui_companion_qt.init();
qt_is_inited = true;
}
if (qt_is_inited && ui_companion_qt.toggle)
ui_companion_qt.toggle(ui_companion_qt_data, force);
}
#endif
}