bug 753274. Make `nsWindow::SubclassWindow` only fail if `mWnd` is an invalid window AND we're trying to apply a subclass (rather than remove a subclass). r=jimm

This commit is contained in:
Tim Abraldes 2012-06-04 00:17:22 -07:00
Родитель ed9a551900
Коммит 930ee483df
1 изменённых файлов: 30 добавлений и 21 удалений

Просмотреть файл

@ -850,34 +850,43 @@ DWORD nsWindow::WindowExStyle()
// Subclass (or remove the subclass from) this component's nsWindow
void nsWindow::SubclassWindow(BOOL bState)
{
if (NULL != mWnd) {
//NS_PRECONDITION(::IsWindow(mWnd), "Invalid window handle");
if (!::IsWindow(mWnd)) {
if (bState) {
if (!mWnd || !IsWindow(mWnd)) {
NS_ERROR("Invalid window handle");
}
if (bState) {
// change the nsWindow proc
if (mUnicodeWidget)
mPrevWndProc = (WNDPROC)::SetWindowLongPtrW(mWnd, GWLP_WNDPROC,
(LONG_PTR)nsWindow::WindowProc);
else
mPrevWndProc = (WNDPROC)::SetWindowLongPtrA(mWnd, GWLP_WNDPROC,
(LONG_PTR)nsWindow::WindowProc);
if (mUnicodeWidget) {
mPrevWndProc =
reinterpret_cast<WNDPROC>(
SetWindowLongPtrW(mWnd,
GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(nsWindow::WindowProc)));
} else {
mPrevWndProc =
reinterpret_cast<WNDPROC>(
SetWindowLongPtrA(mWnd,
GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(nsWindow::WindowProc)));
}
NS_ASSERTION(mPrevWndProc, "Null standard window procedure");
// connect the this pointer to the nsWindow handle
WinUtils::SetNSWindowPtr(mWnd, this);
} else {
if (IsWindow(mWnd)) {
if (mUnicodeWidget) {
SetWindowLongPtrW(mWnd,
GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(mPrevWndProc));
} else {
SetWindowLongPtrA(mWnd,
GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(mPrevWndProc));
}
}
else {
if (mUnicodeWidget)
::SetWindowLongPtrW(mWnd, GWLP_WNDPROC, (LONG_PTR)mPrevWndProc);
else
::SetWindowLongPtrA(mWnd, GWLP_WNDPROC, (LONG_PTR)mPrevWndProc);
WinUtils::SetNSWindowPtr(mWnd, NULL);
mPrevWndProc = NULL;
}
}
}
/**************************************************************
*