Now checks all calls to Lock() - this should fix buggy apps like Globe in bug #499.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17227 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-04-24 23:08:45 +00:00
parent 490fa01c09
commit 29a92e4f53
+39 -26
View File
@@ -475,11 +475,9 @@ BWindow::ChildAt(int32 index) const
void void
BWindow::Minimize(bool minimize) BWindow::Minimize(bool minimize)
{ {
if (IsModal() || IsFloating() || fMinimized == minimize) if (IsModal() || IsFloating() || fMinimized == minimize || !Lock())
return; return;
Lock();
fMinimized = minimize; fMinimized = minimize;
fLink->StartMessage(AS_MINIMIZE_WINDOW); fLink->StartMessage(AS_MINIMIZE_WINDOW);
@@ -494,10 +492,9 @@ BWindow::Minimize(bool minimize)
status_t status_t
BWindow::SendBehind(const BWindow *window) BWindow::SendBehind(const BWindow *window)
{ {
if (!window) if (!window || !Lock())
return B_ERROR; return B_ERROR;
Lock();
fLink->StartMessage(AS_SEND_BEHIND); fLink->StartMessage(AS_SEND_BEHIND);
fLink->Attach<int32>(_get_object_token_(window)); fLink->Attach<int32>(_get_object_token_(window));
fLink->Attach<team_id>(Team()); fLink->Attach<team_id>(Team());
@@ -514,16 +511,19 @@ BWindow::SendBehind(const BWindow *window)
void void
BWindow::Flush() const BWindow::Flush() const
{ {
const_cast<BWindow *>(this)->Lock(); if (const_cast<BWindow *>(this)->Lock()) {
fLink->Flush(); fLink->Flush();
const_cast<BWindow *>(this)->Unlock(); const_cast<BWindow *>(this)->Unlock();
} }
}
void void
BWindow::Sync() const BWindow::Sync() const
{ {
const_cast<BWindow*>(this)->Lock(); if (!const_cast<BWindow*>(this)->Lock())
return;
fLink->StartMessage(AS_SYNC); fLink->StartMessage(AS_SYNC);
// waiting for the reply is the actual syncing // waiting for the reply is the actual syncing
@@ -1398,9 +1398,9 @@ BWindow::SetDefaultButton(BButton *button)
bool bool
BWindow::NeedsUpdate() const BWindow::NeedsUpdate() const
{ {
// TODO: What about locking?!? if (!const_cast<BWindow *>(this)->Lock())
return false;
const_cast<BWindow *>(this)->Lock();
fLink->StartMessage(AS_NEEDS_UPDATE); fLink->StartMessage(AS_NEEDS_UPDATE);
int32 code = B_ERROR; int32 code = B_ERROR;
@@ -1477,14 +1477,15 @@ BView *BWindow::CurrentFocus() const
void void
BWindow::Activate(bool active) BWindow::Activate(bool active)
{ {
// TODO: What about locking?!? if (!Lock())
if (IsHidden())
return; return;
Lock(); if (!IsHidden()) {
fLink->StartMessage(AS_ACTIVATE_WINDOW); fLink->StartMessage(AS_ACTIVATE_WINDOW);
fLink->Attach<bool>(active); fLink->Attach<bool>(active);
fLink->Flush(); fLink->Flush();
}
Unlock(); Unlock();
} }
@@ -1673,7 +1674,8 @@ BWindow::AddToSubset(BWindow *window)
&& fFeel != B_FLOATING_SUBSET_WINDOW_FEEL)) && fFeel != B_FLOATING_SUBSET_WINDOW_FEEL))
return B_BAD_VALUE; return B_BAD_VALUE;
Lock(); if (!Lock())
return B_ERROR;
status_t status = B_ERROR; status_t status = B_ERROR;
fLink->StartMessage(AS_ADD_TO_SUBSET); fLink->StartMessage(AS_ADD_TO_SUBSET);
@@ -1694,7 +1696,8 @@ BWindow::RemoveFromSubset(BWindow *window)
&& fFeel != B_FLOATING_SUBSET_WINDOW_FEEL)) && fFeel != B_FLOATING_SUBSET_WINDOW_FEEL))
return B_BAD_VALUE; return B_BAD_VALUE;
Lock(); if (!Lock())
return B_ERROR;
status_t status = B_ERROR; status_t status = B_ERROR;
fLink->StartMessage(AS_REMOVE_FROM_SUBSET); fLink->StartMessage(AS_REMOVE_FROM_SUBSET);
@@ -1822,7 +1825,9 @@ BWindow::SetWindowAlignment(window_alignment mode,
// TODO: test if hOffset = 0 and set it to 1 if true. // TODO: test if hOffset = 0 and set it to 1 if true.
Lock(); if (!Lock())
return B_ERROR;
fLink->StartMessage(AS_SET_ALIGNMENT); fLink->StartMessage(AS_SET_ALIGNMENT);
fLink->Attach<int32>((int32)mode); fLink->Attach<int32>((int32)mode);
fLink->Attach<int32>(h); fLink->Attach<int32>(h);
@@ -1848,10 +1853,12 @@ BWindow::GetWindowAlignment(window_alignment *mode,
int32 *h, int32 *hOffset, int32 *width, int32 *widthOffset, int32 *h, int32 *hOffset, int32 *width, int32 *widthOffset,
int32 *v, int32 *vOffset, int32 *height, int32 *heightOffset) const int32 *v, int32 *vOffset, int32 *height, int32 *heightOffset) const
{ {
const_cast<BWindow *>(this)->Lock(); if (!const_cast<BWindow *>(this)->Lock())
return B_ERROR;
fLink->StartMessage(AS_GET_ALIGNMENT); fLink->StartMessage(AS_GET_ALIGNMENT);
status_t status = B_ERROR; status_t status;
if (fLink->FlushWithReply(status) == B_OK && status == B_OK) { if (fLink->FlushWithReply(status) == B_OK && status == B_OK) {
fLink->Read<int32>((int32 *)mode); fLink->Read<int32>((int32 *)mode);
fLink->Read<int32>(h); fLink->Read<int32>(h);
@@ -1872,9 +1879,11 @@ BWindow::GetWindowAlignment(window_alignment *mode,
uint32 uint32
BWindow::Workspaces() const BWindow::Workspaces() const
{ {
if (!const_cast<BWindow *>(this)->Lock())
return 0;
uint32 workspaces = 0; uint32 workspaces = 0;
const_cast<BWindow *>(this)->Lock();
fLink->StartMessage(AS_GET_WORKSPACES); fLink->StartMessage(AS_GET_WORKSPACES);
status_t status; status_t status;
@@ -1893,12 +1902,13 @@ BWindow::SetWorkspaces(uint32 workspaces)
if (fFeel != B_NORMAL_WINDOW_FEEL) if (fFeel != B_NORMAL_WINDOW_FEEL)
return; return;
Lock(); if (Lock()) {
fLink->StartMessage(AS_SET_WORKSPACES); fLink->StartMessage(AS_SET_WORKSPACES);
fLink->Attach<uint32>(workspaces); fLink->Attach<uint32>(workspaces);
fLink->Flush(); fLink->Flush();
Unlock(); Unlock();
} }
}
BView * BView *
@@ -1911,11 +1921,9 @@ BWindow::LastMouseMovedView() const
void void
BWindow::MoveBy(float dx, float dy) BWindow::MoveBy(float dx, float dy)
{ {
if (dx == 0.0 && dy == 0.0) if ((dx == 0.0 && dy == 0.0) || !Lock())
return; return;
Lock();
fLink->StartMessage(AS_WINDOW_MOVE); fLink->StartMessage(AS_WINDOW_MOVE);
fLink->Attach<float>(dx); fLink->Attach<float>(dx);
fLink->Attach<float>(dy); fLink->Attach<float>(dy);
@@ -1931,7 +1939,8 @@ BWindow::MoveBy(float dx, float dy)
void void
BWindow::MoveTo(BPoint point) BWindow::MoveTo(BPoint point)
{ {
Lock(); if (!Lock())
return;
point.x = roundf(point.x); point.x = roundf(point.x);
point.y = roundf(point.y); point.y = roundf(point.y);
@@ -1957,7 +1966,8 @@ BWindow::MoveTo(float x, float y)
void void
BWindow::ResizeBy(float dx, float dy) BWindow::ResizeBy(float dx, float dy)
{ {
Lock(); if (!Lock())
return;
dx = roundf(dx); dx = roundf(dx);
dy = roundf(dy); dy = roundf(dy);
@@ -1990,10 +2000,11 @@ BWindow::ResizeBy(float dx, float dy)
void void
BWindow::ResizeTo(float width, float height) BWindow::ResizeTo(float width, float height)
{ {
Lock(); if (Lock()) {
ResizeBy(width - fFrame.Width(), height - fFrame.Height()); ResizeBy(width - fFrame.Width(), height - fFrame.Height());
Unlock(); Unlock();
} }
}
void void
@@ -2337,7 +2348,9 @@ BWindow::task_looper()
fLastMessage = fQueue->NextMessage(); fLastMessage = fQueue->NextMessage();
// Lock the looper // Lock the looper
Lock(); if (!Lock())
break;
if (!fLastMessage) { if (!fLastMessage) {
// No more messages: Unlock the looper and terminate the // No more messages: Unlock the looper and terminate the
// dispatch loop. // dispatch loop.