* fix bug 414 by Sync()ing in UpdateIfNeeded() to make
sure all messages that could trigger an update have actually arrived at the server * small clean ups here and there, some clarifications in comments * check for the return value of Lock() in DisableUpdates() and EnableUpdates() git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17158 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1da0b2498f
commit
8165fa3936
@ -536,20 +536,22 @@ BWindow::Sync() const
|
|||||||
void
|
void
|
||||||
BWindow::DisableUpdates()
|
BWindow::DisableUpdates()
|
||||||
{
|
{
|
||||||
Lock();
|
if (Lock()) {
|
||||||
fLink->StartMessage(AS_DISABLE_UPDATES);
|
fLink->StartMessage(AS_DISABLE_UPDATES);
|
||||||
fLink->Flush();
|
fLink->Flush();
|
||||||
Unlock();
|
Unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindow::EnableUpdates()
|
BWindow::EnableUpdates()
|
||||||
{
|
{
|
||||||
Lock();
|
if (Lock()) {
|
||||||
fLink->StartMessage(AS_ENABLE_UPDATES);
|
fLink->StartMessage(AS_ENABLE_UPDATES);
|
||||||
fLink->Flush();
|
fLink->Flush();
|
||||||
Unlock();
|
Unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -968,6 +970,7 @@ FrameMoved(origin);
|
|||||||
|
|
||||||
case _UPDATE_:
|
case _UPDATE_:
|
||||||
{
|
{
|
||||||
|
//bigtime_t now = system_time();
|
||||||
STRACE(("info:BWindow handling _UPDATE_.\n"));
|
STRACE(("info:BWindow handling _UPDATE_.\n"));
|
||||||
BRect updateRect;
|
BRect updateRect;
|
||||||
|
|
||||||
@ -1035,6 +1038,7 @@ FrameMoved(origin);
|
|||||||
fLink->Flush();
|
fLink->Flush();
|
||||||
fInTransaction = false;
|
fInTransaction = false;
|
||||||
|
|
||||||
|
//printf("BWindow(%s) - UPDATE took %lld usecs\n", Title(), system_time() - now);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1410,11 +1414,14 @@ BWindow::NeedsUpdate() const
|
|||||||
void
|
void
|
||||||
BWindow::UpdateIfNeeded()
|
BWindow::UpdateIfNeeded()
|
||||||
{
|
{
|
||||||
// TODO: What about locking?!?
|
// works only from the window thread
|
||||||
// works only from this thread
|
|
||||||
if (find_thread(NULL) != Thread())
|
if (find_thread(NULL) != Thread())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// make sure all requests that would cause an update have
|
||||||
|
// arrived at the server
|
||||||
|
Sync();
|
||||||
|
|
||||||
// Since we're blocking the event loop, we need to retrieve
|
// Since we're blocking the event loop, we need to retrieve
|
||||||
// all messages that are pending on the port.
|
// all messages that are pending on the port.
|
||||||
_DequeueAll();
|
_DequeueAll();
|
||||||
@ -1423,7 +1430,7 @@ BWindow::UpdateIfNeeded()
|
|||||||
queue->Lock();
|
queue->Lock();
|
||||||
|
|
||||||
// First process and remove any _UPDATE_ message in the queue
|
// First process and remove any _UPDATE_ message in the queue
|
||||||
// According to Adi, there can only be one at a time
|
// With the current design, there can only be one at a time
|
||||||
|
|
||||||
BMessage *msg;
|
BMessage *msg;
|
||||||
for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; i++) {
|
for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; i++) {
|
||||||
@ -1435,6 +1442,8 @@ BWindow::UpdateIfNeeded()
|
|||||||
queue->RemoveMessage(msg);
|
queue->RemoveMessage(msg);
|
||||||
delete msg;
|
delete msg;
|
||||||
break;
|
break;
|
||||||
|
// NOTE: "i" would have to be decreased if there were
|
||||||
|
// multiple _UPDATE_ messages and we would not break!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user