From 41fa17f8f06ce2f893acee5c8a937f407e3040e6 Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Wed, 27 Jan 1999 22:17:42 +0000 Subject: [PATCH] appr for checkin while tree closed by sar. addref and release when we save a ptr to which widget the mouse is over or clicked on. Since we now do widget refcounting correctly, we need to do it correctly elsewhere ;) --- widget/src/mac/nsMacEventHandler.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/widget/src/mac/nsMacEventHandler.cpp b/widget/src/mac/nsMacEventHandler.cpp index bdd7bf489e3..a6d2a52ba5f 100644 --- a/widget/src/mac/nsMacEventHandler.cpp +++ b/widget/src/mac/nsMacEventHandler.cpp @@ -45,6 +45,8 @@ nsMacEventHandler::nsMacEventHandler(nsWindow* aTopLevelWidget) nsMacEventHandler::~nsMacEventHandler() { + NS_IF_RELEASE(mLastWidgetPointed); + NS_IF_RELEASE(mLastWidgetHit); } @@ -301,7 +303,9 @@ PRBool nsMacEventHandler::HandleMouseDownEvent( // dispatch the event retVal = widgetHit->DispatchMouseEvent(mouseEvent); } + NS_IF_RELEASE(mLastWidgetHit); mLastWidgetHit = widgetHit; + NS_ADDREF(widgetHit); break; } } @@ -329,6 +333,7 @@ PRBool nsMacEventHandler::HandleMouseUpEvent( if (mLastWidgetHit != nsnull) { retVal |= mLastWidgetHit->DispatchMouseEvent(mouseEvent); + NS_RELEASE(mLastWidgetHit); mLastWidgetHit = nsnull; } @@ -357,6 +362,7 @@ PRBool nsMacEventHandler::HandleMouseMoveEvent( mouseEvent.widget = mLastWidgetPointed; mouseEvent.message = NS_MOUSE_EXIT; retVal |= mLastWidgetPointed->DispatchMouseEvent(mouseEvent); + NS_IF_RELEASE(mLastWidgetPointed); mLastWidgetPointed = nsnull; mouseEvent.widget = widgetPointed; } @@ -364,7 +370,9 @@ PRBool nsMacEventHandler::HandleMouseMoveEvent( { mouseEvent.message = NS_MOUSE_ENTER; retVal |= widgetPointed->DispatchMouseEvent(mouseEvent); + NS_IF_RELEASE(mLastWidgetPointed); mLastWidgetPointed = widgetPointed; + NS_ADDREF(widgetPointed); } } else