diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-21 02:32:45 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-21 02:32:45 +0100 |
commit | cbd5d2435dd143308c434076e06809ed65217561 (patch) | |
tree | 9319b06bd38db9db420da59dcd8de670d1f01262 /src/menu | |
parent | cac7734bd0439abb40cf5bdf903335e57a0f017c (diff) | |
download | usdx-cbd5d2435dd143308c434076e06809ed65217561.tar.gz usdx-cbd5d2435dd143308c434076e06809ed65217561.tar.xz usdx-cbd5d2435dd143308c434076e06809ed65217561.zip |
menu/application: add quit() to quit the app from everywhere
Diffstat (limited to '')
-rw-r--r-- | src/menu/application.cpp | 14 | ||||
-rw-r--r-- | src/menu/application.hpp | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/menu/application.cpp b/src/menu/application.cpp index f9be797f..55edd69c 100644 --- a/src/menu/application.cpp +++ b/src/menu/application.cpp @@ -102,7 +102,7 @@ namespace usdx SDL_Event event; EventManager event_manager; MouseManager mouse_manager(event_manager); - boost::thread event_thread(boost::bind(&EventManager::handle_events, &event_manager)); + event_thread = boost::thread(boost::bind(&EventManager::handle_events, &event_manager)); SoftwareMousePointer pointer(this, &event_manager); LoadingFrame frame(this); @@ -121,14 +121,12 @@ namespace usdx while (event_manager.available() && SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: - running = false; - event_thread.interrupt(); + quit(); break; case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_q) { - running = false; - event_thread.interrupt(); + quit(); break; } @@ -214,6 +212,12 @@ namespace usdx SDL_ShowCursor(SDL_ENABLE); } + void Application::quit(void) + { + running = false; + event_thread.interrupt(); + } + const int Application::get_frames_per_second(void) const { return frames_per_second; diff --git a/src/menu/application.hpp b/src/menu/application.hpp index c6eea5c8..a0c82107 100644 --- a/src/menu/application.hpp +++ b/src/menu/application.hpp @@ -57,6 +57,7 @@ namespace usdx */ void main_loop(SDL_Surface* display); boost::thread::id gl_thread; + boost::thread event_thread; void init_fps_manager(void); @@ -73,6 +74,7 @@ namespace usdx static bool is_gl_thread(void); void run(void); + void quit(void); const int get_frames_per_second(void) const; void set_frames_per_second(int fps); |