From d12a4384f1bdbaee1edcc291afc36ae66232d0ad Mon Sep 17 00:00:00 2001 From: Alexandre Deckner Date: Wed, 7 Oct 2009 00:12:25 +0000 Subject: [PATCH] * Fixed closing via deskbar's close all. The problem was that i forgot to define the app_flags in the rdef, case that isn't well handled apparently when creating a BMessenger targeting the app. Thanks to Michael and Rene for helping! Fixes #4712 * Removed unneeded and faulty App::MessageReceived and a strange (probably copy pasted then forgotten) MainWindow::QuitRequested. * Minor changes. Made App destructor virtual, moved init into ReadyToRun, fixed a few style violations. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33474 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/haiku3d/App.cpp | 23 +++++++++++++++++------ src/apps/haiku3d/App.h | 9 +++++---- src/apps/haiku3d/Haiku3d.rdef | 4 +++- src/apps/haiku3d/MainWindow.cpp | 7 ++----- src/apps/haiku3d/MainWindow.h | 2 +- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/apps/haiku3d/App.cpp b/src/apps/haiku3d/App.cpp index 3698dc324f..626dcac8b8 100644 --- a/src/apps/haiku3d/App.cpp +++ b/src/apps/haiku3d/App.cpp @@ -14,11 +14,9 @@ App::App() : - BApplication("application/x-vnd.Haiku-Haiku3d") + BApplication("application/x-vnd.Haiku-Haiku3d"), + fMainWindow(NULL) { - BRect frame(50, 50, 640 + 50, 480 + 50); - const char *title = "Haiku3d"; - fMainWindow = new MainWindow(frame, title); } @@ -27,7 +25,18 @@ App::~App() } -void App::AboutRequested() +void +App::ReadyToRun() +{ + BRect frame(50, 50, 640 + 50, 480 + 50); + const char* title = "Haiku3d"; + fMainWindow = new MainWindow(frame, title); + fMainWindow->Show(); +} + + +void +App::AboutRequested() { BAlert* alert; alert = new BAlert("About", "A little 3d demo", "ok"); @@ -35,8 +44,10 @@ void App::AboutRequested() } -void App::MessageReceived(BMessage *message) +bool +App::QuitRequested() { + return true; } diff --git a/src/apps/haiku3d/App.h b/src/apps/haiku3d/App.h index a329845766..b71609777d 100644 --- a/src/apps/haiku3d/App.h +++ b/src/apps/haiku3d/App.h @@ -12,15 +12,16 @@ #include class App: public BApplication { -protected: - BWindow* fMainWindow; public: App(); - ~App(); + virtual ~App(); + virtual void ReadyToRun(); virtual void AboutRequested(); - virtual void MessageReceived(BMessage *message); + virtual bool QuitRequested(); +protected: + BWindow* fMainWindow; }; #endif /* _APP_H */ diff --git a/src/apps/haiku3d/Haiku3d.rdef b/src/apps/haiku3d/Haiku3d.rdef index 5470b94b11..67dfa98c40 100644 --- a/src/apps/haiku3d/Haiku3d.rdef +++ b/src/apps/haiku3d/Haiku3d.rdef @@ -6,7 +6,7 @@ * Alexandre Deckner alex@zappotek.com */ -resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.Haiku-Haiku3d"; +resource app_signature "application/x-vnd.Haiku-Haiku3d"; resource app_version { major = 1, @@ -20,6 +20,8 @@ resource app_version { long_info = "Haiku3d ©2009 Haiku, Inc." }; +resource app_flags B_SINGLE_LAUNCH; + resource vector_icon { $"6E6369660603040E0B02001602380BBEBE16B13FA2DA398FCAC733EC49EB0A00" $"C0FFFF020016023F09763F2172BEF5F53EDF474C8602C9BA65008DFFFF020016" diff --git a/src/apps/haiku3d/MainWindow.cpp b/src/apps/haiku3d/MainWindow.cpp index bf71610710..a1a63159f2 100644 --- a/src/apps/haiku3d/MainWindow.cpp +++ b/src/apps/haiku3d/MainWindow.cpp @@ -35,16 +35,13 @@ MainWindow::~MainWindow() bool MainWindow::QuitRequested() { - be_app->Lock(); - if (be_app->CountWindows() < 2) - be_app_messenger.SendMessage(B_QUIT_REQUESTED); - be_app->Unlock(); + be_app->PostMessage(B_QUIT_REQUESTED); return true; } void -MainWindow::MessageReceived(BMessage *message) +MainWindow::MessageReceived(BMessage* message) { switch (message->what) { default: diff --git a/src/apps/haiku3d/MainWindow.h b/src/apps/haiku3d/MainWindow.h index 70ab86949a..389c966d33 100644 --- a/src/apps/haiku3d/MainWindow.h +++ b/src/apps/haiku3d/MainWindow.h @@ -18,7 +18,7 @@ public: ~MainWindow(); virtual bool QuitRequested(); - virtual void MessageReceived(BMessage *message); + virtual void MessageReceived(BMessage* message); virtual void DirectConnected(direct_buffer_info* info); protected: