diff --git a/widget/public/nsIWidget.h b/widget/public/nsIWidget.h index 5e1bcbd42e3..515fd4b0995 100644 --- a/widget/public/nsIWidget.h +++ b/widget/public/nsIWidget.h @@ -795,6 +795,8 @@ class nsIWidget : public nsISupports { /** * Return the widget's toolkit * + * An AddRef has NOT been done for the caller. + * * @return the toolkit this widget was created in. See nsToolkit. */ diff --git a/widget/src/beos/nsWindow.cpp b/widget/src/beos/nsWindow.cpp index 4fdc30e8de5..b09cd5e1f9d 100644 --- a/widget/src/beos/nsWindow.cpp +++ b/widget/src/beos/nsWindow.cpp @@ -2799,7 +2799,6 @@ bool nsWindowBeOS::QuitRequested( void ) MethodInfo *info = nsnull; if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::CLOSEWINDOW))) t->CallMethodAsync(info); - NS_RELEASE(t); } } return true; @@ -2844,7 +2843,6 @@ void nsWindowBeOS::DispatchMessage(BMessage *msg, BHandler *handler) MethodInfo *info = nsnull; if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::CLOSEWINDOW))) t->CallMethodAsync(info); - NS_RELEASE(t); } } else @@ -2870,7 +2868,6 @@ void nsWindowBeOS::FrameMoved(BPoint origin) MethodInfo *info = nsnull; if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::ONMOVE))) t->CallMethodAsync(info); - NS_RELEASE(t); } } @@ -2887,7 +2884,6 @@ void nsWindowBeOS::WindowActivated(bool active) MethodInfo *info = nsnull; if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::ONACTIVATE, 2, args))) t->CallMethodAsync(info); - NS_RELEASE(t); } } @@ -2905,7 +2901,6 @@ void nsWindowBeOS::WorkspacesChanged(uint32 oldworkspace, uint32 newworkspace) MethodInfo *info = nsnull; if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::ONWORKSPACE, 2, args))) t->CallMethodAsync(info); - NS_RELEASE(t); } } @@ -2926,7 +2921,6 @@ void nsWindowBeOS::FrameResized(float width, float height) if (t->CallMethodAsync(info)) fJustGotBounds = false; } - NS_RELEASE(t); } } @@ -2987,7 +2981,6 @@ void nsViewBeOS::Draw(BRect updateRect) if (t->CallMethodAsync(info)) fJustValidated = false; } - NS_RELEASE(t); } } @@ -3059,7 +3052,6 @@ void nsViewBeOS::MouseDown(BPoint point) MethodInfo *info = nsnull; if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::BTNCLICK, 6, args))) t->CallMethodAsync(info); - NS_RELEASE(t); } void nsViewBeOS::MouseMoved(BPoint point, uint32 transit, const BMessage *msg) @@ -3078,7 +3070,7 @@ void nsViewBeOS::MouseMoved(BPoint point, uint32 transit, const BMessage *msg) nsWindow *w = (nsWindow *)GetMozillaWidget(); if (w == NULL) return; - nsToolkit *t = t = w->GetToolkit(); + nsToolkit *t = w->GetToolkit(); if (t == NULL) return; uint32 args[4]; @@ -3121,7 +3113,6 @@ void nsViewBeOS::MouseMoved(BPoint point, uint32 transit, const BMessage *msg) MethodInfo *moveInfo = nsnull; if (nsnull != (moveInfo = new MethodInfo(w, w, nsSwitchToUIThread::ONMOUSE, 4, args))) t->CallMethodAsync(moveInfo); - NS_RELEASE(t); } void nsViewBeOS::MouseUp(BPoint point) @@ -3143,7 +3134,7 @@ void nsViewBeOS::MouseUp(BPoint point) nsWindow *w = (nsWindow *)GetMozillaWidget(); if (w == NULL) return; - nsToolkit *t = t = w->GetToolkit(); + nsToolkit *t = w->GetToolkit(); if (t == NULL) return; @@ -3158,7 +3149,6 @@ void nsViewBeOS::MouseUp(BPoint point) MethodInfo *info = nsnull; if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::BTNCLICK, 6, args))) t->CallMethodAsync(info); - NS_RELEASE(t); } void nsViewBeOS::MessageReceived(BMessage *msg) @@ -3168,7 +3158,7 @@ void nsViewBeOS::MessageReceived(BMessage *msg) nsWindow *w = (nsWindow *)GetMozillaWidget(); if (w == NULL) return; - nsToolkit *t = t = w->GetToolkit(); + nsToolkit *t = w->GetToolkit(); if (t == NULL) return; @@ -3238,7 +3228,6 @@ void nsViewBeOS::MessageReceived(BMessage *msg) fWheelDispatched = false; } - NS_RELEASE(t); } } break; @@ -3285,7 +3274,6 @@ void nsViewBeOS::KeyDown(const char *bytes, int32 numBytes) MethodInfo *info = nsnull; if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::ONKEY, 6, args))) t->CallMethodAsync(info); - NS_RELEASE(t); } } @@ -3319,7 +3307,6 @@ void nsViewBeOS::KeyUp(const char *bytes, int32 numBytes) MethodInfo *info = nsnull; if (nsnull != (info = new MethodInfo(w, w, nsSwitchToUIThread::ONKEY, 6, args))) t->CallMethodAsync(info); - NS_RELEASE(t); } } @@ -3346,7 +3333,6 @@ void nsViewBeOS::MakeFocus(bool focused) t->CallMethodAsync(info); } #endif - NS_RELEASE(t); } } diff --git a/widget/src/mac/nsMacWindow.cpp b/widget/src/mac/nsMacWindow.cpp index a491240a43f..f64afdc82c4 100644 --- a/widget/src/mac/nsMacWindow.cpp +++ b/widget/src/mac/nsMacWindow.cpp @@ -367,7 +367,7 @@ nsresult nsMacWindow::StandardCreate(nsIWidget *aParent, // when we show it. mOffsetParent = aParent; if( aParent ) - theToolkit = getter_AddRefs(aParent->GetToolkit()); + theToolkit = aParent->GetToolkit(); mAcceptsActivation = PR_FALSE; diff --git a/widget/src/os2/nsWindow.cpp b/widget/src/os2/nsWindow.cpp index 68483b0e909..5f32d85a636 100644 --- a/widget/src/os2/nsWindow.cpp +++ b/widget/src/os2/nsWindow.cpp @@ -868,7 +868,10 @@ void nsWindow::DoCreate( HWND hwndP, nsWindow *aParent, NS_ADDREF(mToolkit); } else if( aParent) + { mToolkit = aParent->GetToolkit(); + NS_IF_ADDREF(mToolkit); + } else { // it's some top level window with no toolkit passed in. diff --git a/widget/src/xpwidgets/nsBaseWidget.cpp b/widget/src/xpwidgets/nsBaseWidget.cpp index 466e1f4727a..ae3b82a576b 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -144,7 +144,8 @@ void nsBaseWidget::BaseCreate(nsIWidget *aParent, } else { if (nsnull != aParent) { - mToolkit = (nsIToolkit*)(aParent->GetToolkit()); // the call AddRef's, we don't have to + mToolkit = aParent->GetToolkit(); + NS_IF_ADDREF(mToolkit); } // it's some top level window with no toolkit passed in. // Create a default toolkit with the current thread @@ -641,7 +642,6 @@ nsIRenderingContext* nsBaseWidget::GetRenderingContext() //------------------------------------------------------------------------- nsIToolkit* nsBaseWidget::GetToolkit() { - NS_IF_ADDREF(mToolkit); return mToolkit; }