* Use _FindView() where possible instead of using BTokenSpace::GetToken() directly.

* Fixed some issues in _UnpackMessage():
  - The focus view could have been removed before its turn which was ignored
    (and could led to a crash, for example when moving the Deskbar around).
    It's now tested if it's still valid (can't use _FindView() here, as the
    the preferred handler of a window could be any BHandler).
  - fLastMouseMovedView could have been NULL in which case there is no
    need to let the message be processed (was harmless, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16010 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-01-20 13:27:11 +00:00
parent 915af8b17a
commit e9e5c69a25
1 changed files with 24 additions and 22 deletions

View File

@ -2533,14 +2533,9 @@ BWindow::_DetermineTarget(BMessage *message, BHandler *target)
// is there a token of the view that is currently under the mouse?
int32 token;
if (message->FindInt32("_view_token", &token) == B_OK) {
BHandler* handler;
if (gDefaultTokens.GetToken(token, B_HANDLER_TOKEN,
(void**)&handler) == B_OK
&& handler->Looper() == this) {
BView* view = dynamic_cast<BView*>(handler);
if (view != NULL)
return view;
}
BView* view = _FindView(token);
if (view != NULL)
return view;
}
// if there is no valid token in the message, we try our
@ -2626,23 +2621,35 @@ BWindow::_UnpackMessage(unpack_cookie& cookie, BMessage** _message, BHandler** _
// if there is a last mouse moved view, and the new focus is
// different, the previous view wants to get its B_EXITED_VIEW
// message
if (cookie.last_view_token != B_NULL_TOKEN && fLastMouseMovedView != cookie.focus) {
if (cookie.last_view_token != B_NULL_TOKEN && fLastMouseMovedView != NULL
&& fLastMouseMovedView != cookie.focus) {
*_message = new BMessage(*cookie.message);
*_target = fLastMouseMovedView;
cookie.last_view_token = B_NULL_TOKEN;
return true;
}
if (cookie.index > 0) {
bool dispatchToFocus = true;
// check if the focus token is still valid (could have been removed in the mean time)
BHandler* handler;
if (gDefaultTokens.GetToken(cookie.focus_token, B_HANDLER_TOKEN, (void**)&handler) != B_OK
|| handler->Looper() != this)
dispatchToFocus = false;
if (dispatchToFocus && cookie.index > 0) {
// should this message still be dispatched by the focus view?
bool feedFocus;
if (!cookie.found_focus
&& (cookie.message->FindBool("_feed_focus", &feedFocus) != B_OK
|| feedFocus == false)) {
delete cookie.message;
cookie.message = NULL;
return false;
}
|| feedFocus == false))
dispatchToFocus = false;
}
if (!dispatchToFocus) {
delete cookie.message;
cookie.message = NULL;
return false;
}
*_message = cookie.message;
@ -2679,13 +2686,8 @@ BWindow::_SanitizeMessage(BMessage* message, BHandler* target, bool usePreferred
// is there a token of the view that is currently under the mouse?
BView* viewUnderMouse = NULL;
int32 token;
if (message->FindInt32("_view_token", &token) == B_OK) {
BHandler* handler;
if (gDefaultTokens.GetToken(token, B_HANDLER_TOKEN,
(void**)&handler) == B_OK
&& handler->Looper() == this)
viewUnderMouse = dynamic_cast<BView*>(handler);
}
if (message->FindInt32("_view_token", &token) == B_OK)
viewUnderMouse = _FindView(token);
// add transit information
int32 transit;