From 9fac7d6cfc359857ac2e56431c1b386bb4540a15 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 3 Jul 2005 16:55:27 +0000 Subject: [PATCH] BServer now remembers whether the GUI context has already been initialized, so that InitGUIContext() can be invoked twice without harm. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13415 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/app/Server.h | 5 ++++- src/kits/app/Server.cpp | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/headers/private/app/Server.h b/headers/private/app/Server.h index 2c34b330dc..dcd9ced094 100644 --- a/headers/private/app/Server.h +++ b/headers/private/app/Server.h @@ -12,9 +12,12 @@ class BServer : public BApplication { public: - BServer(const char* signature, bool initGUI, status_t* error); + BServer(const char* signature, bool initGUI, status_t *error); status_t InitGUIContext(); + +private: + bool fGUIContextInitialized; }; #endif // _SERVER_H diff --git a/src/kits/app/Server.cpp b/src/kits/app/Server.cpp index e14a6e9e44..af64252d1b 100644 --- a/src/kits/app/Server.cpp +++ b/src/kits/app/Server.cpp @@ -9,14 +9,21 @@ #include // constructor -BServer::BServer(const char* signature, bool initGUI, status_t* error) - : BApplication(signature, initGUI, error) +BServer::BServer(const char* signature, bool initGUI, status_t *error) + : BApplication(signature, initGUI, error), + fGUIContextInitialized(false) { + fGUIContextInitialized = (initGUI && (!error || *error == B_OK)); } // InitGUIContext status_t BServer::InitGUIContext() { - return _InitGUIContext(); + if (fGUIContextInitialized) + return B_OK; + + status_t error = _InitGUIContext(); + fGUIContextInitialized = (error == B_OK); + return error; }