diff --git a/src/drivers/Qt/CheatsConf.cpp b/src/drivers/Qt/CheatsConf.cpp index 8160cb73..1f53e556 100644 --- a/src/drivers/Qt/CheatsConf.cpp +++ b/src/drivers/Qt/CheatsConf.cpp @@ -416,12 +416,22 @@ GuiCheatsDialog_t::~GuiCheatsDialog_t(void) } wasPausedByCheats = false; + printf("Destroy Cheat Window Event\n"); +} +//---------------------------------------------------------------------------- +void GuiCheatsDialog_t::closeEvent(QCloseEvent *event) +{ + printf("Cheat Close Window Event\n"); + done(0); + deleteLater(); + event->accept(); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::closeWindow(void) { //printf("Close Window\n"); done(0); + deleteLater(); } //---------------------------------------------------------------------------- int GuiCheatsDialog_t::addSearchResult (uint32_t a, uint8_t last, uint8_t current) diff --git a/src/drivers/Qt/CheatsConf.h b/src/drivers/Qt/CheatsConf.h index d687cb70..fbc46a24 100644 --- a/src/drivers/Qt/CheatsConf.h +++ b/src/drivers/Qt/CheatsConf.h @@ -33,6 +33,7 @@ class GuiCheatsDialog_t : public QDialog int activeCheatListCB (char *name, uint32 a, uint8 v, int c, int s, int type, void *data); protected: + void closeEvent(QCloseEvent *event); QGroupBox *actCheatFrame; QGroupBox *cheatSearchFrame; diff --git a/src/drivers/Qt/ConsoleSoundConf.cpp b/src/drivers/Qt/ConsoleSoundConf.cpp index 9932a7ca..b02c2253 100644 --- a/src/drivers/Qt/ConsoleSoundConf.cpp +++ b/src/drivers/Qt/ConsoleSoundConf.cpp @@ -1,5 +1,7 @@ // ConsoleSoundConf.cpp // +#include + #include "../../fceu.h" #include "../../driver.h" #include "Qt/ConsoleSoundConf.h" @@ -217,7 +219,22 @@ ConsoleSndConfDialog_t::ConsoleSndConfDialog_t(QWidget *parent) //---------------------------------------------------- ConsoleSndConfDialog_t::~ConsoleSndConfDialog_t(void) { - + printf("Destroy Sound Config Window\n"); +} +//---------------------------------------------------------------------------- +void ConsoleSndConfDialog_t::closeEvent(QCloseEvent *event) +{ + printf("Sound Config Close Window Event\n"); + done(0); + deleteLater(); + event->accept(); +} +//---------------------------------------------------------------------------- +void ConsoleSndConfDialog_t::closeWindow(void) +{ + //printf("Sound Close Window\n"); + done(0); + deleteLater(); } //---------------------------------------------------- void ConsoleSndConfDialog_t::setCheckBoxFromProperty( QCheckBox *cbx, const char *property ) diff --git a/src/drivers/Qt/ConsoleSoundConf.h b/src/drivers/Qt/ConsoleSoundConf.h index 40e86d2a..40f8de1f 100644 --- a/src/drivers/Qt/ConsoleSoundConf.h +++ b/src/drivers/Qt/ConsoleSoundConf.h @@ -25,6 +25,8 @@ class ConsoleSndConfDialog_t : public QDialog ~ConsoleSndConfDialog_t(void); protected: + void closeEvent(QCloseEvent *event); + QCheckBox *enaChkbox; QCheckBox *enaLowPass; QCheckBox *swapDutyChkbox; @@ -44,6 +46,7 @@ class ConsoleSndConfDialog_t : public QDialog void setSliderFromProperty( QSlider *slider, QLabel *lbl, const char *property ); private slots: + void closeWindow(void); void bufSizeChanged(int value); void volumeChanged(int value); void triangleChanged(int value); diff --git a/src/drivers/Qt/ConsoleVideoConf.cpp b/src/drivers/Qt/ConsoleVideoConf.cpp index 44f4116b..1da2f639 100644 --- a/src/drivers/Qt/ConsoleVideoConf.cpp +++ b/src/drivers/Qt/ConsoleVideoConf.cpp @@ -1,5 +1,7 @@ // ConsoleVideoConf.cpp // +#include + #include "../../fceu.h" #include "Qt/main.h" #include "Qt/dface.h" @@ -105,7 +107,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent) button = new QPushButton( tr("Close") ); hbox1->addWidget( button ); - connect(button, SIGNAL(clicked()), this, SLOT(closewindow(void)) ); + connect(button, SIGNAL(clicked()), this, SLOT(closeWindow(void)) ); main_vbox->addLayout( hbox1 ); @@ -115,8 +117,24 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent) //---------------------------------------------------- ConsoleVideoConfDialog_t::~ConsoleVideoConfDialog_t(void) { + printf("Destroy Video Config Window\n"); } +//---------------------------------------------------------------------------- +void ConsoleVideoConfDialog_t::closeEvent(QCloseEvent *event) +{ + printf("Video Config Close Window Event\n"); + done(0); + deleteLater(); + event->accept(); +} +//---------------------------------------------------------------------------- +void ConsoleVideoConfDialog_t::closeWindow(void) +{ + //printf("Video Config Close Window\n"); + done(0); + deleteLater(); +} //---------------------------------------------------- void ConsoleVideoConfDialog_t::resetVideo(void) { @@ -237,8 +255,3 @@ void ConsoleVideoConfDialog_t::applyChanges( void ) resetVideo(); } //---------------------------------------------------- -void ConsoleVideoConfDialog_t::closewindow( void ) -{ - done(0); -} -//---------------------------------------------------- diff --git a/src/drivers/Qt/ConsoleVideoConf.h b/src/drivers/Qt/ConsoleVideoConf.h index 00b38d86..73d86e76 100644 --- a/src/drivers/Qt/ConsoleVideoConf.h +++ b/src/drivers/Qt/ConsoleVideoConf.h @@ -25,6 +25,8 @@ class ConsoleVideoConfDialog_t : public QDialog ~ConsoleVideoConfDialog_t(void); protected: + void closeEvent(QCloseEvent *bar); + QComboBox *driverSelect; QComboBox *regionSelect; QCheckBox *gl_LF_chkBox; @@ -40,6 +42,9 @@ class ConsoleVideoConfDialog_t : public QDialog void resetVideo(void); + public slots: + void closeWindow(void); + private slots: void use_new_PPU_changed( int value ); void frameskip_changed( int value ); @@ -49,7 +54,6 @@ class ConsoleVideoConfDialog_t : public QDialog void regionChanged(int index); void driverChanged(int index); void applyChanges( void ); - void closewindow( void ); }; diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 5e16845b..1dd24854 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -75,8 +75,6 @@ consoleWin_t::consoleWin_t(QWidget *parent) emulatorThread->start(); - gamePadConfWin = NULL; - } consoleWin_t::~consoleWin_t(void) @@ -85,10 +83,8 @@ consoleWin_t::~consoleWin_t(void) gameTimer->stop(); - if ( gamePadConfWin != NULL ) - { - gamePadConfWin->closeWindow(); - } + closeGamePadConfWindow(); + fceuWrapperLock(); fceuWrapperClose(); fceuWrapperUnLock(); @@ -144,11 +140,8 @@ void consoleWin_t::QueueErrorMsgWindow( const char *msg ) void consoleWin_t::closeEvent(QCloseEvent *event) { //printf("Main Window Close Event\n"); - if ( gamePadConfWin != NULL ) - { - //printf("Command Game Pad Close\n"); - gamePadConfWin->closeWindow(); - } + closeGamePadConfWindow(); + event->accept(); closeApp(); @@ -901,9 +894,9 @@ void consoleWin_t::loadLua(void) luaCtrlWin = new LuaControlDialog_t(this); luaCtrlWin->show(); - luaCtrlWin->exec(); + //luaCtrlWin->exec(); - delete luaCtrlWin; + //delete luaCtrlWin; //printf("Lua Control Window Destroyed\n"); #endif @@ -911,20 +904,9 @@ void consoleWin_t::loadLua(void) void consoleWin_t::openGamePadConfWin(void) { - if ( gamePadConfWin != NULL ) - { - printf("GamePad Config Window Already Open\n"); - return; - } //printf("Open GamePad Config Window\n"); - gamePadConfWin = new GamePadConfDialog_t(this); - gamePadConfWin->show(); - gamePadConfWin->exec(); - - delete gamePadConfWin; - gamePadConfWin = NULL; - //printf("GamePad Config Window Destroyed\n"); + openGamePadConfWindow(this); } void consoleWin_t::openGameSndConfWin(void) @@ -936,9 +918,9 @@ void consoleWin_t::openGameSndConfWin(void) sndConfWin = new ConsoleSndConfDialog_t(this); sndConfWin->show(); - sndConfWin->exec(); + //sndConfWin->exec(); - delete sndConfWin; + //delete sndConfWin; //printf("Sound Config Window Destroyed\n"); } @@ -952,9 +934,9 @@ void consoleWin_t::openGameVideoConfWin(void) vidConfWin = new ConsoleVideoConfDialog_t(this); vidConfWin->show(); - vidConfWin->exec(); + //vidConfWin->exec(); - delete vidConfWin; + //delete vidConfWin; //printf("Video Config Window Destroyed\n"); } @@ -968,9 +950,9 @@ void consoleWin_t::openHotkeyConfWin(void) hkConfWin = new HotKeyConfDialog_t(this); hkConfWin->show(); - hkConfWin->exec(); + //hkConfWin->exec(); - delete hkConfWin; + //delete hkConfWin; //printf("Hotkey Config Window Destroyed\n"); } @@ -984,9 +966,9 @@ void consoleWin_t::openPaletteConfWin(void) paletteConfWin = new PaletteConfDialog_t(this); paletteConfWin->show(); - paletteConfWin->exec(); + //paletteConfWin->exec(); - delete paletteConfWin; + //delete paletteConfWin; //printf("Palette Config Window Destroyed\n"); } @@ -1000,9 +982,9 @@ void consoleWin_t::openGuiConfWin(void) guiConfWin = new GuiConfDialog_t(this); guiConfWin->show(); - guiConfWin->exec(); + //guiConfWin->exec(); - delete guiConfWin; + //delete guiConfWin; //printf("GUI Config Window Destroyed\n"); } @@ -1016,9 +998,9 @@ void consoleWin_t::openCheats(void) cheatWin = new GuiCheatsDialog_t(this); cheatWin->show(); - cheatWin->exec(); + //cheatWin->exec(); - delete cheatWin; + //delete cheatWin; //printf("GUI Cheat Window Destroyed\n"); } @@ -1032,9 +1014,9 @@ void consoleWin_t::openHexEditor(void) hexEditWin = new HexEditorDialog_t(this); hexEditWin->show(); - hexEditWin->exec(); + //hexEditWin->exec(); - delete hexEditWin; + //delete hexEditWin; //printf("GUI Hex Editor Window Destroyed\n"); } @@ -1412,9 +1394,9 @@ void consoleWin_t::aboutFCEUX(void) aboutWin = new AboutWindow(this); aboutWin->show(); - aboutWin->exec(); + //aboutWin->exec(); - delete aboutWin; + //delete aboutWin; //printf("About Window Destroyed\n"); return; diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h index d2515407..eb5fdddb 100644 --- a/src/drivers/Qt/ConsoleWindow.h +++ b/src/drivers/Qt/ConsoleWindow.h @@ -99,8 +99,6 @@ class consoleWin_t : public QMainWindow emulatorThread_t *emulatorThread; - GamePadConfDialog_t *gamePadConfWin; - std::string errorMsg; bool errorMsgValid; diff --git a/src/drivers/Qt/GamePadConf.cpp b/src/drivers/Qt/GamePadConf.cpp index 03df69bb..2847a01c 100644 --- a/src/drivers/Qt/GamePadConf.cpp +++ b/src/drivers/Qt/GamePadConf.cpp @@ -36,6 +36,30 @@ struct GamePadConfigLocalData_t static GamePadConfigLocalData_t lcl[GAMEPAD_NUM_DEVICES]; +static GamePadConfDialog_t *gamePadConfWin = NULL; + +//---------------------------------------------------- +int openGamePadConfWindow( QWidget *parent ) +{ + if ( gamePadConfWin != NULL ) + { + return -1; + } + gamePadConfWin = new GamePadConfDialog_t(parent); + + gamePadConfWin->show(); + + return 0; +} +//---------------------------------------------------- +int closeGamePadConfWindow(void) +{ + if ( gamePadConfWin != NULL ) + { + gamePadConfWin->closeWindow(); + } + return 0; +} //---------------------------------------------------- GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent) : QDialog( parent ) @@ -56,6 +80,8 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent) std::string prefix; char stmp[256]; + gamePadConfWin = this; + // Ensure that joysticks are enabled, no harm calling init again. InitJoysticks(); @@ -279,6 +305,9 @@ GamePadConfDialog_t::~GamePadConfDialog_t(void) { inputTimer->stop(); buttonConfigStatus = 0; + gamePadConfWin = NULL; + + printf("GamePad Window Deleted\n"); } void GamePadConfDialog_t::keyPressEvent(QKeyEvent *event) { @@ -500,6 +529,7 @@ void GamePadConfDialog_t::closeEvent(QCloseEvent *event) printf("GamePad Close Window Event\n"); buttonConfigStatus = 0; done(0); + deleteLater(); event->accept(); } //---------------------------------------------------- @@ -510,6 +540,7 @@ void GamePadConfDialog_t::closeWindow(void) printf("Close Window\n"); buttonConfigStatus = 0; done(0); + deleteLater(); } //---------------------------------------------------- void GamePadConfDialog_t::changeButton0(void) diff --git a/src/drivers/Qt/GamePadConf.h b/src/drivers/Qt/GamePadConf.h index 5efafeb3..7d5fabe2 100644 --- a/src/drivers/Qt/GamePadConf.h +++ b/src/drivers/Qt/GamePadConf.h @@ -99,3 +99,7 @@ class GamePadConfDialog_t : public QDialog void updatePeriodic(void); }; + +int openGamePadConfWindow( QWidget *parent ); + +int closeGamePadConfWindow(void); diff --git a/src/drivers/Qt/GuiConf.cpp b/src/drivers/Qt/GuiConf.cpp index 256aacb2..0eab340b 100644 --- a/src/drivers/Qt/GuiConf.cpp +++ b/src/drivers/Qt/GuiConf.cpp @@ -46,13 +46,22 @@ GuiConfDialog_t::GuiConfDialog_t(QWidget *parent) //---------------------------------------------------- GuiConfDialog_t::~GuiConfDialog_t(void) { - + printf("Destroy GUI Config Close Window\n"); +} +//---------------------------------------------------------------------------- +void GuiConfDialog_t::closeEvent(QCloseEvent *event) +{ + printf("GUI Config Close Window Event\n"); + done(0); + deleteLater(); + event->accept(); } //---------------------------------------------------- void GuiConfDialog_t::closeWindow(void) { //printf("Close Window\n"); done(0); + deleteLater(); } //---------------------------------------------------- void GuiConfDialog_t::useNativeFileDialogChanged(int state) diff --git a/src/drivers/Qt/GuiConf.h b/src/drivers/Qt/GuiConf.h index 032dd4db..aa0bcc84 100644 --- a/src/drivers/Qt/GuiConf.h +++ b/src/drivers/Qt/GuiConf.h @@ -26,6 +26,8 @@ class GuiConfDialog_t : public QDialog ~GuiConfDialog_t(void); protected: + void closeEvent(QCloseEvent *event); + QCheckBox *useNativeFileDialog; QCheckBox *useNativeMenuBar; private: diff --git a/src/drivers/Qt/HexEditor.cpp b/src/drivers/Qt/HexEditor.cpp index 9ecec382..aefea213 100644 --- a/src/drivers/Qt/HexEditor.cpp +++ b/src/drivers/Qt/HexEditor.cpp @@ -468,6 +468,7 @@ HexEditorDialog_t::HexEditorDialog_t(QWidget *parent) //---------------------------------------------------------------------------- HexEditorDialog_t::~HexEditorDialog_t(void) { + printf("Hex Editor Deleted\n"); periodicTimer->stop(); } //---------------------------------------------------------------------------- @@ -487,10 +488,19 @@ void HexEditorDialog_t::populateBookmarkMenu(void) bookmarkMenu->addSeparator(); } //---------------------------------------------------------------------------- +void HexEditorDialog_t::closeEvent(QCloseEvent *event) +{ + printf("Hex Editor Close Window Event\n"); + done(0); + deleteLater(); + event->accept(); +} +//---------------------------------------------------------------------------- void HexEditorDialog_t::closeWindow(void) { //printf("Close Window\n"); done(0); + deleteLater(); } //---------------------------------------------------------------------------- void HexEditorDialog_t::pickForeGroundColor(void) diff --git a/src/drivers/Qt/HexEditor.h b/src/drivers/Qt/HexEditor.h index b21a5f82..a2f7079a 100644 --- a/src/drivers/Qt/HexEditor.h +++ b/src/drivers/Qt/HexEditor.h @@ -138,6 +138,7 @@ class HexEditorDialog_t : public QDialog ~HexEditorDialog_t(void); protected: + void closeEvent(QCloseEvent *bar); void gotoAddress(int newAddr); void populateBookmarkMenu(void); diff --git a/src/drivers/Qt/HotKeyConf.cpp b/src/drivers/Qt/HotKeyConf.cpp index 13c33f1c..d1db2131 100644 --- a/src/drivers/Qt/HotKeyConf.cpp +++ b/src/drivers/Qt/HotKeyConf.cpp @@ -7,6 +7,7 @@ #include #include +#include #include "Qt/main.h" #include "Qt/dface.h" @@ -68,13 +69,22 @@ HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent) //---------------------------------------------------------------------------- HotKeyConfDialog_t::~HotKeyConfDialog_t(void) { - + printf("Destroy Hot Key Config Window\n"); +} +//---------------------------------------------------------------------------- +void HotKeyConfDialog_t::closeEvent(QCloseEvent *event) +{ + printf("Hot Key Close Window Event\n"); + done(0); + deleteLater(); + event->accept(); } //---------------------------------------------------------------------------- void HotKeyConfDialog_t::closeWindow(void) { //printf("Close Window\n"); done(0); + deleteLater(); } //---------------------------------------------------------------------------- void HotKeyConfDialog_t::assignHotkey(QKeyEvent *event) diff --git a/src/drivers/Qt/HotKeyConf.h b/src/drivers/Qt/HotKeyConf.h index cba35cee..bf9c8a8f 100644 --- a/src/drivers/Qt/HotKeyConf.h +++ b/src/drivers/Qt/HotKeyConf.h @@ -27,6 +27,7 @@ class HotKeyConfDialog_t : public QDialog ~HotKeyConfDialog_t(void); protected: + void closeEvent(QCloseEvent *event); void keyPressEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event); void assignHotkey(QKeyEvent *event); diff --git a/src/drivers/Qt/LuaControl.cpp b/src/drivers/Qt/LuaControl.cpp index 28e1bcff..2aa40271 100644 --- a/src/drivers/Qt/LuaControl.cpp +++ b/src/drivers/Qt/LuaControl.cpp @@ -102,6 +102,8 @@ LuaControlDialog_t::~LuaControlDialog_t(void) { std::list ::iterator it; + printf("Destroy Lua Control Window\n"); + for (it = winList.begin(); it != winList.end(); it++) { if ( (*it) == this ) @@ -113,10 +115,19 @@ LuaControlDialog_t::~LuaControlDialog_t(void) } } //---------------------------------------------------- +void LuaControlDialog_t::closeEvent(QCloseEvent *event) +{ + printf("Lua Control Close Window Event\n"); + done(0); + deleteLater(); + event->accept(); +} +//---------------------------------------------------- void LuaControlDialog_t::closeWindow(void) { - //printf("Close Window\n"); + //printf("Lua Control Close Window\n"); done(0); + deleteLater(); } //---------------------------------------------------- void LuaControlDialog_t::openLuaScriptFile(void) diff --git a/src/drivers/Qt/LuaControl.h b/src/drivers/Qt/LuaControl.h index 824f52fa..522e686a 100644 --- a/src/drivers/Qt/LuaControl.h +++ b/src/drivers/Qt/LuaControl.h @@ -29,6 +29,8 @@ class LuaControlDialog_t : public QDialog void refreshState(void); protected: + void closeEvent(QCloseEvent *bar); + QLineEdit *scriptPath; QLineEdit *scriptArgs; QPushButton *browseButton; diff --git a/src/drivers/Qt/PaletteConf.cpp b/src/drivers/Qt/PaletteConf.cpp index 2adbe66e..d799b8ca 100644 --- a/src/drivers/Qt/PaletteConf.cpp +++ b/src/drivers/Qt/PaletteConf.cpp @@ -148,13 +148,22 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent) //---------------------------------------------------- PaletteConfDialog_t::~PaletteConfDialog_t(void) { - + printf("Destroy Palette Config Window\n"); +} +//---------------------------------------------------------------------------- +void PaletteConfDialog_t::closeEvent(QCloseEvent *event) +{ + printf("Palette Config Close Window Event\n"); + done(0); + deleteLater(); + event->accept(); } //---------------------------------------------------- void PaletteConfDialog_t::closeWindow(void) { //printf("Close Window\n"); done(0); + deleteLater(); } //---------------------------------------------------- void PaletteConfDialog_t::hueChanged(int v) diff --git a/src/drivers/Qt/PaletteConf.h b/src/drivers/Qt/PaletteConf.h index 494d78aa..5b28d9c0 100644 --- a/src/drivers/Qt/PaletteConf.h +++ b/src/drivers/Qt/PaletteConf.h @@ -26,6 +26,8 @@ class PaletteConfDialog_t : public QDialog ~PaletteConfDialog_t(void); protected: + void closeEvent(QCloseEvent *event); + QLineEdit *custom_palette_path; QCheckBox *useCustom; QCheckBox *GrayScale;