[haiku-development] BWindow::Flush() and Sync()
- From: Stephan Assmus <superstippi@xxxxxx>
- To: haiku-development@xxxxxxxxxxxxx
- Date: Wed, 12 Sep 2007 17:50:59 +0200
Hi guys,
I am suspicious about these two functions:
void
BWindow::Flush() const
{
if (const_cast<BWindow *>(this)->Lock()) {
fLink->Flush();
const_cast<BWindow *>(this)->Unlock();
}
}
void
BWindow::Sync() const
{
if (!const_cast<BWindow*>(this)->Lock())
return;
fLink->StartMessage(AS_SYNC);
// waiting for the reply is the actual syncing
int32 code;
fLink->FlushWithReply(code);
const_cast<BWindow*>(this)->Unlock();
}
Is locking the correct thing to do here? Should it not be a simple
BLooper::check_lock()? I have had a weird deadlock in one of my apps which
I tested on Haiku, which involved BView::MouseMoved() -> BView::GetMouse()
-> BWindow::UpdateIfNeeded() -> BView::Draw() -> BWindow::Flush(). The
Looper should have been locked already. There is no way this should have
deadlocked.
This would of course not have been fixed with the above proposal to not
lock at all. Maybe there is something wrong with GetMouse()... didn't have
a look yet.
In any case, I would move the functionality of Flush() and Sync() into two
private functions which wouldn't check the lock, so that BView can call the
private functions, because it already checked the lock.
Best regards,
-Stephan
- Follow-Ups:
- [haiku-development] Re: BWindow::Flush() and Sync()
- From: Stefano Ceccherini
Other related posts:
- » [haiku-development] BWindow::Flush() and Sync()
- » [haiku-development] Re: BWindow::Flush() and Sync()
- [haiku-development] Re: BWindow::Flush() and Sync()
- From: Stefano Ceccherini