1
0
Fork 0

GUI: better thread-safety in the MainWindow + fixed a bug where you could close the 'Closing debugger...' window

This commit is contained in:
Mr. eXoDia 2014-09-07 23:10:27 +02:00
parent acdfe928e1
commit 20d8903b22
4 changed files with 13 additions and 7 deletions

View File

@ -14,3 +14,8 @@ CloseDialog::~CloseDialog()
{ {
delete ui; delete ui;
} }
void CloseDialog::closeEvent(QCloseEvent* event)
{
event->ignore();
}

View File

@ -2,6 +2,7 @@
#define CLOSEDIALOG_H #define CLOSEDIALOG_H
#include <QDialog> #include <QDialog>
#include <QCloseEvent>
namespace Ui namespace Ui
{ {
@ -15,6 +16,7 @@ class CloseDialog : public QDialog
public: public:
explicit CloseDialog(QWidget* parent = 0); explicit CloseDialog(QWidget* parent = 0);
~CloseDialog(); ~CloseDialog();
void closeEvent(QCloseEvent* event);
private: private:
Ui::CloseDialog* ui; Ui::CloseDialog* ui;

View File

@ -204,10 +204,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
DWORD WINAPI MainWindow::closeThread(void* ptr) DWORD WINAPI MainWindow::closeThread(void* ptr)
{ {
static bool closing = false;
if(closing)
return 0;
closing = true;
DbgExit(); DbgExit();
MainWindow* mainWindow = (MainWindow*)ptr; MainWindow* mainWindow = (MainWindow*)ptr;
mainWindow->bClose = true; mainWindow->bClose = true;
@ -220,7 +216,12 @@ void MainWindow::closeEvent(QCloseEvent* event)
hide(); //hide main window hide(); //hide main window
mCloseDialog->show(); mCloseDialog->show();
mCloseDialog->setFocus(); mCloseDialog->setFocus();
static bool bExecuteThread = true;
if(bExecuteThread)
{
bExecuteThread = false;
CloseHandle(CreateThread(0, 0, closeThread, this, 0, 0)); CloseHandle(CreateThread(0, 0, closeThread, this, 0, 0));
}
if(bClose) if(bClose)
event->accept(); event->accept();
else else

View File

@ -86,5 +86,3 @@ int main(int argc, char* argv[])
mConfiguration->save(); //save config on exit mConfiguration->save(); //save config on exit
return result; return result;
} }