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

View File

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

View File

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

View File

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

View File

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

View File

@ -57,6 +57,7 @@ extern TASEDITOR_LUA taseditor_lua;
#else
int LoadGame(const char *path, bool silent = false);
int reloadLastGame(void);
void fceuWrapperRequestAppExit(void);
#endif
#endif
@ -6205,8 +6206,17 @@ void FCEU_LuaFrameBoundary()
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)
DoFCEUExit();
#endif
}
/**