diff options
Diffstat (limited to 'vcl/source/app')
-rw-r--r-- | vcl/source/app/dbggui.cxx | 163 | ||||
-rw-r--r-- | vcl/source/app/help.cxx | 20 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 9 | ||||
-rw-r--r-- | vcl/source/app/stdtext.cxx | 4 | ||||
-rw-r--r-- | vcl/source/app/svapp.cxx | 39 | ||||
-rw-r--r-- | vcl/source/app/svdata.cxx | 18 | ||||
-rw-r--r-- | vcl/source/app/svmain.cxx | 6 | ||||
-rw-r--r-- | vcl/source/app/vclevent.cxx | 9 |
8 files changed, 169 insertions, 99 deletions
diff --git a/vcl/source/app/dbggui.cxx b/vcl/source/app/dbggui.cxx index 1c643f241176..e8d27ae769eb 100644 --- a/vcl/source/app/dbggui.cxx +++ b/vcl/source/app/dbggui.cxx @@ -207,98 +207,104 @@ NULL class DbgInfoDialog : public ModalDialog { private: - ListBox maListBox; - OKButton maOKButton; - bool mbHelpText; + VclPtr<ListBox> maListBox; + VclPtr<OKButton> maOKButton; + bool mbHelpText; public: DbgInfoDialog( vcl::Window* pParent, bool bHelpText = false ); void SetInfoText( const OUString& rStr ); +private: + virtual void dispose() SAL_OVERRIDE; + virtual ~DbgInfoDialog() { disposeOnce(); } }; class DbgDialog : public ModalDialog { private: - CheckBox maRes; - CheckBox maDialog; - CheckBox maBoldAppFont; - GroupBox maBox3; + VclPtr<CheckBox> maRes; + VclPtr<CheckBox> maDialog; + VclPtr<CheckBox> maBoldAppFont; + VclPtr<GroupBox> maBox3; - OKButton maOKButton; - CancelButton maCancelButton; - HelpButton maHelpButton; + VclPtr<OKButton> maOKButton; + VclPtr<CancelButton> maCancelButton; + VclPtr<HelpButton> maHelpButton; public: DbgDialog(); DECL_LINK( ClickHdl, Button* ); void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE; +private: + virtual void dispose() SAL_OVERRIDE; + virtual ~DbgDialog() { disposeOnce(); } }; DbgDialog::DbgDialog() : ModalDialog( NULL, WB_STDMODAL | WB_SYSTEMWINDOW ), - maRes( this ), - maDialog( this ), - maBoldAppFont( this ), - maBox3( this ), - maOKButton( this, WB_DEFBUTTON ), - maCancelButton( this ), - maHelpButton( this ) + maRes(VclPtr<CheckBox>::Create(this)), + maDialog(VclPtr<CheckBox>::Create(this)), + maBoldAppFont(VclPtr<CheckBox>::Create(this)), + maBox3(VclPtr<GroupBox>::Create(this)), + maOKButton(VclPtr<OKButton>::Create(this, WB_DEFBUTTON)), + maCancelButton(VclPtr<CancelButton>::Create(this)), + maHelpButton(VclPtr<HelpButton>::Create(this)) { DbgData* pData = DbgGetData(); MapMode aAppMap( MAP_APPFONT ); Size aButtonSize = LogicToPixel( Size( 60, 12 ), aAppMap ); { - maRes.Show(); - maRes.SetText("~Resourcen"); + maRes->Show(); + maRes->SetText("~Resourcen"); if ( pData->nTestFlags & DBG_TEST_RESOURCE ) - maRes.Check( true ); - maRes.SetPosSizePixel( LogicToPixel( Point( 75, 95 ), aAppMap ), + maRes->Check( true ); + maRes->SetPosSizePixel( LogicToPixel( Point( 75, 95 ), aAppMap ), aButtonSize ); } { - maDialog.Show(); - maDialog.SetText("~Dialog"); + maDialog->Show(); + maDialog->SetText("~Dialog"); if ( pData->nTestFlags & DBG_TEST_DIALOG ) - maDialog.Check( true ); - maDialog.SetPosSizePixel( LogicToPixel( Point( 140, 95 ), aAppMap ), + maDialog->Check( true ); + maDialog->SetPosSizePixel( LogicToPixel( Point( 140, 95 ), aAppMap ), aButtonSize ); } { - maBoldAppFont.Show(); - maBoldAppFont.SetText("~Bold AppFont"); + maBoldAppFont->Show(); + maBoldAppFont->SetText("~Bold AppFont"); if ( pData->nTestFlags & DBG_TEST_BOLDAPPFONT ) - maBoldAppFont.Check( true ); - maBoldAppFont.SetPosSizePixel( LogicToPixel( Point( 205, 95 ), aAppMap ), + maBoldAppFont->Check( true ); + maBoldAppFont->SetPosSizePixel( LogicToPixel( Point( 205, 95 ), aAppMap ), aButtonSize ); - maBoldAppFont.SaveValue(); + maBoldAppFont->SaveValue(); } { - maBox3.Show(); - maBox3.SetText("Test Options"); - maBox3.SetPosSizePixel( LogicToPixel( Point( 5, 85 ), aAppMap ), + maBox3->Show(); + maBox3->SetText("Test Options"); + maBox3->SetPosSizePixel( LogicToPixel( Point( 5, 85 ), aAppMap ), LogicToPixel( Size( 330, 30 ), aAppMap ) ); } { - maOKButton.Show(); - maOKButton.SetClickHdl( LINK( this, DbgDialog, ClickHdl ) ); - maOKButton.SetPosSizePixel( LogicToPixel( Point( 10, 260 ), aAppMap ), + maOKButton->Show(); + maOKButton->SetClickHdl( LINK( this, DbgDialog, ClickHdl ) ); + maOKButton->SetPosSizePixel( LogicToPixel( Point( 10, 260 ), aAppMap ), LogicToPixel( Size( 50, 15 ), aAppMap ) ); } { - maCancelButton.Show(); - maCancelButton.SetPosSizePixel( LogicToPixel( Point( 70, 260 ), aAppMap ), + maCancelButton->Show(); + maCancelButton->SetPosSizePixel( LogicToPixel( Point( 70, 260 ), aAppMap ), LogicToPixel( Size( 50, 15 ), aAppMap ) ); } { - maHelpButton.Show(); - maHelpButton.SetPosSizePixel( LogicToPixel( Point( 190, 260 ), aAppMap ), + maHelpButton->Show(); + maHelpButton->SetPosSizePixel( LogicToPixel( Point( 190, 260 ), aAppMap ), LogicToPixel( Size( 50, 15 ), aAppMap ) ); } @@ -310,20 +316,20 @@ DbgDialog::DbgDialog() : IMPL_LINK( DbgDialog, ClickHdl, Button*, pButton ) { - if ( pButton == &maOKButton ) + if ( pButton == maOKButton ) { DbgData aData; memcpy( &aData, DbgGetData(), sizeof( DbgData ) ); aData.nTestFlags = 0; - if ( maRes.IsChecked() ) + if ( maRes->IsChecked() ) aData.nTestFlags |= DBG_TEST_RESOURCE; - if ( maDialog.IsChecked() ) + if ( maDialog->IsChecked() ) aData.nTestFlags |= DBG_TEST_DIALOG; - if ( maBoldAppFont.IsChecked() ) + if ( maBoldAppFont->IsChecked() ) aData.nTestFlags |= DBG_TEST_BOLDAPPFONT; // Daten speichern @@ -333,12 +339,12 @@ IMPL_LINK( DbgDialog, ClickHdl, Button*, pButton ) #define IMMEDIATE_FLAGS (DBG_TEST_RESOURCE | DBG_TEST_DIALOG | DBG_TEST_BOLDAPPFONT) pData->nTestFlags &= ~IMMEDIATE_FLAGS; pData->nTestFlags |= aData.nTestFlags & IMMEDIATE_FLAGS; - if ( maBoldAppFont.IsValueChangedFromSaved() ) + if ( maBoldAppFont->IsValueChangedFromSaved() ) { AllSettings aSettings = Application::GetSettings(); StyleSettings aStyleSettings = aSettings.GetStyleSettings(); vcl::Font aFont = aStyleSettings.GetAppFont(); - if ( maBoldAppFont.IsChecked() ) + if ( maBoldAppFont->IsChecked() ) aFont.SetWeight( WEIGHT_BOLD ); else aFont.SetWeight( WEIGHT_NORMAL ); @@ -348,10 +354,10 @@ IMPL_LINK( DbgDialog, ClickHdl, Button*, pButton ) } if( (aData.nTestFlags & ~IMMEDIATE_FLAGS) != (pData->nTestFlags & ~IMMEDIATE_FLAGS) ) { - MessageDialog aBox(this, OUString( + ScopedVclPtrInstance<MessageDialog> aBox(this, OUString( "Some of the changed settings will only be active after " "restarting the process"), VCL_MESSAGE_INFO); - aBox.Execute(); + aBox->Execute(); } EndDialog( RET_OK ); } @@ -363,7 +369,7 @@ void DbgDialog::RequestHelp( const HelpEvent& rHEvt ) { if ( rHEvt.GetMode() & HelpEventMode::CONTEXT ) { - DbgInfoDialog aInfoDialog( this, true ); + ScopedVclPtrInstance< DbgInfoDialog > aInfoDialog( this, true ); OUString aHelpText; const sal_Char** pHelpStrs = pDbgHelpText; while ( *pHelpStrs ) @@ -371,16 +377,28 @@ void DbgDialog::RequestHelp( const HelpEvent& rHEvt ) aHelpText += OUString::createFromAscii(*pHelpStrs); pHelpStrs++; } - aInfoDialog.SetText( "Debug Hilfe" ); - aInfoDialog.SetInfoText( aHelpText ); - aInfoDialog.Execute(); + aInfoDialog->SetText( "Debug Hilfe" ); + aInfoDialog->SetInfoText( aHelpText ); + aInfoDialog->Execute(); } } +void DbgDialog::dispose() +{ + maRes.disposeAndClear(); + maDialog.disposeAndClear(); + maBoldAppFont.disposeAndClear(); + maBox3.disposeAndClear(); + maOKButton.disposeAndClear(); + maCancelButton.disposeAndClear(); + maHelpButton.disposeAndClear(); + ModalDialog::dispose(); +} + DbgInfoDialog::DbgInfoDialog( vcl::Window* pParent, bool bHelpText ) : ModalDialog( pParent, WB_STDMODAL ), - maListBox( this, WB_BORDER | WB_AUTOHSCROLL ), - maOKButton( this, WB_DEFBUTTON ) + maListBox(VclPtr<ListBox>::Create( this, WB_BORDER | WB_AUTOHSCROLL )), + maOKButton(VclPtr<OKButton>::Create(this, WB_DEFBUTTON)) { mbHelpText = bHelpText; @@ -389,21 +407,21 @@ DbgInfoDialog::DbgInfoDialog( vcl::Window* pParent, bool bHelpText ) : vcl::Font aFont = GetDefaultFont( DEFAULTFONT_FIXED, LANGUAGE_ENGLISH_US, 0 ); aFont.SetHeight( 8 ); aFont.SetPitch( PITCH_FIXED ); - maListBox.SetControlFont( aFont ); + maListBox->SetControlFont( aFont ); } - maListBox.SetPosSizePixel( Point( 5, 5 ), Size( 630, 380 ) ); - maListBox.Show(); + maListBox->SetPosSizePixel( Point( 5, 5 ), Size( 630, 380 ) ); + maListBox->Show(); - maOKButton.SetPosSizePixel( Point( 290, 390 ), Size( 60, 25 ) ); - maOKButton.Show(); + maOKButton->SetPosSizePixel( Point( 290, 390 ), Size( 60, 25 ) ); + maOKButton->Show(); SetOutputSizePixel( Size( 640, 420 ) ); } void DbgInfoDialog::SetInfoText( const OUString& rStr ) { - maListBox.SetUpdateMode( false ); - maListBox.Clear(); + maListBox->SetUpdateMode( false ); + maListBox->Clear(); OUString aStr = convertLineEnd(rStr, LINEEND_LF); sal_Int32 nStrIndex = 0; sal_Int32 nFoundIndex; @@ -413,18 +431,18 @@ void DbgInfoDialog::SetInfoText( const OUString& rStr ) OUString aTextParagraph = aStr.copy( nStrIndex, nFoundIndex-nStrIndex ); if ( mbHelpText ) { - long nMaxWidth = maListBox.GetOutputSizePixel().Width()-30; + long nMaxWidth = maListBox->GetOutputSizePixel().Width()-30; sal_Int32 nLastIndex = 0; sal_Int32 nIndex = aTextParagraph.indexOf( ' ' ); while ( nIndex != -1 ) { - if ( maListBox.GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth ) + if ( maListBox->GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth ) { if ( !nLastIndex ) nLastIndex = nIndex+1; OUString aTempStr = aTextParagraph.copy( 0, nLastIndex ); aTextParagraph = aTextParagraph.replaceAt( 0, nLastIndex, "" ); - maListBox.InsertEntry( aTempStr ); + maListBox->InsertEntry( aTempStr ); nLastIndex = 0; } else @@ -432,20 +450,27 @@ void DbgInfoDialog::SetInfoText( const OUString& rStr ) nIndex = aTextParagraph.indexOf( ' ', nLastIndex ); } - if ( maListBox.GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth ) + if ( maListBox->GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth ) { if ( !nLastIndex ) nLastIndex = nIndex+1; OUString aTempStr = aTextParagraph.copy( 0, nLastIndex ); aTextParagraph = aTextParagraph.replaceAt( 0, nLastIndex, "" ); - maListBox.InsertEntry( aTempStr ); + maListBox->InsertEntry( aTempStr ); } } - maListBox.InsertEntry( aTextParagraph ); + maListBox->InsertEntry( aTextParagraph ); nStrIndex = nFoundIndex+1; } while ( nFoundIndex != -1 ); - maListBox.SetUpdateMode( true ); + maListBox->SetUpdateMode( true ); +} + +void DbgInfoDialog::dispose() +{ + maListBox.disposeAndClear(); + maOKButton.disposeAndClear(); + ModalDialog::dispose(); } void DbgDialogTest( vcl::Window* pWindow ) @@ -808,7 +833,7 @@ void DbgGUIStart() if ( pData ) { - std::unique_ptr<DbgDialog> xDialog(new DbgDialog); + ScopedVclPtrInstance< DbgDialog > xDialog; // we switch off dialog tests for the debug dialog sal_uLong nOldFlags = pData->nTestFlags; pData->nTestFlags &= ~DBG_TEST_DIALOG; diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx index 53ebd746a3f6..2f52375d1e02 100644 --- a/vcl/source/app/help.cxx +++ b/vcl/source/app/help.cxx @@ -204,9 +204,9 @@ sal_uIntPtr Help::ShowTip( vcl::Window* pParent, const Rectangle& rScreenRect, const OUString& rText, sal_uInt16 nStyle ) { sal_uInt16 nHelpWinStyle = ( ( nStyle & QUICKHELP_TIP_STYLE_BALLOON ) != 0 ) ? HELPWINSTYLE_BALLOON : HELPWINSTYLE_QUICK; - HelpTextWindow* pHelpWin = new HelpTextWindow( pParent, rText, nHelpWinStyle, nStyle ); + VclPtrInstance<HelpTextWindow> pHelpWin( pParent, rText, nHelpWinStyle, nStyle ); - sal_uIntPtr nId = reinterpret_cast< sal_uIntPtr >( pHelpWin ); + sal_uIntPtr nId = reinterpret_cast< sal_uIntPtr >( pHelpWin.get() ); UpdateTip( nId, pParent, rScreenRect, rText ); pHelpWin->ShowHelp( HELPDELAY_NONE ); @@ -229,12 +229,12 @@ void Help::UpdateTip( sal_uIntPtr nId, vcl::Window* pParent, const Rectangle& rS void Help::HideTip( sal_uLong nId ) { - HelpTextWindow* pHelpWin = reinterpret_cast<HelpTextWindow*>(nId); + VclPtr<HelpTextWindow> pHelpWin = reinterpret_cast<HelpTextWindow*>(nId); vcl::Window* pFrameWindow = pHelpWin->ImplGetFrameWindow(); pHelpWin->Hide(); // trigger update, so that a Paint is instantly triggered since we do not save the background pFrameWindow->ImplUpdateAll(); - delete pHelpWin; + pHelpWin.disposeAndClear(); ImplGetSVData()->maHelpData.mnLastHelpHideTime = tools::Time::GetSystemTicks(); } @@ -290,11 +290,17 @@ HelpTextWindow::HelpTextWindow( vcl::Window* pParent, const OUString& rText, sal HelpTextWindow::~HelpTextWindow() { + disposeOnce(); +} + +void HelpTextWindow::dispose() +{ maShowTimer.Stop(); maHideTimer.Stop(); if( this == ImplGetSVData()->maHelpData.mpHelpWin ) ImplGetSVData()->maHelpData.mpHelpWin = NULL; + FloatingWindow::dispose(); } void HelpTextWindow::SetHelpText( const OUString& rHelpText ) @@ -524,7 +530,7 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, sal_uIn nDelayMode = HELPDELAY_NONE; DBG_ASSERT( !pHelpWin, "Noch ein HelpWin ?!" ); - pHelpWin = new HelpTextWindow( pParent, rHelpText, nHelpWinStyle, nStyle ); + pHelpWin = VclPtr<HelpTextWindow>::Create( pParent, rHelpText, nHelpWinStyle, nStyle ); pSVData->maHelpData.mpHelpWin = pHelpWin; pHelpWin->SetStatusText( rStatusText ); if ( pHelpArea ) @@ -544,7 +550,7 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, sal_uIn void ImplDestroyHelpWindow( bool bUpdateHideTime ) { ImplSVData* pSVData = ImplGetSVData(); - HelpTextWindow* pHelpWin = pSVData->maHelpData.mpHelpWin; + VclPtr<HelpTextWindow> pHelpWin = pSVData->maHelpData.mpHelpWin; if ( pHelpWin ) { vcl::Window * pWindow = pHelpWin->GetParent()->ImplGetFrameWindow(); @@ -555,7 +561,7 @@ void ImplDestroyHelpWindow( bool bUpdateHideTime ) pSVData->maHelpData.mpHelpWin = NULL; pSVData->maHelpData.mbKeyboardHelp = false; pHelpWin->Hide(); - delete pHelpWin; + pHelpWin.disposeAndClear(); if( bUpdateHideTime ) pSVData->maHelpData.mnLastHelpHideTime = tools::Time::GetSystemTicks(); } diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index a0447312a778..e05b73480148 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -28,6 +28,9 @@ #include <salobj.hxx> #include <salmenu.hxx> + +SalFrame::SalFrame() : m_pWindow( NULL ), m_pProc( NULL ) {} + // this file contains the virtual destructors of the sal interface // compilers usually put their vtables where the destructor is @@ -35,6 +38,12 @@ SalFrame::~SalFrame() { } +void SalFrame::SetCallback( vcl::Window* pWindow, SALFRAMEPROC pProc ) +{ + m_pWindow = pWindow; + m_pProc = pProc; +} + // default to full-frame flushes // on ports where partial-flushes are much cheaper this method should be overridden void SalFrame::Flush( const Rectangle& ) diff --git a/vcl/source/app/stdtext.cxx b/vcl/source/app/stdtext.cxx index 8093a6fe6900..fcf7b9d129c7 100644 --- a/vcl/source/app/stdtext.cxx +++ b/vcl/source/app/stdtext.cxx @@ -39,8 +39,8 @@ void ShowServiceNotAvailableError(vcl::Window* pParent, { OUString aText = GetStandardText(STANDARD_TEXT_SERVICE_NOT_AVAILABLE). replaceAll("%s", rServiceName); - MessageDialog aBox(pParent, aText, bError ? VCL_MESSAGE_ERROR : VCL_MESSAGE_WARNING); - aBox.Execute(); + ScopedVclPtrInstance< MessageDialog > aBox( pParent, aText, bError ? VCL_MESSAGE_ERROR : VCL_MESSAGE_WARNING ); + aBox->Execute(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 3d22d7cf5621..7859ccc370c4 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -156,28 +156,28 @@ struct ImplEventHook struct ImplPostEventData { sal_uLong mnEvent; - const vcl::Window* mpWin; + VclPtr<vcl::Window> mpWin; ImplSVEvent * mnEventId; KeyEvent maKeyEvent; MouseEvent maMouseEvent; ZoomEvent maZoomEvent; ScrollEvent maScrollEvent; - ImplPostEventData( sal_uLong nEvent, const vcl::Window* pWin, const KeyEvent& rKeyEvent ) : + ImplPostEventData( sal_uLong nEvent, vcl::Window* pWin, const KeyEvent& rKeyEvent ) : mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maKeyEvent( rKeyEvent ) {} - ImplPostEventData( sal_uLong nEvent, const vcl::Window* pWin, const MouseEvent& rMouseEvent ) : + ImplPostEventData( sal_uLong nEvent, vcl::Window* pWin, const MouseEvent& rMouseEvent ) : mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maMouseEvent( rMouseEvent ) {} #if !HAVE_FEATURE_DESKTOP - ImplPostEventData( sal_uLong nEvent, const vcl::Window* pWin, const ZoomEvent& rZoomEvent ) : + ImplPostEventData( sal_uLong nEvent, vcl::Window* pWin, const ZoomEvent& rZoomEvent ) : mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maZoomEvent( rZoomEvent ) {} - ImplPostEventData( sal_uLong nEvent, const vcl::Window* pWin, const ScrollEvent& rScrollEvent ) : + ImplPostEventData( sal_uLong nEvent, vcl::Window* pWin, const ScrollEvent& rScrollEvent ) : mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maScrollEvent( rScrollEvent ) {} #endif ~ImplPostEventData() {} }; -typedef ::std::pair< vcl::Window*, ImplPostEventData* > ImplPostEventPair; +typedef ::std::pair< VclPtr<vcl::Window>, ImplPostEventData* > ImplPostEventPair; static ::std::list< ImplPostEventPair > aPostedEventList; @@ -855,8 +855,8 @@ IMPL_STATIC_LINK_NOINSTANCE( Application, PostEventHandler, void*, pCallData ) break; }; - if( pData->mpWin && pData->mpWin->mpWindowImpl->mpFrameWindow && pEventData ) - ImplWindowFrameProc( pData->mpWin->mpWindowImpl->mpFrameWindow, NULL, (sal_uInt16) nEvent, pEventData ); + if( pData->mpWin && pData->mpWin.get()->mpWindowImpl->mpFrameWindow.get() && pEventData ) + ImplWindowFrameProc( pData->mpWin.get()->mpWindowImpl->mpFrameWindow.get(), NULL, (sal_uInt16) nEvent, pEventData ); // remove this event from list of posted events, watch for destruction of internal data ::std::list< ImplPostEventPair >::iterator aIter( aPostedEventList.begin() ); @@ -1010,7 +1010,7 @@ long Application::GetTopWindowCount() { long nRet = 0; ImplSVData* pSVData = ImplGetSVData(); - vcl::Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame : NULL; + vcl::Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame.get() : NULL; while( pWin ) { if( pWin->ImplGetWindow()->IsTopWindow() ) @@ -1024,7 +1024,7 @@ vcl::Window* Application::GetTopWindow( long nIndex ) { long nIdx = 0; ImplSVData* pSVData = ImplGetSVData(); - vcl::Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame : NULL; + vcl::Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame.get() : NULL; while( pWin ) { if( pWin->ImplGetWindow()->IsTopWindow() ) @@ -1268,7 +1268,7 @@ vcl::Window* Application::GetDefDialogParent() // #103442# find some useful dialog parent if there // was no default set // NOTE: currently even the default is not used - if( false && pSVData->maWinData.mpDefDialogParent != NULL ) + if( false && pSVData->maWinData.mpDefDialogParent.get() != NULL ) return pSVData->maWinData.mpDefDialogParent; else { @@ -1629,11 +1629,24 @@ void Application::setDeInitHook(Link const & hook) { pSVData->maAppData.mbInAppMain = true; } +ImplDelData::ImplDelData( vcl::Window* pWindow ) : + mpNext( NULL ), + mpWindow( NULL ), + mbDel( false ) +{ + if( pWindow ) AttachToWindow( pWindow ); +} + // helper method to allow inline constructor even for pWindow!=NULL case void ImplDelData::AttachToWindow( const vcl::Window* pWindow ) { if( pWindow ) - const_cast<vcl::Window*>(pWindow)->ImplAddDel( this ); + { + if( pWindow->IsDisposed() ) + mbDel = true; + else + const_cast<vcl::Window*>(pWindow)->ImplAddDel( this ); + } } // define dtor for ImplDelData @@ -1644,7 +1657,7 @@ ImplDelData::~ImplDelData() if( !mbDel && mpWindow ) { // the window still exists but we were not removed - const_cast<vcl::Window*>(mpWindow)->ImplRemoveDel( this ); + const_cast<vcl::Window*>(mpWindow.get())->ImplRemoveDel( this ); mpWindow = NULL; } } diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx index 155b5cc0ba3c..14cf94de9dd2 100644 --- a/vcl/source/app/svdata.cxx +++ b/vcl/source/app/svdata.cxx @@ -37,6 +37,8 @@ #include "vcl/layout.hxx" #include "vcl/button.hxx" #include "vcl/dockwin.hxx" +#include "vcl/print.hxx" +#include "vcl/virdev.hxx" #include "salinst.hxx" #include "salframe.hxx" #include "salgdi.hxx" @@ -45,6 +47,8 @@ #include "salimestatus.hxx" #include "salsys.hxx" #include "svids.hrc" +#include "helpwin.hxx" +#include "../window/scrwnd.hxx" #include "com/sun/star/accessibility/MSAAService.hpp" @@ -84,6 +88,14 @@ ImplSVData::ImplSVData() maNWFData.maMenuBarHighlightTextColor = Color( COL_TRANSPARENT ); } +ImplSVGDIData::~ImplSVGDIData() +{ + // FIXME: deliberately leak any remaining OutputDevice + // until we have their pGraphics reference counted, doing + // any disposes so late in shutdown is rather unsafe. + memset( this, 0, sizeof( ImplSVGDIData ) ); +} + void ImplDeInitSVData() { ImplSVData* pSVData = ImplGetSVData(); @@ -124,7 +136,7 @@ vcl::Window* ImplGetDefaultWindow() if ( !pSVData->mpDefaultWin && !pSVData->mbDeInit ) { DBG_WARNING( "ImplGetDefaultWindow(): No AppWindow" ); - pSVData->mpDefaultWin = new WorkWindow( 0, WB_DEFAULTWIN ); + pSVData->mpDefaultWin = VclPtr<WorkWindow>::Create( nullptr, WB_DEFAULTWIN ); pSVData->mpDefaultWin->SetText( OUString( "VCL ImplGetDefaultWindow" ) ); // Add a reference to the default context so it never gets deleted @@ -160,8 +172,8 @@ ResMgr* ImplGetResMgr() "Missing vcl resource. This indicates that files vital to localization are missing. " "You might have a corrupt installation."; fprintf( stderr, "%s\n", pMsg ); - MessageDialog aBox(NULL, OUString(pMsg, strlen(pMsg), RTL_TEXTENCODING_ASCII_US)); - aBox.Execute(); + ScopedVclPtrInstance< MessageDialog > aBox( nullptr, OUString(pMsg, strlen(pMsg), RTL_TEXTENCODING_ASCII_US) ); + aBox->Execute(); } } return pSVData->mpResMgr; diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx index a80d576c1987..fce2961c2c53 100644 --- a/vcl/source/app/svmain.cxx +++ b/vcl/source/app/svmain.cxx @@ -423,11 +423,7 @@ void DeInitVCL() delete pSVData->maCtrlData.mpDisclosureMinus; pSVData->maCtrlData.mpDisclosureMinus = NULL; } - if ( pSVData->mpDefaultWin ) - { - delete pSVData->mpDefaultWin; - pSVData->mpDefaultWin = NULL; - } + pSVData->mpDefaultWin.disposeAndClear(); DBGGUI_DEINIT_SOLARMUTEXCHECK(); diff --git a/vcl/source/app/vclevent.cxx b/vcl/source/app/vclevent.cxx index 11d03e3f8b03..325c9b659b18 100644 --- a/vcl/source/app/vclevent.cxx +++ b/vcl/source/app/vclevent.cxx @@ -18,6 +18,7 @@ */ #include "vcl/vclevent.hxx" +#include "vcl/window.hxx" #include "svdata.hxx" @@ -158,4 +159,12 @@ void VclEventListeners2::callListeners( VclSimpleEvent* i_pEvent ) m_aIterators.pop_back(); } + +VclWindowEvent::VclWindowEvent( vcl::Window* pWin, sal_uLong n, void* pDat ) : VclSimpleEvent(n) +{ + pWindow = pWin; pData = pDat; +} + +VclWindowEvent::~VclWindowEvent() {} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |