Merge pull request #148 from mjbudd77/master

GTK GUI Quit Logic Change
This commit is contained in:
mjbudd77 2020-08-05 21:02:24 -04:00 committed by GitHub
commit 75f04fd1df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 17 deletions

View File

@ -67,6 +67,7 @@ void toggleSound (GtkWidget * check, gpointer data);
void loadGame (void); void loadGame (void);
void closeGame (void); void closeGame (void);
extern Config *g_config; extern Config *g_config;
extern bool gtk_gui_run;
GtkWidget *MainWindow = NULL; GtkWidget *MainWindow = NULL;
GtkWidget *evbox = NULL; GtkWidget *evbox = NULL;
@ -1452,21 +1453,25 @@ void openSoundConfig (void)
void quit (void) void quit (void)
{ {
// manually flush GTK event queue // Set gui run flag to false to allow main gui loop
while (gtk_events_pending ()) // to exit normally.
gtk_main_iteration_do (FALSE); gtk_gui_run = false;
// this is not neccesary to be explicitly called // // manually flush GTK event queue
// it raises a GTK-Critical when its called // while (gtk_events_pending ())
//gtk_main_quit(); // gtk_main_iteration_do (FALSE);
FCEUI_CloseGame (); //
FCEUI_Kill (); // // this is not neccesary to be explicitly called
// LoadGame() checks for an IP and if it finds one begins a network session // // it raises a GTK-Critical when its called
// clear the NetworkIP field so this doesn't happen unintentionally // //gtk_main_quit();
g_config->setOption ("SDL.NetworkIP", ""); // FCEUI_CloseGame ();
g_config->save (); // FCEUI_Kill ();
SDL_Quit (); // // LoadGame() checks for an IP and if it finds one begins a network session
exit (0); // // clear the NetworkIP field so this doesn't happen unintentionally
// g_config->setOption ("SDL.NetworkIP", "");
// g_config->save ();
// SDL_Quit ();
// exit (0);
} }
const char *Authors[] = { const char *Authors[] = {

View File

@ -57,8 +57,8 @@ extern bool bindSavestate, frameAdvanceLagSkip, lagCounterDisplay;
/* UsrInputType[] is user-specified. CurInputType[] is current /* UsrInputType[] is user-specified. CurInputType[] is current
(game loading can override user settings) (game loading can override user settings)
*/ */
static int UsrInputType[NUM_INPUT_DEVICES]; static int UsrInputType[NUM_INPUT_DEVICES] = { SI_GAMEPAD, SI_GAMEPAD, SI_NONE };
static int CurInputType[NUM_INPUT_DEVICES]; static int CurInputType[NUM_INPUT_DEVICES] = { SI_GAMEPAD, SI_GAMEPAD, SI_NONE };
static int cspec = 0; static int cspec = 0;
extern int gametype; extern int gametype;

View File

@ -57,6 +57,7 @@ extern bool MaxSpeed;
int isloaded; int isloaded;
bool turbo = false; bool turbo = false;
bool gtk_gui_run = true;
int closeFinishedMovie = 0; int closeFinishedMovie = 0;
@ -910,7 +911,7 @@ int main(int argc, char *argv[])
#ifdef _GTK #ifdef _GTK
if(noGui == 0) if(noGui == 0)
{ {
while(1) while ( gtk_gui_run )
{ {
if(GameInfo) if(GameInfo)
{ {
@ -926,6 +927,7 @@ int main(int argc, char *argv[])
gtk_main_iteration_do(FALSE); gtk_main_iteration_do(FALSE);
} }
} }
printf("Exiting GUI Main Loop...\n");
} }
else else
{ {
@ -938,11 +940,20 @@ int main(int argc, char *argv[])
DoFun(frameskip, periodic_saves); DoFun(frameskip, periodic_saves);
} }
#endif #endif
printf("Closing Game...\n");
CloseGame(); CloseGame();
printf("Exiting Infrastructure...\n");
// exit the infrastructure // exit the infrastructure
FCEUI_Kill(); FCEUI_Kill();
SDL_Quit(); SDL_Quit();
// LoadGame() checks for an IP and if it finds one begins a network session
// clear the NetworkIP field so this doesn't happen unintentionally
g_config->setOption ("SDL.NetworkIP", "");
g_config->save ();
printf("Done!\n");
return 0; return 0;
} }