// // Stop process // void CNewFilesBox::OnHide(void) { g_mutex_lock(m_DataMutex); if (m_Thread && !m_StopThread) { m_StopThread = true; g_cond_signal(m_Cond); g_mutex_unlock(m_DataMutex); gdk_threads_unlock(); g_thread_join(m_Thread); gdk_threads_lock(); g_mutex_lock(m_DataMutex); m_Thread = NULL; } g_mutex_unlock(m_DataMutex); Clear(); }
// // Destructor // CNewFilesBox::~CNewFilesBox(void) { g_mutex_lock(m_DataMutex); if (m_Thread) { m_StopThread = true; g_cond_signal(m_Cond); g_mutex_unlock(m_DataMutex); gdk_threads_unlock(); g_thread_join(m_Thread); gdk_threads_lock(); g_mutex_lock(m_DataMutex); m_Thread = NULL; } g_mutex_unlock(m_DataMutex); delete m_Proc; delete m_Con; PurgeQueue(); g_async_queue_unref(m_Queue); g_mutex_free(m_DataMutex); g_cond_free(m_Cond); }
int main (int argc, char *argv[]) { struct sigaction sig_callback; g_thread_init (NULL); gdk_threads_init (); gtk_init (&argc, &argv); bindtextdomain (GETTEXT_PACKAGE, SNES9XLOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); ZeroMemory (&Settings, sizeof (Settings)); /* Allow original config file for backend settings */ S9xLoadConfigFiles (argv, argc); /* Perform our config here */ gui_config = new Snes9xConfig (); S9xInitInputDevices (); gui_config->load_config_file (); char *rom_filename = S9xParseArgs (argv, argc); S9xReportControllers (); if (!Memory.Init () || !S9xInitAPU ()) exit (3); g_set_application_name ("Snes9x"); top_level = new Snes9xWindow (gui_config); /* If we're going to fullscreen, do it before showing window to avoid flicker. */ if ((gui_config->full_screen_on_open && rom_filename) || (gui_config->fullscreen)) gtk_window_fullscreen (top_level->get_window ()); top_level->show (); S9xInitDisplay (argc, argv); Memory.PostRomInitFunc = S9xPostRomInit; S9xPortSoundInit (); gui_config->reconfigure (); top_level->update_accels (); Settings.Paused = TRUE; syncing = 0; idle_func_id = g_idle_add_full (IDLE_FUNC_PRIORITY, S9xIdleFunc, NULL, NULL); g_timeout_add (10000, S9xScreenSaverCheckFunc, NULL); S9xNoROMLoaded (); if (rom_filename) { if (S9xOpenROM (rom_filename) && gui_config->full_screen_on_open) gtk_window_unfullscreen (top_level->get_window()); } memset (&sig_callback, 0, sizeof (struct sigaction)); sig_callback.sa_handler = S9xTerm; sigaction (15 /* SIGTERM */, &sig_callback, NULL); sigaction (3 /* SIGQUIT */, &sig_callback, NULL); sigaction (2 /* SIGINT */, &sig_callback, NULL); if (gui_config->fullscreen) { gui_config->fullscreen = 0; needs_fullscreening = 1; } #ifdef USE_JOYSTICK gui_config->flush_joysticks (); #endif gtk_window_present (top_level->get_window ()); gdk_threads_lock (); gtk_main (); return 0; }