From 4701b640d9b716771495bbe3ab8c53f5a8f3ab99 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 30 Nov 2009 17:14:00 +0000 Subject: [PATCH] * Give the BClipboard lock a name. * be_clipboard is no longer created at libbe initialization time. The BApplication creates it as done in BeOS. This requires manual initialization in the registrar to avoid a deadlock on shutdown. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34388 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/app/ClipboardPrivate.h | 12 ------------ src/kits/app/Clipboard.cpp | 23 +++++------------------ src/kits/app/InitTerminateLibBe.cpp | 6 +----- src/servers/registrar/Registrar.cpp | 10 +++++++++- 4 files changed, 15 insertions(+), 36 deletions(-) delete mode 100644 headers/private/app/ClipboardPrivate.h diff --git a/headers/private/app/ClipboardPrivate.h b/headers/private/app/ClipboardPrivate.h deleted file mode 100644 index 0e5125445a..0000000000 --- a/headers/private/app/ClipboardPrivate.h +++ /dev/null @@ -1,12 +0,0 @@ -// ClipboardPrivate.h - -#ifndef _CLIPBOARD_PRIVATE_H -#define _CLIPBOARD_PRIVATE_H - -namespace BPrivate { - -void init_clipboard(); - -}; - -#endif // _CLIPBOARD_PRIVATE_H diff --git a/src/kits/app/Clipboard.cpp b/src/kits/app/Clipboard.cpp index 17e8109b6c..ba3f8bed16 100644 --- a/src/kits/app/Clipboard.cpp +++ b/src/kits/app/Clipboard.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007, Haiku. + * Copyright 2001-2009, Haiku Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -7,9 +7,8 @@ */ -#include - #include + #include #include #include @@ -30,6 +29,8 @@ using namespace BPrivate; BClipboard::BClipboard(const char *name, bool transient) + : + fLock("clipboard") { if (name != NULL) fName = strdup(name); @@ -91,7 +92,7 @@ BClipboard::LocalCount() const value directly from the system service managing the clipboards, so it is more expensive, but more up-to-date than LocalCount(), which returns a locally cached value. - + \return The number of commits to the clipboard. */ uint32 @@ -291,17 +292,3 @@ BClipboard::_DownloadFromSystem(bool force) return B_ERROR; } - - -// #pragma mark - - - -/*! \brief Initializes the global \c be_clipboard. - - Invoked at libbe initialization time. -*/ -void -BPrivate::init_clipboard() -{ - be_clipboard = new BClipboard(NULL); -} diff --git a/src/kits/app/InitTerminateLibBe.cpp b/src/kits/app/InitTerminateLibBe.cpp index 8f8314cecd..1d4b527959 100644 --- a/src/kits/app/InitTerminateLibBe.cpp +++ b/src/kits/app/InitTerminateLibBe.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku. + * Copyright 2001-2009, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -53,9 +52,6 @@ initialize_after() { DBG(OUT("initialize_after()\n")); - BPrivate::init_clipboard(); - // needs to send a message, and that requires gDefaultTokens to be initialized - DBG(OUT("initialize_after() done\n")); } diff --git a/src/servers/registrar/Registrar.cpp b/src/servers/registrar/Registrar.cpp index de1a04f8af..cb6cfb5a56 100644 --- a/src/servers/registrar/Registrar.cpp +++ b/src/servers/registrar/Registrar.cpp @@ -3,7 +3,7 @@ * Distributed under the terms of the MIT License. * * Authors: - * Ingo Weinhold, bonefish@users.sf.net + * Ingo Weinhold, ingo_weinhold@gmx.de */ #include "Registrar.h" @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -405,6 +406,13 @@ main() { FUNCTION_START(); + // Create the global be_clipboard manually -- it will not work, since it + // wants to talk to the registrar in its constructor, but it doesn't have + // to and we would otherwise deadlock when initializing our GUI in the + // app thread. + be_clipboard = new BClipboard(NULL); + + // create and run the registrar application status_t error; Registrar *app = new Registrar(&error);