Make ~Window more robust
...in cases where the Window(WindowType) ctor did not call Window::ImplInit, so many members are null; if then a derived class's ctor throws an exception, ~Window must be careful not to dereference those null members. Change-Id: I12c4b1b5d7f3633387b85acf9da6d57c42e793b4
This commit is contained in:
@@ -268,19 +268,22 @@ void UnoWrapper::WindowDestroyed( Window* pWindow )
|
|||||||
|
|
||||||
// ::com::sun::star::chaos::System-Windows suchen...
|
// ::com::sun::star::chaos::System-Windows suchen...
|
||||||
Window* pOverlap = pWindow->GetWindow( WINDOW_OVERLAP );
|
Window* pOverlap = pWindow->GetWindow( WINDOW_OVERLAP );
|
||||||
pOverlap = pOverlap->GetWindow( WINDOW_FIRSTOVERLAP );
|
if ( pOverlap )
|
||||||
while ( pOverlap )
|
|
||||||
{
|
{
|
||||||
Window* pNextOverlap = pOverlap->GetWindow( WINDOW_NEXT );
|
pOverlap = pOverlap->GetWindow( WINDOW_FIRSTOVERLAP );
|
||||||
Window* pClient = pOverlap->GetWindow( WINDOW_CLIENT );
|
while ( pOverlap )
|
||||||
|
|
||||||
if ( pClient->GetWindowPeer() && lcl_ImplIsParent( pWindow, pClient ) )
|
|
||||||
{
|
{
|
||||||
::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( sal_False ), ::com::sun::star::uno::UNO_QUERY );
|
Window* pNextOverlap = pOverlap->GetWindow( WINDOW_NEXT );
|
||||||
xComp->dispose();
|
Window* pClient = pOverlap->GetWindow( WINDOW_CLIENT );
|
||||||
}
|
|
||||||
|
|
||||||
pOverlap = pNextOverlap;
|
if ( pClient->GetWindowPeer() && lcl_ImplIsParent( pWindow, pClient ) )
|
||||||
|
{
|
||||||
|
::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( sal_False ), ::com::sun::star::uno::UNO_QUERY );
|
||||||
|
xComp->dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
pOverlap = pNextOverlap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Window* pParent = pWindow->GetParent();
|
Window* pParent = pWindow->GetParent();
|
||||||
|
@@ -1105,11 +1105,11 @@ void Window::ImplRemoveWindow( sal_Bool bRemoveFrameData )
|
|||||||
{
|
{
|
||||||
if ( mpWindowImpl->mpPrev )
|
if ( mpWindowImpl->mpPrev )
|
||||||
mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
|
mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
|
||||||
else
|
else if ( mpWindowImpl->mpParent )
|
||||||
mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
|
mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
|
||||||
if ( mpWindowImpl->mpNext )
|
if ( mpWindowImpl->mpNext )
|
||||||
mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
|
mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
|
||||||
else
|
else if ( mpWindowImpl->mpParent )
|
||||||
mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev;
|
mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4368,29 +4368,33 @@ Window::~Window()
|
|||||||
{
|
{
|
||||||
rtl::OStringBuffer aErrorStr;
|
rtl::OStringBuffer aErrorStr;
|
||||||
sal_Bool bError = sal_False;
|
sal_Bool bError = sal_False;
|
||||||
Window* pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap;
|
Window* pTempWin;
|
||||||
while ( pTempWin )
|
if (mpWindowImpl->mpFrameData != 0)
|
||||||
{
|
{
|
||||||
if ( ImplIsRealParentPath( pTempWin ) )
|
pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap;
|
||||||
|
while ( pTempWin )
|
||||||
{
|
{
|
||||||
bError = sal_True;
|
if ( ImplIsRealParentPath( pTempWin ) )
|
||||||
aErrorStr.append(lcl_createWindowInfo(*pTempWin));
|
{
|
||||||
|
bError = sal_True;
|
||||||
|
aErrorStr.append(lcl_createWindowInfo(*pTempWin));
|
||||||
|
}
|
||||||
|
pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
|
||||||
|
}
|
||||||
|
if ( bError )
|
||||||
|
{
|
||||||
|
rtl::OStringBuffer aTempStr;
|
||||||
|
aTempStr.append(RTL_CONSTASCII_STRINGPARAM("Window ("));
|
||||||
|
aTempStr.append(rtl::OUStringToOString(GetText(),
|
||||||
|
RTL_TEXTENCODING_UTF8));
|
||||||
|
aTempStr.append(RTL_CONSTASCII_STRINGPARAM(
|
||||||
|
") with living SystemWindow(s) destroyed: "));
|
||||||
|
aTempStr.append(aErrorStr.toString());
|
||||||
|
OSL_FAIL(aTempStr.getStr());
|
||||||
|
// abort in non-pro version, this must be fixed!
|
||||||
|
GetpApp()->Abort(rtl::OStringToOUString(
|
||||||
|
aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
|
||||||
}
|
}
|
||||||
pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
|
|
||||||
}
|
|
||||||
if ( bError )
|
|
||||||
{
|
|
||||||
rtl::OStringBuffer aTempStr;
|
|
||||||
aTempStr.append(RTL_CONSTASCII_STRINGPARAM("Window ("));
|
|
||||||
aTempStr.append(rtl::OUStringToOString(GetText(),
|
|
||||||
RTL_TEXTENCODING_UTF8));
|
|
||||||
aTempStr.append(RTL_CONSTASCII_STRINGPARAM(
|
|
||||||
") with living SystemWindow(s) destroyed: "));
|
|
||||||
aTempStr.append(aErrorStr.toString());
|
|
||||||
OSL_FAIL(aTempStr.getStr());
|
|
||||||
// abort in non-pro version, this must be fixed!
|
|
||||||
GetpApp()->Abort(rtl::OStringToOUString(
|
|
||||||
aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bError = sal_False;
|
bError = sal_False;
|
||||||
@@ -4562,7 +4566,8 @@ Window::~Window()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( pOverlapWindow->mpWindowImpl->mpLastFocusWindow == this )
|
if ( pOverlapWindow != 0 &&
|
||||||
|
pOverlapWindow->mpWindowImpl->mpLastFocusWindow == this )
|
||||||
pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
|
pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
|
||||||
|
|
||||||
// reset hint for DefModalDialogParent
|
// reset hint for DefModalDialogParent
|
||||||
@@ -4570,12 +4575,15 @@ Window::~Window()
|
|||||||
pSVData->maWinData.mpActiveApplicationFrame = NULL;
|
pSVData->maWinData.mpActiveApplicationFrame = NULL;
|
||||||
|
|
||||||
// reset marked windows
|
// reset marked windows
|
||||||
if ( mpWindowImpl->mpFrameData->mpFocusWin == this )
|
if ( mpWindowImpl->mpFrameData != 0 )
|
||||||
mpWindowImpl->mpFrameData->mpFocusWin = NULL;
|
{
|
||||||
if ( mpWindowImpl->mpFrameData->mpMouseMoveWin == this )
|
if ( mpWindowImpl->mpFrameData->mpFocusWin == this )
|
||||||
mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL;
|
mpWindowImpl->mpFrameData->mpFocusWin = NULL;
|
||||||
if ( mpWindowImpl->mpFrameData->mpMouseDownWin == this )
|
if ( mpWindowImpl->mpFrameData->mpMouseMoveWin == this )
|
||||||
mpWindowImpl->mpFrameData->mpMouseDownWin = NULL;
|
mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL;
|
||||||
|
if ( mpWindowImpl->mpFrameData->mpMouseDownWin == this )
|
||||||
|
mpWindowImpl->mpFrameData->mpMouseDownWin = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// reset Deactivate-Window
|
// reset Deactivate-Window
|
||||||
if ( pSVData->maWinData.mpLastDeacWin == this )
|
if ( pSVData->maWinData.mpLastDeacWin == this )
|
||||||
|
Reference in New Issue
Block a user