From 488a89e02f6480f1a02c46e1ee742d96260a9f02 Mon Sep 17 00:00:00 2001 From: "joshmoz%gmail.com" Date: Tue, 22 Sep 2009 01:28:52 +0000 Subject: [PATCH] Add safety checks to ChildView's getScrollableView. Crash fix. b=493238 r=mstange a=dveditz git-svn-id: svn://10.0.0.236/trunk@258448 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/cocoa/nsChildView.mm | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mozilla/widget/src/cocoa/nsChildView.mm b/mozilla/widget/src/cocoa/nsChildView.mm index b1570eee8a5..8924c611da2 100644 --- a/mozilla/widget/src/cocoa/nsChildView.mm +++ b/mozilla/widget/src/cocoa/nsChildView.mm @@ -2333,23 +2333,23 @@ NSEvent* gLastDragEvent = nil; // we have to loop up through superviews in case the view that received the // mouseDown is in fact a plugin view with no scrollbars while (currView) { - // This is a hack I learned in nsView::GetViewFor(nsIWidget* aWidget) - // that I'm not sure is kosher. If anyone knows a better way to get - // the view for a widget, I'd love to hear it. --Nathan - - void* clientData; - [currView widget]->GetClientData(clientData); - - nsISupports* data = (nsISupports*)clientData; - nsCOMPtr req(do_QueryInterface(data)); - if (req) { - req->GetInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollableView); - if (scrollableView) - break; + nsIWidget* widget = [currView widget]; + if (widget) { + void* clientData; + if (NS_SUCCEEDED(widget->GetClientData(clientData))) { + nsISupports* data = (nsISupports*)clientData; + nsCOMPtr req(do_QueryInterface(data)); + if (req) { + req->GetInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollableView); + if (scrollableView) + break; + } + } } - if ([[currView superview] isMemberOfClass:[ChildView class]]) - currView = (ChildView*)[currView superview]; + NSView* superview = [currView superview]; + if (superview && [superview isMemberOfClass:[ChildView class]]) + currView = (ChildView*)superview; else currView = nil; }