Destroy the main window before exiting the application

This ensures all widgets inside the window get destroyed too.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Thiago Macieira 2013-09-18 10:27:24 -05:00 committed by Dirk Hohndel
parent 7d9c1e9ee4
commit 0afe576a50

View file

@ -66,6 +66,7 @@ QString Translator::translate(const char *context, const char *sourceText,
} }
static QApplication *application = NULL; static QApplication *application = NULL;
static MainWindow *window = NULL;
int error_count; int error_count;
const char *existing_filename; const char *existing_filename;
@ -117,7 +118,7 @@ void init_ui(int *argcp, char ***argvp)
s.endGroup(); s.endGroup();
application->installTranslator(new Translator(application)); application->installTranslator(new Translator(application));
MainWindow *window = new MainWindow(); window = new MainWindow();
window->show(); window->show();
if (existing_filename && existing_filename[0] != '\0') if (existing_filename && existing_filename[0] != '\0')
window->setTitle(MWTF_FILENAME); window->setTitle(MWTF_FILENAME);
@ -134,6 +135,7 @@ void run_ui(void)
void exit_ui(void) void exit_ui(void)
{ {
delete window;
delete application; delete application;
if (existing_filename) if (existing_filename)
free((void *)existing_filename); free((void *)existing_filename);