Merge pull request #151 from mjbudd77/master

Changed GTK GUI shutdown order of execution so that the main window c…
This commit is contained in:
mjbudd77 2020-08-06 21:40:53 -04:00 committed by GitHub
commit 9cd4b59cb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 5 deletions

View File

@ -1451,8 +1451,11 @@ void openSoundConfig (void)
return; return;
} }
void quit (void) static void mainMenuQuitCB(
GtkMenuItem *menuitem,
gpointer user_data)
{ {
printf("Main Menu Quit\n");
// Set gui run flag to false to allow main gui loop // Set gui run flag to false to allow main gui loop
// to exit normally. // to exit normally.
gtk_gui_run = false; gtk_gui_run = false;
@ -1474,6 +1477,30 @@ void quit (void)
// exit (0); // exit (0);
} }
static gboolean deleteMainWindowCB(
GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
printf("Delete Main Window Requested...\n");
gtk_gui_run = false;
return(TRUE);
}
static gboolean destroyMainWindowCB(
GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
printf("Destroy Main Window\n");
gtk_gui_run = false;
return(FALSE);
}
const char *Authors[] = { const char *Authors[] = {
"Linux/SDL Developers:", "Linux/SDL Developers:",
" Lukas Sabota //punkrockguy318", " Soules", " Bryan Cain", " radsaq", " Lukas Sabota //punkrockguy318", " Soules", " Bryan Cain", " radsaq",
@ -2612,7 +2639,7 @@ static GtkWidget *CreateMenubar (GtkWidget * window)
//-File --> Quit ------------------ //-File --> Quit ------------------
item = gtk_menu_item_new_with_label ("Quit"); item = gtk_menu_item_new_with_label ("Quit");
g_signal_connect (item, "activate", G_CALLBACK (quit), NULL); g_signal_connect (item, "activate", G_CALLBACK (mainMenuQuitCB), NULL);
gtk_widget_add_accelerator (item, "activate", accel_group, gtk_widget_add_accelerator (item, "activate", accel_group,
GDK_KEY_q, GDK_CONTROL_MASK, GDK_KEY_q, GDK_CONTROL_MASK,
@ -3683,8 +3710,8 @@ int InitGTKSubsystem (int argc, char **argv)
G_CALLBACK (handleMouseClick), NULL); G_CALLBACK (handleMouseClick), NULL);
// signal handlers // signal handlers
g_signal_connect (MainWindow, "delete-event", quit, NULL); g_signal_connect (MainWindow, "delete-event", G_CALLBACK(deleteMainWindowCB), NULL);
g_signal_connect (MainWindow, "destroy-event", quit, NULL); g_signal_connect (MainWindow, "destroy-event", G_CALLBACK(destroyMainWindowCB), NULL);
g_signal_connect (evbox, "configure-event", g_signal_connect (evbox, "configure-event",
G_CALLBACK (handle_resize), NULL); G_CALLBACK (handle_resize), NULL);

View File

@ -59,7 +59,6 @@ void setStateMenuItem( int i );
void openVideoConfig(); void openVideoConfig();
void openSoundConfig(); void openSoundConfig();
void quit ();
void openAbout (); void openAbout ();
void emuReset (); void emuReset ();

View File

@ -948,6 +948,20 @@ int main(int argc, char *argv[])
FCEUI_Kill(); FCEUI_Kill();
SDL_Quit(); SDL_Quit();
#ifdef _GTK
usleep(50000);
if ( MainWindow != NULL )
{
printf("Destroying GUI Window...\n");
gtk_widget_destroy( MainWindow ); MainWindow = NULL;
}
usleep(50000);
while(gtk_events_pending())
{
//printf("Processing the last of the events...\n");
gtk_main_iteration_do(FALSE);
}
#endif
// LoadGame() checks for an IP and if it finds one begins a network session // LoadGame() checks for an IP and if it finds one begins a network session
// clear the NetworkIP field so this doesn't happen unintentionally // clear the NetworkIP field so this doesn't happen unintentionally
g_config->setOption ("SDL.NetworkIP", ""); g_config->setOption ("SDL.NetworkIP", "");