* Made the tool tip manager's lock available, and guarded adding/removing the
tool tip view with this lock, too. * BTextToolTip::SetText() can now be called in all circumstances safely. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32242 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#define _TOOL_TIP_MANAGER_H
|
||||
|
||||
|
||||
#include <Locker.h>
|
||||
#include <Messenger.h>
|
||||
#include <Point.h>
|
||||
|
||||
@@ -25,6 +26,9 @@ public:
|
||||
void SetHideDelay(bigtime_t time);
|
||||
bigtime_t HideDelay() const;
|
||||
|
||||
static bool Lock() { return sLock.Lock(); }
|
||||
static void Unlock() { sLock.Unlock(); }
|
||||
|
||||
private:
|
||||
BToolTipManager();
|
||||
virtual ~BToolTipManager();
|
||||
@@ -34,6 +38,7 @@ private:
|
||||
bigtime_t fShowDelay;
|
||||
bigtime_t fHideDelay;
|
||||
|
||||
static BLocker sLock;
|
||||
static BToolTipManager* sDefaultInstance;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <Message.h>
|
||||
#include <TextView.h>
|
||||
#include <ToolTipManager.h>
|
||||
|
||||
|
||||
BToolTip::BToolTip()
|
||||
@@ -157,7 +158,26 @@ BTextToolTip::Text() const
|
||||
void
|
||||
BTextToolTip::SetText(const char* text)
|
||||
{
|
||||
bool lockedLooper;
|
||||
while (true) {
|
||||
lockedLooper = fTextView->LockLooper();
|
||||
if (!lockedLooper) {
|
||||
BToolTipManager::Lock();
|
||||
|
||||
if (fTextView->Window() != NULL) {
|
||||
BToolTipManager::Unlock();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
fTextView->SetText(text);
|
||||
|
||||
if (lockedLooper)
|
||||
fTextView->UnlockLooper();
|
||||
else
|
||||
BToolTipManager::Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,10 +14,9 @@
|
||||
#include <ToolTip.h>
|
||||
|
||||
|
||||
BLocker BToolTipManager::sLock("tool tip manager");
|
||||
BToolTipManager* BToolTipManager::sDefaultInstance;
|
||||
|
||||
static BLocker sLock("tool tip manager");
|
||||
|
||||
static const uint32 kMsgHideToolTip = 'hide';
|
||||
static const uint32 kMsgShowToolTip = 'show';
|
||||
static const uint32 kMsgCurrentToolTip = 'curr';
|
||||
@@ -56,8 +55,12 @@ public:
|
||||
|
||||
virtual void DetachedFromWindow()
|
||||
{
|
||||
BToolTipManager::Lock();
|
||||
|
||||
RemoveChild(fToolTip->View());
|
||||
// don't delete this one!
|
||||
|
||||
BToolTipManager::Unlock();
|
||||
}
|
||||
|
||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||
@@ -112,7 +115,10 @@ ToolTipWindow::ToolTipWindow(BToolTip* tip, BPoint where)
|
||||
// TODO: take alignment into account!
|
||||
|
||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||
|
||||
BToolTipManager::Lock();
|
||||
AddChild(new ToolTipView(tip));
|
||||
BToolTipManager::Unlock();
|
||||
|
||||
BSize size = ChildAt(0)->PreferredSize();
|
||||
ResizeTo(size.width, size.height);
|
||||
|
||||
Reference in New Issue
Block a user