Added logic and necessary functions to SDL port for new Lua emu.exit() function.

This commit is contained in:
mjbudd77 2020-12-12 06:59:07 -05:00
parent 3bab27ff76
commit 35720a78ce
6 changed files with 41 additions and 3 deletions

View File

@ -80,9 +80,10 @@ consoleWin_t::consoleWin_t(QWidget *parent)
g_config->getOption( "SDL.VideoDriver", &use_SDL_video ); g_config->getOption( "SDL.VideoDriver", &use_SDL_video );
errorMsgValid = false; closeRequested = false;
viewport_GL = NULL; errorMsgValid = false;
viewport_SDL = NULL; viewport_GL = NULL;
viewport_SDL = NULL;
if ( use_SDL_video ) if ( use_SDL_video )
{ {
@ -218,6 +219,11 @@ void consoleWin_t::closeEvent(QCloseEvent *event)
closeApp(); closeApp();
} }
void consoleWin_t::requestClose(void)
{
closeRequested = true;
}
void consoleWin_t::keyPressEvent(QKeyEvent *event) void consoleWin_t::keyPressEvent(QKeyEvent *event)
{ {
//printf("Key Press: 0x%x \n", event->key() ); //printf("Key Press: 0x%x \n", event->key() );
@ -2054,6 +2060,12 @@ void consoleWin_t::updatePeriodic(void)
errorMsgValid = false; errorMsgValid = false;
} }
if ( closeRequested )
{
closeApp();
closeRequested = false;
}
return; return;
} }

View File

@ -71,6 +71,8 @@ class consoleWin_t : public QMainWindow
QMutex *mutex; QMutex *mutex;
void requestClose(void);
void QueueErrorMsgWindow( const char *msg ); void QueueErrorMsgWindow( const char *msg );
int showListSelectDialog( const char *title, std::vector <std::string> &l ); int showListSelectDialog( const char *title, std::vector <std::string> &l );
@ -149,6 +151,7 @@ class consoleWin_t : public QMainWindow
std::string errorMsg; std::string errorMsg;
bool errorMsgValid; bool errorMsgValid;
bool closeRequested;
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);

View File

@ -383,6 +383,14 @@ bool fceuWrapperGameLoaded(void)
return (isloaded ? true : false); return (isloaded ? true : false);
} }
void fceuWrapperRequestAppExit(void)
{
if ( consoleWindow )
{
consoleWindow->requestClose();
}
}
static const char *DriverUsage = static const char *DriverUsage =
"Option Value Description\n" "Option Value Description\n"
"--pal {0|1} Use PAL timing.\n" "--pal {0|1} Use PAL timing.\n"

View File

@ -36,4 +36,5 @@ int fceuWrapperSoftReset(void);
int fceuWrapperHardReset(void); int fceuWrapperHardReset(void);
int fceuWrapperTogglePause(void); int fceuWrapperTogglePause(void);
bool fceuWrapperGameLoaded(void); bool fceuWrapperGameLoaded(void);
void fceuWrapperRequestAppExit(void);

View File

@ -533,6 +533,10 @@ void FCEUD_TraceInstruction() {
return; return;
} }
void fceuWrapperRequestAppExit(void)
{
gtk_gui_run = false;
}
#ifdef _GTK #ifdef _GTK
int noGui = 0; int noGui = 0;

View File

@ -57,6 +57,7 @@ extern TASEDITOR_LUA taseditor_lua;
#else #else
int LoadGame(const char *path, bool silent = false); int LoadGame(const char *path, bool silent = false);
int reloadLastGame(void); int reloadLastGame(void);
void fceuWrapperRequestAppExit(void);
#endif #endif
#endif #endif
@ -6205,8 +6206,17 @@ void FCEU_LuaFrameBoundary()
FCEU_LuaOnStop(); FCEU_LuaOnStop();
} }
#if defined(__linux) || defined(__APPLE__)
if (exitScheduled)
{ // This function does not exit immediately,
// it requests for the application to exit when next convenient.
fceuWrapperRequestAppExit();
exitScheduled = FALSE;
}
#else
if (exitScheduled) if (exitScheduled)
DoFCEUExit(); DoFCEUExit();
#endif
} }
/** /**