[Libreoffice-commits] core.git: Branch 'feature/vclptr' - 9 commits - canvas/source compilerplugins/clang cppcanvas/source cui/source dbaccess/source desktop/source drawinglayer/source editeng/source extensions/source filter/source forms/source fpicker/source framework/inc include/drawinglayer include/sfx2 include/vcl sc/inc sc/source sd/source sfx2/source starmath/source svtools/source svx/source sw/inc sw/source vcl/README.lifecycle vcl/source vcl/unx vcl/workben

Michael Meeks michael.meeks at collabora.com
Fri Apr 10 04:56:20 PDT 2015


 canvas/source/directx/dx_devicehelper.hxx                  |    2 
 canvas/source/vcl/backbuffer.hxx                           |    2 
 compilerplugins/clang/vclwidgets.cxx                       |    4 
 cppcanvas/source/mtfrenderer/implrenderer.cxx              |    2 
 cui/source/dialogs/iconcdlg.cxx                            |    2 
 cui/source/factory/dlgfact.hxx                             |    2 
 cui/source/options/optjava.cxx                             |    2 
 cui/source/options/treeopt.cxx                             |    2 
 dbaccess/source/ui/querydesign/JoinTableView.cxx           |    4 
 dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx  |    1 
 dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx      |    2 
 desktop/source/deployment/gui/dp_gui_theextmgr.cxx         |    2 
 desktop/source/splash/splash.cxx                           |  139 +++++++------
 drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx |    4 
 drawinglayer/source/tools/converters.cxx                   |    2 
 editeng/source/editeng/editeng.cxx                         |    2 
 extensions/source/propctrlr/propertyeditor.cxx             |    5 
 filter/source/graphicfilter/epict/epict.cxx                |   14 -
 forms/source/solar/control/navtoolbar.cxx                  |    2 
 forms/source/solar/inc/navtoolbar.hxx                      |    2 
 fpicker/source/office/commonpicker.cxx                     |    6 
 framework/inc/classes/fwktabwindow.hxx                     |    2 
 include/drawinglayer/processor2d/canvasprocessor.hxx       |    2 
 include/sfx2/fcontnr.hxx                                   |    2 
 include/vcl/vclptr.hxx                                     |   22 +-
 sc/inc/editutil.hxx                                        |    2 
 sc/source/core/data/documen8.cxx                           |    2 
 sc/source/filter/inc/htmlexp.hxx                           |    2 
 sc/source/ui/attrdlg/scdlgfact.hxx                         |    6 
 sc/source/ui/cctrl/tbzoomsliderctrl.cxx                    |    5 
 sc/source/ui/dbgui/csvruler.cxx                            |   54 ++---
 sc/source/ui/drawfunc/fupoor.cxx                           |    1 
 sc/source/ui/inc/autofmt.hxx                               |    2 
 sc/source/ui/inc/cbutton.hxx                               |    1 
 sc/source/ui/inc/dpcontrol.hxx                             |    3 
 sc/source/ui/inc/gridmerg.hxx                              |    2 
 sc/source/ui/inc/printfun.hxx                              |    2 
 sc/source/ui/miscdlgs/autofmt.cxx                          |   34 +--
 sc/source/ui/sidebar/CellLineStyleValueSet.cxx             |    2 
 sc/source/ui/sidebar/CellLineStyleValueSet.hxx             |    2 
 sc/source/ui/unoobj/confuno.cxx                            |    4 
 sc/source/ui/view/printfun.cxx                             |    2 
 sd/source/filter/eppt/epptbase.hxx                         |    2 
 sd/source/filter/eppt/pptx-text.cxx                        |    2 
 sd/source/ui/app/sdxfer.cxx                                |    2 
 sd/source/ui/dlg/sddlgfact.hxx                             |    2 
 sd/source/ui/func/fupoor.cxx                               |    3 
 sd/source/ui/inc/PreviewRenderer.hxx                       |    2 
 sd/source/ui/inc/View.hxx                                  |    4 
 sd/source/ui/inc/drawview.hxx                              |    2 
 sd/source/ui/inc/sdxfer.hxx                                |    2 
 sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx         |    2 
 sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx     |    2 
 sd/source/ui/view/DocumentRenderer.cxx                     |   10 
 sd/source/ui/view/drawview.cxx                             |    5 
 sfx2/source/control/thumbnailviewitem.cxx                  |    1 
 sfx2/source/dialog/basedlgs.cxx                            |    2 
 sfx2/source/dialog/infobar.cxx                             |    9 
 sfx2/source/dialog/templdlg.cxx                            |    1 
 starmath/source/unomodel.cxx                               |    4 
 svtools/source/brwbox/brwbox1.cxx                          |    2 
 svtools/source/control/tabbar.cxx                          |   30 +-
 svtools/source/dialogs/roadmapwizard.cxx                   |    2 
 svtools/source/graphic/grfmgr2.cxx                         |    2 
 svtools/source/graphic/provider.cxx                        |    2 
 svtools/source/misc/sampletext.cxx                         |    2 
 svtools/source/table/gridtablerenderer.cxx                 |    2 
 svx/source/fmcomp/gridcell.cxx                             |    4 
 svx/source/form/datanavi.cxx                               |    3 
 sw/inc/hints.hxx                                           |    5 
 sw/source/core/attr/hints.cxx                              |    2 
 sw/source/core/draw/dflyobj.cxx                            |    2 
 sw/source/core/inc/drawfont.hxx                            |    2 
 sw/source/core/inc/fntcache.hxx                            |    5 
 sw/source/core/layout/paintfrm.cxx                         |    4 
 sw/source/core/layout/virtoutp.cxx                         |    3 
 sw/source/core/layout/virtoutp.hxx                         |    6 
 sw/source/core/text/inftxt.hxx                             |    4 
 sw/source/core/text/itratr.cxx                             |    6 
 sw/source/core/text/itratr.hxx                             |    2 
 sw/source/core/text/itrtxt.hxx                             |    2 
 sw/source/core/text/txtpaint.hxx                           |    4 
 sw/source/core/txtnode/fntcache.cxx                        |   10 
 sw/source/core/view/viewsh.cxx                             |   20 -
 sw/source/ui/chrdlg/drpcps.cxx                             |    4 
 sw/source/ui/config/optpage.cxx                            |    6 
 sw/source/ui/dbui/createaddresslistdialog.cxx              |    8 
 sw/source/ui/dbui/mmaddressblockpage.cxx                   |    7 
 sw/source/ui/dbui/mmoutputpage.cxx                         |    4 
 sw/source/ui/dbui/mmoutputpage.hxx                         |    2 
 sw/source/ui/dialog/swdlgfact.cxx                          |    1 
 sw/source/ui/dialog/swdlgfact.hxx                          |    2 
 sw/source/ui/envelp/envprt.hxx                             |    2 
 sw/source/ui/envelp/labprt.cxx                             |    2 
 sw/source/ui/envelp/labprt.hxx                             |    2 
 sw/source/ui/index/cnttab.cxx                              |    2 
 sw/source/ui/misc/outline.cxx                              |    2 
 sw/source/ui/table/tautofmt.cxx                            |   50 ++--
 sw/source/uibase/docvw/PostItMgr.cxx                       |    3 
 sw/source/uibase/inc/envlop.hxx                            |    2 
 sw/source/uibase/inc/optpage.hxx                           |    2 
 sw/source/uibase/inc/swruler.hxx                           |    2 
 sw/source/uibase/misc/swruler.cxx                          |   38 +--
 sw/source/uibase/uiview/pview.cxx                          |    6 
 sw/source/uibase/uno/SwXDocumentSettings.cxx               |    8 
 sw/source/uibase/uno/SwXDocumentSettings.hxx               |    2 
 sw/source/uibase/utlui/navipi.cxx                          |    1 
 vcl/README.lifecycle                                       |    8 
 vcl/source/control/tabctrl.cxx                             |    2 
 vcl/source/edit/vclmedit.cxx                               |    9 
 vcl/source/filter/graphicfilter.cxx                        |    2 
 vcl/source/filter/sgfbram.cxx                              |    2 
 vcl/source/filter/sgvmain.cxx                              |    2 
 vcl/source/filter/sgvtext.cxx                              |    2 
 vcl/source/filter/wmf/emfwr.hxx                            |    4 
 vcl/source/gdi/cvtsvm.cxx                                  |    6 
 vcl/source/gdi/gdimetafiletools.cxx                        |    2 
 vcl/source/gdi/gdimtf.cxx                                  |   14 -
 vcl/source/gdi/impanmvw.cxx                                |    2 
 vcl/source/gdi/impgraph.cxx                                |    2 
 vcl/source/gdi/impvect.cxx                                 |    2 
 vcl/source/gdi/pdfwriter_impl.cxx                          |    2 
 vcl/source/gdi/print2.cxx                                  |    6 
 vcl/source/gdi/print3.cxx                                  |    1 
 vcl/source/outdev/bitmap.cxx                               |    2 
 vcl/source/outdev/transparent.cxx                          |    2 
 vcl/source/outdev/wallpaper.cxx                            |    2 
 vcl/source/window/btndlg.cxx                               |    6 
 vcl/source/window/builder.cxx                              |    1 
 vcl/source/window/window.cxx                               |    3 
 vcl/unx/generic/app/i18n_status.cxx                        |    1 
 vcl/workben/vcldemo.cxx                                    |    3 
 132 files changed, 449 insertions(+), 337 deletions(-)

New commits:
commit a8dc965511f5f8e276eb4797ac0c37479907a079
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Mar 20 23:06:40 2015 +0000

    splash: de-confuse mixed VCL and UNO reference counting.
    
    Change-Id: I1c8ded2e5c5e8072111d3e1480ba7086db135810

diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx
index cb1ed36..cb1630a 100644
--- a/desktop/source/splash/splash.cxx
+++ b/desktop/source/splash/splash.cxx
@@ -46,16 +46,31 @@ using namespace ::com::sun::star::uno;
 
 namespace {
 
+class SplashScreen;
+
+class SplashScreenWindow : public IntroWindow
+{
+public:
+    SplashScreen *pSpl;
+    ScopedVclPtr<VirtualDevice> _vdev;
+            SplashScreenWindow(SplashScreen *);
+    virtual ~SplashScreenWindow() { disposeOnce(); }
+    virtual void dispose() SAL_OVERRIDE;
+    // workwindow
+    virtual void Paint( const Rectangle& ) SAL_OVERRIDE;
+};
+
 class  SplashScreen
     : public ::cppu::WeakImplHelper3< XStatusIndicator, XInitialization, XServiceInfo >
-    , public IntroWindow
 {
+    friend SplashScreenWindow;
 private:
     enum BitmapMode { BM_FULLSCREEN, BM_DEFAULTMODE };
 
+    VclPtr<SplashScreenWindow> pWindow;
+
     DECL_LINK( AppEventListenerHdl, VclWindowEvent * );
     virtual ~SplashScreen();
-    virtual void dispose() SAL_OVERRIDE;
     void loadConfig();
     void updateStatus();
     void SetScreenBitmap(BitmapEx &rBitmap);
@@ -63,7 +78,6 @@ private:
 
     static osl::Mutex _aMutex;
 
-    ScopedVclPtr<VirtualDevice> _vdev;
     BitmapEx        _aIntroBmp;
     Color           _cProgressFrameColor;
     Color           _cProgressBarColor;
@@ -112,15 +126,24 @@ public:
     virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     { return desktop::splash::getSupportedServiceNames(); }
+};
 
-    // workwindow
-    virtual void Paint( const Rectangle& ) SAL_OVERRIDE;
+SplashScreenWindow::SplashScreenWindow(SplashScreen *pSplash)
+    : IntroWindow()
+    , pSpl( pSplash )
+    , _vdev(new VirtualDevice(*this))
+{
+    _vdev->EnableRTL(IsRTLEnabled());
+}
 
-};
+void SplashScreenWindow::dispose()
+{
+    pSpl = NULL;
+    IntroWindow::dispose();
+}
 
 SplashScreen::SplashScreen()
-    : IntroWindow()
-    , _vdev(new VirtualDevice(*((IntroWindow*)this)))
+    : pWindow( new SplashScreenWindow (this) )
     , _cProgressFrameColor(sal::static_int_cast< ColorData >(NOT_LOADED))
     , _cProgressBarColor(sal::static_int_cast< ColorData >(NOT_LOADED))
     , _cProgressTextColor(sal::static_int_cast< ColorData >(NOT_LOADED))
@@ -150,20 +173,14 @@ SplashScreen::SplashScreen()
     , _yoffset(18)
 {
     loadConfig();
-    _vdev->EnableRTL(IsRTLEnabled());
 }
 
 SplashScreen::~SplashScreen()
 {
-    disposeOnce();
-}
-
-void SplashScreen::dispose()
-{
     Application::RemoveEventListener(
         LINK( this, SplashScreen, AppEventListenerHdl ) );
-    Hide();
-    IntroWindow::dispose();
+    pWindow->Hide();
+    pWindow.disposeAndClear();
 }
 
 void SAL_CALL SplashScreen::start(const OUString&, sal_Int32 nRange)
@@ -174,10 +191,10 @@ void SAL_CALL SplashScreen::start(const OUString&, sal_Int32 nRange)
         _bProgressEnd = false;
         SolarMutexGuard aSolarGuard;
         if ( _eBitmapMode == BM_FULLSCREEN )
-            ShowFullScreenMode( true );
-        Show();
-        Paint(Rectangle());
-        Flush();
+            pWindow->ShowFullScreenMode( true );
+        pWindow->Show();
+        pWindow->Paint(Rectangle());
+        pWindow->Flush();
     }
 }
 
@@ -188,8 +205,8 @@ void SAL_CALL SplashScreen::end()
     if (_bVisible )
     {
         if ( _eBitmapMode == BM_FULLSCREEN )
-            EndFullScreenMode();
-        Hide();
+            pWindow->EndFullScreenMode();
+        pWindow->Hide();
     }
     _bProgressEnd = true;
 }
@@ -201,8 +218,8 @@ void SAL_CALL SplashScreen::reset()
     if (_bVisible && !_bProgressEnd )
     {
         if ( _eBitmapMode == BM_FULLSCREEN )
-            ShowFullScreenMode( true );
-        Show();
+            pWindow->ShowFullScreenMode( true );
+        pWindow->Show();
         updateStatus();
     }
 }
@@ -218,8 +235,8 @@ void SAL_CALL SplashScreen::setText(const OUString& rText)
         if (_bVisible && !_bProgressEnd)
         {
             if ( _eBitmapMode == BM_FULLSCREEN )
-                ShowFullScreenMode( true );
-            Show();
+                pWindow->ShowFullScreenMode( true );
+            pWindow->Show();
             updateStatus();
         }
     }
@@ -233,11 +250,13 @@ void SAL_CALL SplashScreen::setValue(sal_Int32 nValue)
     SolarMutexGuard aSolarGuard;
     if (_bVisible && !_bProgressEnd) {
         if ( _eBitmapMode == BM_FULLSCREEN )
-            ShowFullScreenMode( true );
-        Show();
-        if (nValue >= _iMax) _iProgress = _iMax;
-    else _iProgress = nValue;
-    updateStatus();
+            pWindow->ShowFullScreenMode( true );
+        pWindow->Show();
+        if (nValue >= _iMax)
+            _iProgress = _iMax;
+        else
+            _iProgress = nValue;
+        updateStatus();
     }
 }
 
@@ -257,8 +276,8 @@ SplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::sta
         if ( _bShowLogo )
             SetScreenBitmap (_aIntroBmp);
         Size aSize = _aIntroBmp.GetSizePixel();
-        SetOutputSizePixel( aSize );
-        _vdev->SetOutputSizePixel( aSize );
+        pWindow->SetOutputSizePixel( aSize );
+        pWindow->_vdev->SetOutputSizePixel( aSize );
         _height = aSize.Height();
         _width = aSize.Width();
         if (_width > 500)
@@ -328,10 +347,12 @@ SplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::sta
 
 void SplashScreen::updateStatus()
 {
-    if (!_bVisible || _bProgressEnd) return;
-    if (!_bPaintProgress) _bPaintProgress = true;
-    Paint(Rectangle());
-    Flush();
+    if (!_bVisible || _bProgressEnd)
+        return;
+    if (!_bPaintProgress)
+        _bPaintProgress = true;
+    pWindow->Paint(Rectangle());
+    pWindow->Flush();
 }
 
 // internal private methods
@@ -342,7 +363,7 @@ IMPL_LINK( SplashScreen, AppEventListenerHdl, VclWindowEvent *, inEvent )
         switch ( inEvent->GetId() )
         {
             case VCLEVENT_WINDOW_SHOW:
-                Paint( Rectangle() );
+                pWindow->Paint( Rectangle() );
                 break;
             default:
                 break;
@@ -583,18 +604,19 @@ void SplashScreen::determineProgressRatioValues(
     }
 }
 
-void SplashScreen::Paint( const Rectangle&)
+void SplashScreenWindow::Paint( const Rectangle&)
 {
-    if(!_bVisible) return;
+    if (!pSpl || !pSpl->_bVisible)
+        return;
 
     //native drawing
     // in case of native controls we need to draw directly to the window
-    if( _bNativeProgress && IsNativeControlSupported( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL ) )
+    if( pSpl->_bNativeProgress && IsNativeControlSupported( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL ) )
     {
-        DrawBitmapEx( Point(), _aIntroBmp );
+        DrawBitmapEx( Point(), pSpl->_aIntroBmp );
 
-        ImplControlValue aValue( _iProgress * _barwidth / _iMax);
-        Rectangle aDrawRect( Point(_tlx, _tly), Size( _barwidth, _barheight ) );
+        ImplControlValue aValue( pSpl->_iProgress * pSpl->_barwidth / pSpl->_iMax);
+        Rectangle aDrawRect( Point(pSpl->_tlx, pSpl->_tly), Size( pSpl->_barwidth, pSpl->_barheight ) );
         Rectangle aNativeControlRegion, aNativeContentRegion;
 
         if( GetNativeControlRegion( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect,
@@ -602,39 +624,40 @@ void SplashScreen::Paint( const Rectangle&)
                                              aNativeControlRegion, aNativeContentRegion ) )
         {
               long nProgressHeight = aNativeControlRegion.GetHeight();
-              aDrawRect.Top() -= (nProgressHeight - _barheight)/2;
-              aDrawRect.Bottom() += (nProgressHeight - _barheight)/2;
+              aDrawRect.Top() -= (nProgressHeight - pSpl->_barheight)/2;
+              aDrawRect.Bottom() += (nProgressHeight - pSpl->_barheight)/2;
         }
 
         if( (DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect,
-                                            ControlState::ENABLED, aValue, _sProgressText )) )
+                                ControlState::ENABLED, aValue, _sProgressText )) )
         {
             return;
         }
     }
-    //non native drawing
+
+    // non native drawing
     // draw bitmap
-    if (_bPaintBitmap)
-        _vdev->DrawBitmapEx( Point(), _aIntroBmp );
+    if (pSpl->_bPaintBitmap)
+        _vdev->DrawBitmapEx( Point(), pSpl->_aIntroBmp );
 
-    if (_bPaintProgress) {
+    if (pSpl->_bPaintProgress) {
         // draw progress...
-        long length = (_iProgress * _barwidth / _iMax) - (2 * _barspace);
+        long length = (pSpl->_iProgress * pSpl->_barwidth / pSpl->_iMax) - (2 * pSpl->_barspace);
         if (length < 0) length = 0;
 
         // border
         _vdev->SetFillColor();
-        _vdev->SetLineColor( _cProgressFrameColor );
-        _vdev->DrawRect(Rectangle(_tlx, _tly, _tlx+_barwidth, _tly+_barheight));
-        _vdev->SetFillColor( _cProgressBarColor );
+        _vdev->SetLineColor( pSpl->_cProgressFrameColor );
+        _vdev->DrawRect(Rectangle(pSpl->_tlx, pSpl->_tly, pSpl->_tlx+pSpl->_barwidth, pSpl->_tly+pSpl->_barheight));
+        _vdev->SetFillColor( pSpl->_cProgressBarColor );
         _vdev->SetLineColor();
-        _vdev->DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace));
+        _vdev->DrawRect(Rectangle(pSpl->_tlx+pSpl->_barspace, pSpl->_tly+pSpl->_barspace, pSpl->_tlx+pSpl->_barspace+length, pSpl->_tly+pSpl->_barheight-pSpl->_barspace));
         vcl::Font aFont;
         aFont.SetSize(Size(0, 12));
         aFont.SetAlign(ALIGN_BASELINE);
         _vdev->SetFont(aFont);
-        _vdev->SetTextColor(_cProgressTextColor);
-        _vdev->DrawText(Point(_tlx, _textBaseline), _sProgressText);
+        _vdev->SetTextColor(pSpl->_cProgressTextColor);
+        _vdev->DrawText(Point(pSpl->_tlx, pSpl->_textBaseline), pSpl->_sProgressText);
     }
     DrawOutDev(Point(), GetOutputSizePixel(), Point(), _vdev->GetOutputSizePixel(), *_vdev.get() );
 }
commit bd2a35e10c6a2600dc9cdadc1202c174a7b87f06
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Mar 20 21:05:22 2015 +0000

    malingering delete.
    
    Change-Id: I954c6b0db3ae69146763fa6c54e2d8015b00ee4e

diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx
index 6d0ceb7..722bc70 100644
--- a/sc/source/ui/unoobj/confuno.cxx
+++ b/sc/source/ui/unoobj/confuno.cxx
@@ -191,11 +191,11 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue(
                     {
                         if (pPrinter->GetName() != sPrinterName)
                         {
-                            SfxPrinter* pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), sPrinterName );
+                            VclPtr<SfxPrinter> pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), sPrinterName );
                             if (pNewPrinter->IsKnown())
                                 pDocShell->SetPrinter( pNewPrinter, SfxPrinterChangeFlags::PRINTER );
                             else
-                                delete pNewPrinter;
+                                pNewPrinter.disposeAndClear();
                         }
                     }
                     else
commit ad8a2074c6143d3ce05c0a5d93a553c13b950520
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Mar 20 18:58:34 2015 +0000

    cure a lot of unfortunate ScopedVclPtrs.
    
    Change-Id: I2149511f958ba75e81dc41b10b01eb9d19610037

diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx
index 3f38946..129f539 100644
--- a/cppcanvas/source/mtfrenderer/implrenderer.cxx
+++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx
@@ -2908,7 +2908,7 @@ namespace cppcanvas
 
             VectorOfOutDevStates    aStateStack;
 
-            ScopedVclPtr<VirtualDevice> aVDev = new VirtualDevice;
+            ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice() );
             aVDev->EnableOutput( false );
 
             // Setup VDev for state tracking and mapping
diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index 515b3c0..c088d48 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -437,7 +437,7 @@ IMPL_LINK( SvxJavaOptionsPage, DialogClosedHdl, DialogClosedEvent*, pEvt )
 
 IMPL_LINK_NOARG( SvxJavaOptionsPage, ExpertConfigHdl_Impl )
 {
-    ScopedVclPtr<CuiAboutConfigTabPage> m_pExpertConfigDlg = new CuiAboutConfigTabPage(this);
+    ScopedVclPtr<CuiAboutConfigTabPage> m_pExpertConfigDlg( new CuiAboutConfigTabPage(this) );
     m_pExpertConfigDlg->Reset();//initialize and reset function
 
     if( RET_OK == m_pExpertConfigDlg->Execute() )
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index 935b0b5..8b26870 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -252,7 +252,7 @@ namespace drawinglayer
             const Rectangle aPrimitiveRectangle(
                 basegfx::fround(aPrimitiveRange.getMinX()), basegfx::fround(aPrimitiveRange.getMinY()),
                 basegfx::fround(aPrimitiveRange.getMaxX()), basegfx::fround(aPrimitiveRange.getMaxY()));
-            ScopedVclPtr<VirtualDevice> aContentVDev = new VirtualDevice;
+            ScopedVclPtr<VirtualDevice> aContentVDev( new VirtualDevice() );
             MapMode aNewMapMode(pLastOutputDevice->GetMapMode());
 
             mpOutputDevice = aContentVDev.get();
@@ -2016,7 +2016,7 @@ namespace drawinglayer
                             const Rectangle aRectPixel(mpOutputDevice->LogicToPixel(aRectLogic));
                             Size aSizePixel(aRectPixel.GetSize());
                             const Point aEmptyPoint;
-                            ScopedVclPtr<VirtualDevice> aBufferDevice = new VirtualDevice;
+                            ScopedVclPtr<VirtualDevice> aBufferDevice( new VirtualDevice() );
                             const sal_uInt32 nMaxQuadratPixels(500000);
                             const sal_uInt32 nViewVisibleArea(aSizePixel.getWidth() * aSizePixel.getHeight());
                             double fReduceFactor(1.0);
diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx
index e06356c..e64f7d3 100644
--- a/drawinglayer/source/tools/converters.cxx
+++ b/drawinglayer/source/tools/converters.cxx
@@ -73,7 +73,7 @@ namespace drawinglayer
                 const Point aEmptyPoint;
                 const Size aSizePixel(nDiscreteWidth, nDiscreteHeight);
                 geometry::ViewInformation2D aViewInformation2D(rViewInformation2D);
-                ScopedVclPtr<VirtualDevice> maContent = new VirtualDevice;
+                ScopedVclPtr<VirtualDevice> maContent(new VirtualDevice());
 
                 // prepare vdev
                 maContent->SetOutputSizePixel(aSizePixel, false);
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index d795c0f..d775fb1 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1755,7 +1755,7 @@ SvxFont EditEngine::GetStandardSvxFont( sal_Int32 nPara )
 
 void EditEngine::StripPortions()
 {
-    ScopedVclPtr<VirtualDevice> aTmpDev = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice> aTmpDev( new VirtualDevice() );
     Rectangle aBigRect( Point( 0, 0 ), Size( 0x7FFFFFFF, 0x7FFFFFFF ) );
     if ( IsVertical() )
     {
diff --git a/extensions/source/propctrlr/propertyeditor.cxx b/extensions/source/propctrlr/propertyeditor.cxx
index 3585ba3..7e7bee0 100644
--- a/extensions/source/propctrlr/propertyeditor.cxx
+++ b/extensions/source/propctrlr/propertyeditor.cxx
@@ -96,6 +96,11 @@ namespace pcr
             m_aPropertyPageIds.swap( aEmpty );
         }
 
+        while ( !m_aHiddenPages.empty() )
+        {
+            m_aHiddenPages.begin()->second.pPage.disposeAndClear();
+            m_aHiddenPages.erase( m_aHiddenPages.begin() );
+        }
         m_aHiddenPages.clear();
     }
 
diff --git a/extensions/source/propctrlr/propertyeditor.hxx b/extensions/source/propctrlr/propertyeditor.hxx
index 2e2d6fd..a43ee8d 100644
--- a/extensions/source/propctrlr/propertyeditor.hxx
+++ b/extensions/source/propctrlr/propertyeditor.hxx
@@ -49,7 +49,7 @@ namespace pcr
         struct HiddenPage
         {
             sal_uInt16  nPos;
-            ScopedVclPtr<TabPage>    pPage;
+            VclPtr<TabPage>    pPage;
             HiddenPage() : nPos( 0 ), pPage( NULL ) { }
             HiddenPage( sal_uInt16 _nPos, TabPage* _pPage ) : nPos( _nPos ), pPage( _pPage ) { }
         };
diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx
index af7bf5d..07429f0 100644
--- a/forms/source/solar/control/navtoolbar.cxx
+++ b/forms/source/solar/control/navtoolbar.cxx
@@ -152,6 +152,8 @@ namespace frm
 
     void NavigationToolBar::dispose()
     {
+        for (auto i = m_aChildWins.begin(); i != m_aChildWins.end(); ++i)
+            i->disposeAndClear();
         m_aChildWins.clear();
         m_pToolbar.clear();
         vcl::Window::dispose();
diff --git a/forms/source/solar/inc/navtoolbar.hxx b/forms/source/solar/inc/navtoolbar.hxx
index ec66f92..79d1266 100644
--- a/forms/source/solar/inc/navtoolbar.hxx
+++ b/forms/source/solar/inc/navtoolbar.hxx
@@ -61,7 +61,7 @@ namespace frm
                                         m_pDescriptionProvider;
         ImageSize                       m_eImageSize;
         VclPtr<ImplNavToolBar>          m_pToolbar;
-        ::std::vector< ScopedVclPtr<vcl::Window> > m_aChildWins;
+        ::std::vector< VclPtr<vcl::Window> > m_aChildWins;
 
     public:
         NavigationToolBar(
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index f7a6318..6b65c70 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -158,7 +158,7 @@ void ScDocument::SetPrinter( SfxPrinter* pNewPrinter )
     }
     else
     {
-        ScopedVclPtr<SfxPrinter> pOld = pPrinter;
+        ScopedVclPtr<SfxPrinter> pOld( pPrinter );
         pPrinter = pNewPrinter;
         UpdateDrawPrinter();
         pPrinter->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
diff --git a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
index d0e181b..9a6282a 100644
--- a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
+++ b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
@@ -401,7 +401,7 @@ void ScZoomSliderWnd::DoPaint( const Rectangle& /*rRect*/ )
     Size aSliderWindowSize = GetOutputSizePixel();
     Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
 
-    ScopedVclPtr<VirtualDevice> pVDev = new VirtualDevice( *this );
+    ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice( *this ) );
     pVDev->SetOutputSizePixel( aSliderWindowSize );
 
     Rectangle   aSlider = aRect;
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx
index dd6df46..a78b114 100644
--- a/svtools/source/brwbox/brwbox1.cxx
+++ b/svtools/source/brwbox/brwbox1.cxx
@@ -58,8 +58,6 @@ namespace
     }
 }
 
-
-
 void BrowseBox::ConstructImpl( BrowserMode nMode )
 {
     OSL_TRACE( "BrowseBox: %p->ConstructImpl", this );
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index eb78198..b923ab3 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -1894,7 +1894,7 @@ bool GraphicObject::ImplDrawTiled( OutputDevice* pOut, const Rectangle& rArea, c
         // First combine very small bitmaps into a larger tile
 
 
-        ScopedVclPtr<VirtualDevice>   aVDev = new VirtualDevice;
+        ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice() );
         const int       nNumTilesInCacheX( (nTileCacheSize1D + rSizePixel.Width()-1) / rSizePixel.Width() );
         const int       nNumTilesInCacheY( (nTileCacheSize1D + rSizePixel.Height()-1) / rSizePixel.Height() );
 
diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx
index 52e2149..e144f6b 100644
--- a/svtools/source/graphic/provider.cxx
+++ b/svtools/source/graphic/provider.cxx
@@ -634,7 +634,7 @@ void ImplApplyFilterData( ::Graphic& rGraphic, uno::Sequence< beans::PropertyVal
     }
     else if ( ( rGraphic.GetType() == GRAPHIC_GDIMETAFILE ) && nImageResolution )
     {
-        ScopedVclPtr<VirtualDevice> aDummyVDev = new VirtualDevice;
+        ScopedVclPtr<VirtualDevice> aDummyVDev( new VirtualDevice() );
         GDIMetaFile aMtf( rGraphic.GetGDIMetaFile() );
         Size aMtfSize( OutputDevice::LogicToLogic( aMtf.GetPrefSize(), aMtf.GetPrefMapMode(), MAP_100TH_MM ) );
         if ( aMtfSize.Width() && aMtfSize.Height() )
diff --git a/svtools/source/misc/sampletext.cxx b/svtools/source/misc/sampletext.cxx
index a1cb7a8..889103d 100644
--- a/svtools/source/misc/sampletext.cxx
+++ b/svtools/source/misc/sampletext.cxx
@@ -1623,7 +1623,7 @@ OUString makeRepresentativeTextForFont(sal_Int16 nScriptType, const vcl::Font &r
 {
     OUString sRet(makeRepresentativeTextForLanguage(rFont.GetLanguage()));
 
-    ScopedVclPtr<VirtualDevice> aDevice = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice> aDevice( new VirtualDevice() );
     if (sRet.isEmpty() || (-1 != aDevice->HasGlyphs(rFont, sRet)))
     {
         aDevice->SetFont(rFont);
diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx
index 4f4ad26..b36ac6d 100644
--- a/svtools/source/table/gridtablerenderer.cxx
+++ b/svtools/source/table/gridtablerenderer.cxx
@@ -86,7 +86,7 @@ namespace svt { namespace table
 
             Point const aBitmapPos( 0, 0 );
             Size const aBitmapSize( nSortIndicatorWidth, nSortIndicatorHeight );
-            ScopedVclPtr<VirtualDevice> aDevice = new VirtualDevice( i_device, 0, 0 );
+            ScopedVclPtr<VirtualDevice> aDevice( new VirtualDevice( i_device, 0, 0 ) );
             aDevice->SetOutputSizePixel( aBitmapSize );
 
             DecorationView aDecoView( aDevice.get() );
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 18cd8dd..8cc8d9d 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1892,7 +1892,7 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString
         {
             Size aSizePixel;
             sal_uLong nColorCount,nBitsPerPixel,nNeededMem,nMaxMem;
-            ScopedVclPtr<VirtualDevice> aVirDev = new VirtualDevice;
+            ScopedVclPtr<VirtualDevice> aVirDev( new VirtualDevice() );
 
             nMaxMem = 1024;
             nMaxMem *= 1024; // In Bytes
diff --git a/vcl/source/filter/sgfbram.cxx b/vcl/source/filter/sgfbram.cxx
index d0fe0f1..95ae3fa 100644
--- a/vcl/source/filter/sgfbram.cxx
+++ b/vcl/source/filter/sgfbram.cxx
@@ -390,7 +390,7 @@ Color Hpgl2SvFarbe( sal_uInt8 nFarb )
 
 bool SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMtf)
 {
-    ScopedVclPtr<VirtualDevice> aOutDev = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice> aOutDev( new VirtualDevice() );
     SgfVector aVect;
     sal_uInt8      nFarb;
     sal_uInt8      nFrb0=7;
diff --git a/vcl/source/filter/sgvmain.cxx b/vcl/source/filter/sgvmain.cxx
index f40afac..88020be 100644
--- a/vcl/source/filter/sgvmain.cxx
+++ b/vcl/source/filter/sgvmain.cxx
@@ -794,7 +794,7 @@ bool SgfFilterSDrw( SvStream& rInp, SgfHeader&, SgfEntry&, GDIMetaFile& rMtf )
 {
     bool          bRet = false;
     PageType      aPage;
-    ScopedVclPtr<VirtualDevice> aOutDev = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice> aOutDev( new VirtualDevice() );
     OutputDevice* pOutDev;
     sal_uLong         nStdPos;
     sal_uLong         nCharPos;
diff --git a/vcl/source/filter/sgvtext.cxx b/vcl/source/filter/sgvtext.cxx
index d3b2ed7..19d4620 100644
--- a/vcl/source/filter/sgvtext.cxx
+++ b/vcl/source/filter/sgvtext.cxx
@@ -660,7 +660,7 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType&
                 double, double,
                 UCHAR* cLine, bool TextFit)
 {
-    ScopedVclPtr<VirtualDevice> vOut = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice> vOut( new VirtualDevice() );
     UCHAR        c,c0;
     bool         First;               // first char ?
     sal_uInt8    Just = 0;            // paragraph format
diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx
index 4edff5d..c1b33ce 100644
--- a/vcl/source/gdi/cvtsvm.cxx
+++ b/vcl/source/gdi/cvtsvm.cxx
@@ -498,7 +498,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
 
     LineInfo            aLineInfo( LINE_NONE, 0 );
     ::std::stack< LineInfo* >    aLIStack;
-    ScopedVclPtr<VirtualDevice>  aFontVDev = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice>  aFontVDev( new VirtualDevice() );
     rtl_TextEncoding    eActualCharSet = osl_getThreadTextEncoding();
     bool                bFatLine = false;
 
@@ -1374,7 +1374,7 @@ void SVMConverter::ImplConvertToSVM1( SvStream& rOStm, GDIMetaFile& rMtf )
     rtl_TextEncoding    eActualCharSet = osl_getThreadTextEncoding();
     const Size          aPrefSize( rMtf.GetPrefSize() );
     bool                bRop_0_1 = false;
-    ScopedVclPtr<VirtualDevice>  aSaveVDev = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice>  aSaveVDev( new VirtualDevice() );
     Color               aLineCol( COL_BLACK );
     ::std::stack< Color* >  aLineColStack;
 
@@ -2311,7 +2311,7 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf,
 
                 {
                     // write actions for hatch
-                    ScopedVclPtr<VirtualDevice> aVDev = new VirtualDevice;
+                    ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice() );
                     GDIMetaFile     aTmpMtf;
 
                     aVDev->AddHatchActions( rPolyPoly, rHatch, aTmpMtf );
diff --git a/vcl/source/gdi/gdimetafiletools.cxx b/vcl/source/gdi/gdimetafiletools.cxx
index 32b7a83..4bb3240 100644
--- a/vcl/source/gdi/gdimetafiletools.cxx
+++ b/vcl/source/gdi/gdimetafiletools.cxx
@@ -161,7 +161,7 @@ namespace
         // in pixel mode for alpha channel painting (black is transparent,
         // white to paint 100% opacity)
         const Size aSizePixel(rBitmapEx.GetSizePixel());
-        ScopedVclPtr<VirtualDevice> aVDev = new VirtualDevice;
+        ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice() );
 
         aVDev->SetOutputSizePixel(aSizePixel);
         aVDev->EnableMapMode(false);
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 9772a57..0720b7f 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -723,7 +723,7 @@ void GDIMetaFile::Move( long nX, long nY )
 {
     const Size      aBaseOffset( nX, nY );
     Size            aOffset( aBaseOffset );
-    ScopedVclPtr<VirtualDevice>   aMapVDev = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice> aMapVDev( new VirtualDevice() );
 
     aMapVDev->EnableOutput( false );
     aMapVDev->SetMapMode( GetPrefMapMode() );
@@ -757,7 +757,7 @@ void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY )
 {
     const Size      aBaseOffset( nX, nY );
     Size            aOffset( aBaseOffset );
-    ScopedVclPtr<VirtualDevice>   aMapVDev = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice> aMapVDev( new VirtualDevice() );
 
     aMapVDev->EnableOutput( false );
     aMapVDev->SetReferenceDevice( nDPIX, nDPIY );
@@ -825,7 +825,7 @@ void GDIMetaFile::Scale( const Fraction& rScaleX, const Fraction& rScaleY )
 void GDIMetaFile::Clip( const Rectangle& i_rClipRect )
 {
     Rectangle aCurRect( i_rClipRect );
-    ScopedVclPtr<VirtualDevice>   aMapVDev = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice> aMapVDev( new VirtualDevice() );
 
     aMapVDev->EnableOutput( false );
     aMapVDev->SetMapMode( GetPrefMapMode() );
@@ -892,7 +892,7 @@ void GDIMetaFile::ImplAddGradientEx( GDIMetaFile&         rMtf,
                                      const Gradient&      rGrad     )
 {
     // Generate comment, GradientEx and Gradient actions (within DrawGradient)
-    ScopedVclPtr<VirtualDevice> aVDev = new VirtualDevice( rMapDev, 0 );
+    ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice( rMapDev, 0 ) );
     aVDev->EnableOutput( false );
     GDIMetaFile aGradMtf;
 
@@ -917,7 +917,7 @@ void GDIMetaFile::Rotate( long nAngle10 )
     if( nAngle10 )
     {
         GDIMetaFile     aMtf;
-        ScopedVclPtr<VirtualDevice>   aMapVDev = new VirtualDevice;
+        ScopedVclPtr<VirtualDevice> aMapVDev( new VirtualDevice() );
         const double    fAngle = F_PI1800 * nAngle10;
         const double    fSin = sin( fAngle );
         const double    fCos = cos( fAngle );
@@ -1400,7 +1400,7 @@ static void ImplActionBounds( Rectangle& o_rOutBounds,
 Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHairline ) const
 {
     GDIMetaFile     aMtf;
-    ScopedVclPtr<VirtualDevice> aMapVDev = new VirtualDevice( i_rReference );
+    ScopedVclPtr<VirtualDevice> aMapVDev( new VirtualDevice( i_rReference ) );
 
     aMapVDev->EnableOutput( false );
     aMapVDev->SetMapMode( GetPrefMapMode() );
@@ -2890,7 +2890,7 @@ SvStream& GDIMetaFile::Write( SvStream& rOStm )
 bool GDIMetaFile::CreateThumbnail(BitmapEx& rBitmapEx, sal_uInt32 nMaximumExtent, BmpConversion eColorConversion, long nScaleFlag) const
 {
     // initialization seems to be complicated but is used to avoid rounding errors
-    ScopedVclPtr<VirtualDevice>  aVDev = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice() );
     const Point     aNullPt;
     const Point     aTLPix( aVDev->LogicToPixel( aNullPt, GetPrefMapMode() ) );
     const Point     aBRPix( aVDev->LogicToPixel( Point( GetPrefSize().Width() - 1, GetPrefSize().Height() - 1 ), GetPrefMapMode() ) );
diff --git a/vcl/source/gdi/impanmvw.cxx b/vcl/source/gdi/impanmvw.cxx
index e271ae4..b225280 100644
--- a/vcl/source/gdi/impanmvw.cxx
+++ b/vcl/source/gdi/impanmvw.cxx
@@ -153,7 +153,7 @@ void ImplAnimView::getPosSize( const AnimationBitmap& rAnm, Point& rPosPix, Size
 
 void ImplAnimView::drawToPos( sal_uLong nPos )
 {
-    ScopedVclPtr<VirtualDevice> aVDev = new VirtualDevice;
+    ScopedVclPtrInstance<VirtualDevice> aVDev;
     std::unique_ptr<vcl::Region> xOldClip(!maClip.IsNull() ? new vcl::Region( mpOut->GetClipRegion() ) : NULL);
 
     aVDev->SetOutputSizePixel( maSzPix, false );
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index a970919..b7d7b36 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -467,7 +467,7 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters)
         if(maEx.IsEmpty())
         {
             // calculate size
-            ScopedVclPtr<VirtualDevice> aVDev = new VirtualDevice;
+            ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice() );
             Size aDrawSize(aVDev->LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode()));
 
             if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height())
diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx
index a0ac4c3..6775985 100644
--- a/vcl/source/gdi/impvect.cxx
+++ b/vcl/source/gdi/impvect.cxx
@@ -717,7 +717,7 @@ bool ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf,
         if( rMtf.GetActionSize() )
         {
             MapMode         aMap( MAP_100TH_MM );
-            ScopedVclPtr<VirtualDevice>   aVDev = new VirtualDevice;
+            ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice() );
             const Size      aLogSize1( aVDev->PixelToLogic( Size( 1, 1 ), aMap ) );
 
             rMtf.SetPrefMapMode( aMap );
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index c71c52f..e7edf47 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -10938,7 +10938,7 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit& rObject )
     sal_Int32 nFunctionObject = createObject();
     CHECK_RETURN( updateObject( nFunctionObject ) );
 
-    ScopedVclPtr<VirtualDevice> aDev = new VirtualDevice;
+    ScopedVclPtr<VirtualDevice> aDev( new VirtualDevice() );
     aDev->SetOutputSizePixel( rObject.m_aSize );
     aDev->SetMapMode( MapMode( MAP_PIXEL ) );
     if( m_aContext.ColorMode == PDFWriter::DrawGreyscale )
diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx
index 5a556c4..2ea36cc 100644
--- a/vcl/source/gdi/print2.cxx
+++ b/vcl/source/gdi/print2.cxx
@@ -728,7 +728,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
         ConnectedComponents aBackgroundComponent;
 
         // create an OutputDevice to record mapmode changes and the like
-        ScopedVclPtr<VirtualDevice> aMapModeVDev = new VirtualDevice;
+        ScopedVclPtr<VirtualDevice> aMapModeVDev( new VirtualDevice() );
         aMapModeVDev->mnDPIX = mnDPIX;
         aMapModeVDev->mnDPIY = mnDPIY;
         aMapModeVDev->EnableOutput(false);
@@ -1155,10 +1155,10 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
                         Point           aDstPtPix( aBoundRect.TopLeft() );
                         Size            aDstSzPix;
 
-                        ScopedVclPtr<VirtualDevice> aMapVDev = new VirtualDevice;   // here, we record only mapmode information
+                        ScopedVclPtr<VirtualDevice> aMapVDev( new VirtualDevice() );   // here, we record only mapmode information
                         aMapVDev->EnableOutput(false);
 
-                        ScopedVclPtr<VirtualDevice> aPaintVDev = new VirtualDevice; // into this one, we render.
+                        ScopedVclPtr<VirtualDevice> aPaintVDev( new VirtualDevice() ); // into this one, we render.
                         aPaintVDev->SetBackground( aBackgroundComponent.aBgColor );
 
                         rOutMtf.AddAction( new MetaPushAction( PushFlags::MAPMODE ) );
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 711a64a..289fb1b 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -410,7 +410,7 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const
                 // If the visible part has been clipped, we have to create a
                 // Bitmap with the correct size in which we copy the clipped
                 // Bitmap to the correct position.
-                ScopedVclPtr<VirtualDevice> aVDev = new VirtualDevice( *this );
+                ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice( *this ) );
 
                 if ( aVDev->SetOutputSizePixel( aRect.GetSize() ) )
                 {
diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx
index 7cff08f..81e8d8c 100644
--- a/vcl/source/outdev/transparent.cxx
+++ b/vcl/source/outdev/transparent.cxx
@@ -431,7 +431,7 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly,
 
         if( !bDrawn )
         {
-            ScopedVclPtr<VirtualDevice> aVDev = new VirtualDevice( *this, 1 );
+            ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice( *this, 1 ) );
             const Size aDstSz( aDstRect.GetSize() );
             const sal_uInt8 cTrans = (sal_uInt8) MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 );
 
diff --git a/vcl/source/outdev/wallpaper.cxx b/vcl/source/outdev/wallpaper.cxx
index 87f4314..5d01f31 100644
--- a/vcl/source/outdev/wallpaper.cxx
+++ b/vcl/source/outdev/wallpaper.cxx
@@ -129,7 +129,7 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY,
         {
             if( !pCached && !rWallpaper.GetColor().GetTransparency() )
             {
-                ScopedVclPtr<VirtualDevice> aVDev = new VirtualDevice( *this );
+                ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice( *this ) );
                 aVDev->SetBackground( rWallpaper.GetColor() );
                 aVDev->SetOutputSizePixel( Size( nBmpWidth, nBmpHeight ) );
                 aVDev->DrawBitmapEx( Point(), aBmpEx );
commit 8fb4672aef888fc5a582ca9508799ecdbe777c42
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Mar 20 17:24:08 2015 +0000

    ScopedVclPtr: needs an = operator to make life flow.
    
    Without this, assigning to a ScopedVclPtr instance thus:
    
        pScopedVclPtr = new Foo();
    
    constructed a new intermediate ScopedVCLPtr, used a default assignment
    operator, unhelpfully disposing the new Foo before it could make it to
    pScopedVclPtr => add operator, and hide problematic constructors.
    
    Change-Id: Icc0da962938bf115eac0c24a6a76cfeb66ddf23a

diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index c75d421..3e0de76 100644
--- a/include/vcl/vclptr.hxx
+++ b/include/vcl/vclptr.hxx
@@ -81,7 +81,6 @@ namespace vcl { class Window; }
 template <class reference_type>
 class VclPtr
 {
-
     ::rtl::Reference<reference_type> m_rInnerRef;
 
 public:
@@ -211,7 +210,6 @@ public:
         return (m_rInnerRef < handle.m_rInnerRef);
     }
 
-
     /** Needed to place VclPtr's into STL collection.
      */
     inline bool SAL_CALL operator> (const VclPtr<reference_type> & handle) const
@@ -231,20 +229,28 @@ public:
         : VclPtr<reference_type>()
     {}
 
-
-    /** Constructor...
+    /** Constructor
      */
     inline ScopedVclPtr (reference_type * pBody)
         : VclPtr<reference_type>(pBody)
     {}
 
-
     /** Copy constructor...
      */
     inline ScopedVclPtr (const VclPtr<reference_type> & handle)
         : VclPtr<reference_type>(handle)
     {}
 
+    /**
+       Assignment that releases the last reference.
+     */
+    inline ScopedVclPtr<reference_type>& SAL_CALL operator= (reference_type * pBody)
+    {
+        VclPtr<reference_type>::disposeAndClear();
+        VclPtr<reference_type>::set(pBody);
+        return *this;
+    }
+
     /** Up-casting conversion constructor: Copies interface reference.
 
         Does not work for up-casts to ambiguous bases.  For the special case of
@@ -265,7 +271,11 @@ public:
     {
         VclPtr<reference_type>::disposeAndClear();
     }
-
+private:
+    // Most likely we don't want this default copy-construtor.
+    ScopedVclPtr (const ScopedVclPtr<reference_type> &) SAL_DELETED_FUNCTION;
+    // And certainly we don't want a default assignment operator.
+    ScopedVclPtr<reference_type>& SAL_CALL operator= (const ScopedVclPtr<reference_type> &) SAL_DELETED_FUNCTION;
 };
 
 #endif // INCLUDED_VCL_PTR_HXX
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index 9ff0df6..4a65042 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -159,6 +159,7 @@ public:
 private:
     void            ImplTrack( const Point& rScreenPos );
 
+    virtual void    dispose() SAL_OVERRIDE;
     virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     virtual void    Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     virtual void    Paint( const Rectangle& rRect ) SAL_OVERRIDE;
@@ -176,6 +177,11 @@ ImplTabSizer::ImplTabSizer( TabBar* pParent, WinBits nWinStyle )
     SetSizePixel(Size(7 * nScaleFactor, 0));
 }
 
+void ImplTabSizer::dispose()
+{
+    vcl::Window::dispose();
+}
+
 void ImplTabSizer::ImplTrack( const Point& rScreenPos )
 {
     TabBar* pParent = GetParent();
diff --git a/vcl/README.lifecycle b/vcl/README.lifecycle
index 201e212..1ee7eab 100644
--- a/vcl/README.lifecycle
+++ b/vcl/README.lifecycle
@@ -67,6 +67,14 @@ to lingering pointers to freed objects.
 	'dispose' methods, in order to provide a minimal initial
 	behavioral change.
 
+	As such a VclPtr can have three states:
+
+	VclPtr<PushButton> pButton;
+	...
+	assert (pButton == nullptr || !pButton);    // null
+	assert (pButton && !pButton->IsDisposed()); // alive
+	assert (pButton &&  pButton->IsDisposed()); // disposed
+
 ** ScopedVclPtr - making disposes easier
 
 	While replacing existing code with new, it can be a bit
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 2af9470..b04bad1 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -2264,8 +2264,7 @@ vcl::Font Window::GetPointFont() const
 
 void Window::Show( bool bVisible, sal_uInt16 nFlags )
 {
-
-    if ( mpWindowImpl->mbVisible == bVisible )
+    if ( IsDisposed() || mpWindowImpl->mbVisible == bVisible )
         return;
 
     ImplDelData aDogTag( this );
commit d1091fd50adb1c01d1b1393fd662278611f9e7e1
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Mar 20 15:00:03 2015 +0000

    re-insert erroneously converted delete calls.
    
    Change-Id: Iebdf2af3866d884289f6913646106fe3f2d4dde5

diff --git a/cui/source/dialogs/iconcdlg.cxx b/cui/source/dialogs/iconcdlg.cxx
index cb80961..4e0c09b 100644
--- a/cui/source/dialogs/iconcdlg.cxx
+++ b/cui/source/dialogs/iconcdlg.cxx
@@ -242,7 +242,7 @@ void IconChoiceDialog::dispose()
 
             if ( pData->bOnDemand )
                 delete &pData->pPage->GetItemSet();
-            delete pData->pPage;
+            pData->pPage.disposeAndClear();
         }
         delete pData;
     }
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 98833f9..808a80c 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -81,7 +81,7 @@ short Class::Execute()                              \
 
 class VclAbstractDialog2_Impl : public VclAbstractDialog2
 {
-    VclPtr<Dialog>         m_pDlg;
+    ScopedVclPtr<Dialog> m_pDlg;
     Link            m_aEndDlgHdl;
 public:
                     VclAbstractDialog2_Impl( Dialog* p ) : m_pDlg( p ) {}
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 6262d24..ab31348 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -465,7 +465,7 @@ static bool lcl_isOptionHidden( sal_uInt16 _nPageId, const SvtOptionsDialogOptio
 
 struct OptionsPageInfo
 {
-    VclPtr<SfxTabPage>  m_pPage;
+    ScopedVclPtr<SfxTabPage> m_pPage;
     sal_uInt16          m_nPageId;
     OUString       m_sPageURL;
     OUString       m_sEventHdl;
diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx
index 2125cbd..da52057 100644
--- a/dbaccess/source/ui/querydesign/JoinTableView.cxx
+++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx
@@ -1535,6 +1535,10 @@ void OJoinTableView::clearLayoutInformation()
 
     m_aTableMap.clear();
 
+    for(auto i = m_vTableConnection.begin();
+             i != m_vTableConnection.end(); ++i)
+        i->disposeAndClear();
+
     m_vTableConnection.clear();
 }
 
diff --git a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx
index 85f3ff2..02c59c3 100644
--- a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx
+++ b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx
@@ -33,6 +33,7 @@ OQueryTabConnUndoAction::~OQueryTabConnUndoAction()
     if (m_bOwnerOfConn)
     {   // I have the connection -> delete
         m_pOwner->DeselectConn(m_pConnection);
+        m_pConnection.disposeAndClear();
     }
 }
 
diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx
index 1745890..d898780 100644
--- a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx
+++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx
@@ -56,6 +56,7 @@ OQueryTabWinUndoAct::~OQueryTabWinUndoAct()
 
         if ( m_pTabWin )
             m_pTabWin->clearListBox();
+        m_pTabWin.disposeAndClear();
 
         // and of course the corresponding connections
         auto aIter = m_vTableConnection.begin();
@@ -63,6 +64,7 @@ OQueryTabWinUndoAct::~OQueryTabWinUndoAct()
         for(;aIter != aEnd;++aIter)
         {
             m_pOwner->DeselectConn(*aIter);
+            aIter->disposeAndClear();
         }
         m_vTableConnection.clear();
     }
diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
index a031b47..53b5380 100644
--- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
+++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
@@ -98,6 +98,8 @@ TheExtensionManager::TheExtensionManager( vcl::Window *pParent,
 
 TheExtensionManager::~TheExtensionManager()
 {
+    m_pUpdReqDialog.disposeAndClear();
+    m_pExtMgrDialog.disposeAndClear();
     delete m_pExecuteCmdQueue;
 }
 
diff --git a/extensions/source/propctrlr/propertyeditor.hxx b/extensions/source/propctrlr/propertyeditor.hxx
index a43ee8d..2e2d6fd 100644
--- a/extensions/source/propctrlr/propertyeditor.hxx
+++ b/extensions/source/propctrlr/propertyeditor.hxx
@@ -49,7 +49,7 @@ namespace pcr
         struct HiddenPage
         {
             sal_uInt16  nPos;
-            VclPtr<TabPage>    pPage;
+            ScopedVclPtr<TabPage>    pPage;
             HiddenPage() : nPos( 0 ), pPage( NULL ) { }
             HiddenPage( sal_uInt16 _nPos, TabPage* _pPage ) : nPos( _nPos ), pPage( _pPage ) { }
         };
diff --git a/forms/source/solar/inc/navtoolbar.hxx b/forms/source/solar/inc/navtoolbar.hxx
index e5c2627..ec66f92 100644
--- a/forms/source/solar/inc/navtoolbar.hxx
+++ b/forms/source/solar/inc/navtoolbar.hxx
@@ -61,7 +61,7 @@ namespace frm
                                         m_pDescriptionProvider;
         ImageSize                       m_eImageSize;
         VclPtr<ImplNavToolBar>          m_pToolbar;
-        ::std::vector< VclPtr<vcl::Window> >        m_aChildWins;
+        ::std::vector< ScopedVclPtr<vcl::Window> > m_aChildWins;
 
     public:
         NavigationToolBar(
diff --git a/fpicker/source/office/commonpicker.cxx b/fpicker/source/office/commonpicker.cxx
index 95ee24b..f237568 100644
--- a/fpicker/source/office/commonpicker.cxx
+++ b/fpicker/source/office/commonpicker.cxx
@@ -148,7 +148,11 @@ namespace svt
         {
             stopWindowListening();
 
-            m_pDlg.clear();
+            if ( !bDialogDying )    // it's the parent which is dying -> delete the dialog
+                m_pDlg.disposeAndClear();
+            else
+                m_pDlg.clear();
+
             m_xWindow = NULL;
             m_xDialogParent = NULL;
         }
diff --git a/framework/inc/classes/fwktabwindow.hxx b/framework/inc/classes/fwktabwindow.hxx
index b041482..ed3d82c 100644
--- a/framework/inc/classes/fwktabwindow.hxx
+++ b/framework/inc/classes/fwktabwindow.hxx
@@ -78,7 +78,7 @@ public:
 struct TabEntry
 {
     sal_Int32           m_nIndex;
-    VclPtr<FwkTabPage>  m_pPage;
+    ScopedVclPtr<FwkTabPage>  m_pPage;
     OUString            m_sPageURL;
     css::uno::Reference< css::awt::XContainerWindowEventHandler > m_xEventHdl;
 
diff --git a/include/sfx2/fcontnr.hxx b/include/sfx2/fcontnr.hxx
index 3ae4237..1c325b9 100644
--- a/include/sfx2/fcontnr.hxx
+++ b/include/sfx2/fcontnr.hxx
@@ -57,7 +57,7 @@ public:
 
 class SfxFrameWindow
 {
-    VclPtr<vcl::Window>     pWindow;
+    ScopedVclPtr<vcl::Window> pWindow;
 public:
                 SfxFrameWindow( vcl::Window *pWin )
                  : pWindow( pWin )
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 44f6969..216c3c8 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -58,7 +58,7 @@ class ScTextImportOptionsDlg;
 class ScCondFormatManagerDlg;
 
 #define DECL_ABSTDLG_BASE(Class,DialogClass)        \
-    VclPtr<DialogClass> pDlg;                       \
+    ScopedVclPtr<DialogClass> pDlg;                 \
 public:                                             \
                     Class( DialogClass* p)          \
                      : pDlg(p)                      \
@@ -66,8 +66,8 @@ public:                                             \
     virtual         ~Class();                       \
     virtual short   Execute() SAL_OVERRIDE ;
 
-#define DECL_ABSTDLG2_BASE(Class,DialogClass)        \
-    VclPtr<DialogClass> pDlg;                       \
+#define DECL_ABSTDLG2_BASE(Class,DialogClass)       \
+    ScopedVclPtr<DialogClass> pDlg;                 \
 public:                                             \
                     Class( DialogClass* p)          \
                      : pDlg(p)                      \
diff --git a/sc/source/ui/drawfunc/fupoor.cxx b/sc/source/ui/drawfunc/fupoor.cxx
index 28bf18e..f0aa72a 100644
--- a/sc/source/ui/drawfunc/fupoor.cxx
+++ b/sc/source/ui/drawfunc/fupoor.cxx
@@ -53,6 +53,7 @@ FuPoor::~FuPoor()
 {
     aDragTimer.Stop();
     aScrollTimer.Stop();
+    pDialog.disposeAndClear();
 }
 
 void FuPoor::Activate()
diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx
index b7fe534..3ba9b48 100644
--- a/sd/source/ui/dlg/sddlgfact.hxx
+++ b/sd/source/ui/dlg/sddlgfact.hxx
@@ -23,7 +23,7 @@
 #include <sfx2/basedlgs.hxx>
 
 #define DECL_ABSTDLG_BASE(Class,DialogClass)        \
-    VclPtr<DialogClass> pDlg;                       \
+    ScopedVclPtr<DialogClass> pDlg;                 \
 public:                                             \
                     Class( DialogClass* p)          \
                      : pDlg(p)                      \
diff --git a/sd/source/ui/func/fupoor.cxx b/sd/source/ui/func/fupoor.cxx
index f3d94ef..9d1da08 100644
--- a/sd/source/ui/func/fupoor.cxx
+++ b/sd/source/ui/func/fupoor.cxx
@@ -100,7 +100,8 @@ FuPoor::~FuPoor()
 {
     aDragTimer.Stop();
     aScrollTimer.Stop();
-    aDelayToScrollTimer.Stop ();
+    aDelayToScrollTimer.Stop();
+    pDialog.disposeAndClear();
 }
 
 void FuPoor::Activate()
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index 4d265d7..ccaebb1 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -117,6 +117,7 @@ ThumbnailViewItem::ThumbnailViewItem(ThumbnailView &rView, sal_uInt16 nId)
 
 ThumbnailViewItem::~ThumbnailViewItem()
 {
+    mpTitleED.disposeAndClear();
     if( mpxAcc )
     {
         static_cast< ThumbnailViewItemAcc* >( mpxAcc->get() )->ParentDestroyed();
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 6a6e4b5..285e618 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -712,6 +712,8 @@ SfxSingleTabDialog::~SfxSingleTabDialog()
 
 void SfxSingleTabDialog::dispose()
 {
+    pImpl->m_pSfxPage.disposeAndClear();
+    pImpl->m_pLine.disposeAndClear();
     delete pImpl;
     pOKBtn.clear();
     pCancelBtn.clear();
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index 88377b3..2b1177a 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -150,8 +150,11 @@ SfxInfoBarWindow::~SfxInfoBarWindow()
 
 void SfxInfoBarWindow::dispose()
 {
-    m_pMessage.clear();
-    m_pCloseBtn.clear();
+    for ( auto it = m_aActionBtns.begin( ); it != m_aActionBtns.end( ); ++it )
+        it->disposeAndClear();
+
+    m_pMessage.disposeAndClear();
+    m_pCloseBtn.disposeAndClear();
     m_aActionBtns.clear( );
     vcl::Window::dispose();
 }
@@ -247,6 +250,8 @@ SfxInfoBarContainerWindow::~SfxInfoBarContainerWindow()
 
 void SfxInfoBarContainerWindow::dispose()
 {
+    for ( auto it = m_pInfoBars.begin( ); it != m_pInfoBars.end( ); ++it )
+        it->disposeAndClear();
     m_pInfoBars.clear( );
     Window::dispose();
 }
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index b1c8bf0..cbe8217 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -765,6 +765,7 @@ SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
     if ( pStyleSheetPool )
         EndListening(*pStyleSheetPool);
     pStyleSheetPool = NULL;
+    pTreeBox.disposeAndClear();
     delete pIdle;
     if ( m_pDeletionWatcher )
         m_pDeletionWatcher->signal();
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index 2df93f1..9ff0df6 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -328,13 +328,13 @@ IMPL_LINK_NOARG(TabBarEdit, ImplEndTimerHdl)
 
 struct TabBar_Impl
 {
-    VclPtr<ImplTabSizer>  mpSizer;
-    VclPtr<ImplTabButton> mpFirstButton;
-    VclPtr<ImplTabButton> mpPrevButton;
-    VclPtr<ImplTabButton> mpNextButton;
-    VclPtr<ImplTabButton> mpLastButton;
-    VclPtr<TabBarEdit>    mpEdit;
-    ImplTabBarList        mpItemList;
+    ScopedVclPtr<ImplTabSizer>  mpSizer;
+    ScopedVclPtr<ImplTabButton> mpFirstButton;
+    ScopedVclPtr<ImplTabButton> mpPrevButton;
+    ScopedVclPtr<ImplTabButton> mpNextButton;
+    ScopedVclPtr<ImplTabButton> mpLastButton;
+    ScopedVclPtr<TabBarEdit>    mpEdit;
+    ImplTabBarList              mpItemList;
 
     svt::AccessibleFactoryAccess  maAccessibleFactory;
 
@@ -347,22 +347,12 @@ struct TabBar_Impl
             delete mpItemList[i];
         }
         mpItemList.clear();
-
-        mpPrevBtn.disposeAndClear();
-        mpNextBtn.disposeAndClear();
-        mpFirstBtn.disposeAndClear();
-        mpLastBtn.disposeAndClear();
-        mpEdit.disposeAndClear();
     }
 
     sal_uInt16 getItemSize()
     {
         return static_cast<sal_uInt16>(mpItemList.size());
     }
-    ~TabBar_Impl()
-    {
-        mpSizer.disposeAndClear();
-    }
 };
 
 TabBar::TabBar( vcl::Window* pParent, WinBits nWinStyle ) :
diff --git a/svtools/source/dialogs/roadmapwizard.cxx b/svtools/source/dialogs/roadmapwizard.cxx
index 411c9b0..87c63f0 100644
--- a/svtools/source/dialogs/roadmapwizard.cxx
+++ b/svtools/source/dialogs/roadmapwizard.cxx
@@ -55,7 +55,7 @@ namespace svt
 
     struct RoadmapWizardImpl : public RoadmapWizardTypes
     {
-        VclPtr<ORoadmap>    pRoadmap;
+        ScopedVclPtr<ORoadmap> pRoadmap;
         Paths               aPaths;
         PathId              nActivePath;
         StateDescriptions   aStateDescriptors;
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 66984db..403fa39 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -643,8 +643,10 @@ DbCellControl::~DbCellControl()
 {
     lcl_clearBroadCaster(m_pModelChangeBroadcaster);
     lcl_clearBroadCaster(m_pFieldChangeBroadcaster);
-}
 
+    m_pWindow.disposeAndClear();
+    m_pPainter.disposeAndClear();
+}
 
 void DbCellControl::implValuePropertyChanged( )
 {
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx
index 349da44..3460eca 100644
--- a/svx/source/form/datanavi.cxx
+++ b/svx/source/form/datanavi.cxx
@@ -1436,6 +1436,9 @@ namespace svxform
         m_pSubmissionPage.clear();
         m_pBindingPage.clear();
 
+        sal_Int32 i, nCount = m_aPageList.size();
+        for ( i = 0; i < nCount; ++i )
+            m_aPageList[i].disposeAndClear();
         m_aPageList.clear();
 
         Reference< XFrameActionListener > xListener(
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx
index 16cd697..5f7a6fd 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -119,7 +119,11 @@ SwAddressControl_Impl::~SwAddressControl_Impl()
 
 void SwAddressControl_Impl::dispose()
 {
+    for(auto aTextIter = m_aFixedTexts.begin(); aTextIter != m_aFixedTexts.end(); ++aTextIter)
+        aTextIter->disposeAndClear();
     m_aFixedTexts.clear();
+    for(auto aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter)
+        aEditIter->disposeAndClear();
     m_aEdits.clear();
     m_pScrollBar.clear();
     m_pWindow.clear();
@@ -132,7 +136,11 @@ void SwAddressControl_Impl::SetData(SwCSVData& rDBData)
     //when the address data is updated then remove the controls an build again
     if(m_aFixedTexts.size())
     {
+        for(auto aTextIter = m_aFixedTexts.begin(); aTextIter != m_aFixedTexts.end(); ++aTextIter)
+            aTextIter->disposeAndClear();
         m_aFixedTexts.clear();
+        for(auto aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter)
+            aEditIter->disposeAndClear();
         m_aEdits.clear();
         m_bNoDataSet = true;
     }
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index 538163d..42b9e33 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -989,6 +989,13 @@ SwAssignFieldsControl::~SwAssignFieldsControl()
 
 void SwAssignFieldsControl::dispose()
 {
+    for(auto aFIIter = m_aFieldNames.begin(); aFIIter != m_aFieldNames.end(); ++aFIIter)
+        aFIIter->disposeAndClear();
+    for(auto aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter)
+        aLBIter->disposeAndClear();
+    for(auto aFIIter = m_aPreviews.begin(); aFIIter != m_aPreviews.end(); ++aFIIter)
+        aFIIter->disposeAndClear();
+
     m_aFieldNames.clear();
     m_aMatches.clear();
     m_aPreviews.clear();
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index a65a7cb..68fa68a 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -595,6 +595,7 @@ void AbstractSwWordCountFloatDlg_Impl::SetCounts(const SwDocStat &rCurrCnt, cons
 
 AbstractMailMergeWizard_Impl::~AbstractMailMergeWizard_Impl()
 {
+    pDlg.disposeAndClear();
 }
 
 void AbstractMailMergeWizard_Impl::StartExecuteModal( const Link& rEndDialogHdl )
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index ea38f71..4ec9fa6 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -48,7 +48,7 @@ class DropDownFieldDialog;
 
 #define DECL_ABSTDLG_BASE(Class,DialogClass)        \
 protected:                                          \
-    VclPtr<DialogClass> pDlg;                       \
+    ScopedVclPtr<DialogClass> pDlg;                 \
 public:                                             \
                     Class( DialogClass* p)          \
                      : pDlg(p)                      \
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index e0fd483..e65a904 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -2789,6 +2789,8 @@ void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL)
 
     if(pForm)
     {
+        for (ctrl_iterator iter = aControlList.begin(); iter != aControlList.end(); ++iter)
+            iter->disposeAndClear();
         //apply current level settings to the form
         for (auto it = aControlList.begin(); it != aControlList.end(); ++it)
              it->disposeAndClear();
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index b16c1c6..6f2404a 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -193,6 +193,7 @@ void SwPostItMgr::CheckForRemovedPostIts()
             mvPostItFlds.remove(*it);
             if (GetActiveSidebarWin() == p->pPostIt)
                 SetActiveSidebarWin(0);
+            p->pPostIt.disposeAndClear();
             delete p;
             bRemoved = true;
         }
@@ -241,6 +242,7 @@ void SwPostItMgr::RemoveItem( SfxBroadcaster* pBroadcast )
             SwSidebarItem* p = (*i);
             if (GetActiveSidebarWin() == p->pPostIt)
                 SetActiveSidebarWin(0);
+            p->pPostIt.disposeAndClear();
             mvPostItFlds.erase(i);
             delete p;
             break;
@@ -1174,6 +1176,7 @@ void SwPostItMgr::RemoveSidebarWin()
         for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
         {
             EndListening( *(const_cast<SfxBroadcaster*>((*i)->GetBroadCaster())) );
+            (*i)->pPostIt.disposeAndClear();
             delete (*i);
         }
         mvPostItFlds.clear();
diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx
index 9e2f997..ad29cdc 100644
--- a/sw/source/uibase/uiview/pview.cxx
+++ b/sw/source/uibase/uiview/pview.cxx
@@ -1238,6 +1238,12 @@ SwPagePreview::~SwPagePreview()
     SwViewShell* pVShell =  pViewWin->GetViewShell();
     pVShell->SetWin(0);
     delete pVShell;
+
+    pViewWin.disposeAndClear();
+
+    pScrollFill.disposeAndClear();
+    pHScrollbar.disposeAndClear();
+    pVScrollbar.disposeAndClear();
 }
 
 SwDocShell* SwPagePreview::GetDocShell()
diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx
index f5161a7..fb057fc 100644
--- a/sw/source/uibase/utlui/navipi.cxx
+++ b/sw/source/uibase/utlui/navipi.cxx
@@ -895,6 +895,7 @@ IMPL_LINK_NOARG(SwNavigationPI, PopupModeEndHdl)
     {
         // Replace floating window with popup window and destroy
         // floating window instance.
+        pFloatingWindow.disposeAndClear();
         pFloatingWindow = pPopupWindow;
         pPopupWindow    = 0;
     }
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 961dd91..90184ec 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -204,6 +204,8 @@ void TabControl::dispose()
     ImplFreeLayoutData();
 
     // delete TabCtrl data
+    if (mpTabCtrlData)
+        mpTabCtrlData->mpListBox.disposeAndClear();
     delete mpTabCtrlData;
     mpTabCtrlData = NULL;
     Control::dispose();
diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx
index 4322248..6371297 100644
--- a/vcl/source/edit/vclmedit.cxx
+++ b/vcl/source/edit/vclmedit.cxx
@@ -184,6 +184,7 @@ void ImpVclMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle )
     bool bScrollbarsChanged = false;
     if ( bHaveVScroll != bNeedVScroll )
     {
+        mpVScrollBar.disposeAndClear();
         mpVScrollBar = bNeedVScroll ? new ScrollBar( pVclMultiLineEdit, WB_VSCROLL|WB_DRAG ) : NULL;
 
         if ( bNeedVScroll )
@@ -197,6 +198,7 @@ void ImpVclMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle )
 
     if ( bHaveHScroll != bNeedHScroll )
     {
+        mpHScrollBar.disposeAndClear();
         mpHScrollBar = bNeedHScroll ? new ScrollBar( pVclMultiLineEdit, WB_HSCROLL|WB_DRAG ) : NULL;
 
         if ( bNeedHScroll )
@@ -210,6 +212,7 @@ void ImpVclMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle )
 
     if ( bHaveScrollBox != bNeedScrollBox )
     {
+        mpScrollBox.disposeAndClear();
         mpScrollBox = bNeedScrollBox ? new ScrollBarBox( pVclMultiLineEdit, WB_SIZEABLE ) : NULL;
 
         if ( bNeedScrollBox )
@@ -255,10 +258,10 @@ void ImpVclMEdit::InitFromStyle( WinBits nWinStyle )
 ImpVclMEdit::~ImpVclMEdit()
 {
     EndListening( *mpTextWindow->GetTextEngine() );
-    mpScrollBox.disposeAndClear();
-    mpVScrollBar.disposeAndClear();
-    mpHScrollBar.disposeAndClear();
     mpTextWindow.disposeAndClear();
+    mpHScrollBar.disposeAndClear();
+    mpVScrollBar.disposeAndClear();
+    mpScrollBox.disposeAndClear();
     pVclMultiLineEdit.disposeAndClear();
 }
 
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 8216e6e..b5e7845 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -191,6 +191,7 @@ public:
         mnDefaultPaperBin( -1 ),
         mnFixedPaperBin( -1 )
     {}
+    ~ImplPrinterControllerData() { mpProgress.disposeAndClear(); }
 
     Size getRealPaperSize( const Size& i_rPageSize, bool bNoNUP ) const
     {
diff --git a/vcl/source/window/btndlg.cxx b/vcl/source/window/btndlg.cxx
index 37a4b3a..b0552ff 100644
--- a/vcl/source/window/btndlg.cxx
+++ b/vcl/source/window/btndlg.cxx
@@ -64,6 +64,11 @@ ButtonDialog::~ButtonDialog()
 
 void ButtonDialog::dispose()
 {
+    for ( btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
+    {
+        if ( it->mbOwnButton )
+            it->mpPushButton.disposeAndClear();
+    }
     maItemList.clear();
     Dialog::dispose();
 }
@@ -343,6 +348,7 @@ void ButtonDialog::Clear()
     for (btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
     {
         it->mpPushButton->Hide();
+        it->mpPushButton.disposeAndClear();
     }
 
     maItemList.clear();
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 92595d0..7a4bd3d 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -3286,6 +3286,7 @@ void VclBuilder::delete_by_name(const OString& sID)
     {
         if (aI->m_sID.equals(sID))
         {
+            aI->m_pWindow.disposeAndClear();
             m_aChildren.erase(aI);
             break;
         }
diff --git a/vcl/unx/generic/app/i18n_status.cxx b/vcl/unx/generic/app/i18n_status.cxx
index 2101713..13cfdb1 100644
--- a/vcl/unx/generic/app/i18n_status.cxx
+++ b/vcl/unx/generic/app/i18n_status.cxx
@@ -523,6 +523,7 @@ I18NStatus::I18NStatus() :
 
 I18NStatus::~I18NStatus()
 {
+    m_pStatusWindow.disposeAndClear();
     if( pInstance == this )
         pInstance = NULL;
 }
commit 58a43332b3a86db3756e6ad18e31189969c85364
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Mar 20 14:59:22 2015 +0200

    wrap more stuff in VclPtr
    
    Change-Id: I2f0d8a4fe426d8ee1ac55a05ae8dd0b44f9aab2b

diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index 092770d..2c171d0 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -82,6 +82,8 @@ bool containsWindowSubclass(const Type* pType0);
 bool containsWindowSubclass(const QualType& qType) {
     if (startsWith(qType.getAsString(), "VclPtr"))
         return false;
+    if (startsWith(qType.getAsString(), "const VclPtr"))
+        return false;
     if (startsWith(qType.getAsString(), "class VclPtr"))
         return false;
     if (startsWith(qType.getAsString(), "const class VclPtr"))
diff --git a/sd/source/filter/eppt/pptx-text.cxx b/sd/source/filter/eppt/pptx-text.cxx
index 4bce723..b1fc50f 100644
--- a/sd/source/filter/eppt/pptx-text.cxx
+++ b/sd/source/filter/eppt/pptx-text.cxx
@@ -1396,7 +1396,7 @@ void FontCollectionEntry::ImplInit( const OUString& rName )
 
 FontCollection::~FontCollection()
 {
-    delete pVDev;
+    pVDev.disposeAndClear();
     xPPTBreakIter = NULL;
 }
 
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index 32b0278..7ae66ff 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -141,7 +141,7 @@ SdTransferable::~SdTransferable()
     delete mpBookmark;
     delete mpImageMap;
 
-    delete mpVDev;
+    mpVDev.disposeAndClear();
     delete mpObjDesc;
 
     //call explicitly at end of dtor to be covered by above SolarMutex
diff --git a/sd/source/ui/inc/PreviewRenderer.hxx b/sd/source/ui/inc/PreviewRenderer.hxx
index 5159184..0333ee0 100644
--- a/sd/source/ui/inc/PreviewRenderer.hxx
+++ b/sd/source/ui/inc/PreviewRenderer.hxx
@@ -126,7 +126,7 @@ protected:
     virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) SAL_OVERRIDE;
 
 private:
-    ::std::unique_ptr<VirtualDevice> mpPreviewDevice;
+    ScopedVclPtr<VirtualDevice> mpPreviewDevice;
     ::std::unique_ptr<DrawView> mpView;
     DrawDocShell* mpDocShellOfView;
     const Color maFrameColor;
diff --git a/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx b/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
index 90156c5..7dde1cb 100644
--- a/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
+++ b/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
@@ -75,7 +75,7 @@ private:
     VclPtr<sd::Window> mpTargetWindow;
     class LayerContainer;
     ::boost::scoped_ptr<LayerContainer> mpLayers;
-    ::boost::scoped_ptr<VirtualDevice> mpBackBuffer;
+    ScopedVclPtr<VirtualDevice> mpBackBuffer;
     MapMode maSavedMapMode;
 
     void RepaintRectangle (const Rectangle& rRepaintRectangle);
diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
index bb1d48e..1ac2ac0 100644
--- a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
+++ b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
@@ -160,7 +160,7 @@ Bitmap PageObjectPainter::CreateMarkedPreview (
     const BitmapEx& rOverlay,
     const OutputDevice* pReferenceDevice) const
 {
-    ::boost::scoped_ptr<VirtualDevice> pDevice;
+    ScopedVclPtr<VirtualDevice> pDevice;
     if (pReferenceDevice != NULL)
         pDevice.reset(new VirtualDevice(*pReferenceDevice));
     else
diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx
index ba7826b..59ed7a1 100644
--- a/sd/source/ui/view/DocumentRenderer.cxx
+++ b/sd/source/ui/view/DocumentRenderer.cxx
@@ -256,7 +256,7 @@ namespace {
     {
     public:
         PrintInfo (
-            const Printer* pPrinter,
+            Printer* pPrinter,
             const bool bPrintMarkedOnly)
             : mpPrinter(pPrinter),
               mnDrawMode(DRAWMODE_DEFAULT),
@@ -269,7 +269,7 @@ namespace {
               mbPrintMarkedOnly(bPrintMarkedOnly)
         {}
 
-        const Printer* mpPrinter;
+        const VclPtr<Printer> mpPrinter;
         sal_uLong mnDrawMode;
         OUString msTimeDate;
         OUString msPageString;
@@ -1338,7 +1338,7 @@ private:
     SfxObjectShellRef mxObjectShell; // destroying mpPrintView
     ViewShellBase& mrBase;
     bool mbIsDisposed;
-    Printer* mpPrinter;
+    VclPtr<Printer> mpPrinter;
     Size maPrinterPageSizePixel;
     ::boost::scoped_ptr<PrintOptions> mpOptions;
     ::std::vector< ::boost::shared_ptr< ::sd::PrinterPage> > maPrinterPages;
@@ -1423,7 +1423,7 @@ private:
 
         PrintInfo aInfo (mpPrinter, mpOptions->IsPrintMarkedOnly());
 
-        if (aInfo.mpPrinter!=NULL && pShell!=NULL)
+        if (aInfo.mpPrinter!=nullptr && pShell!=NULL)
         {
 
             MapMode aMap (aInfo.mpPrinter->GetMapMode());
@@ -1880,7 +1880,7 @@ private:
         const PageKind ePageKind,
         PrintInfo& rInfo)
     {
-        OSL_ASSERT(rInfo.mpPrinter != NULL);
+        OSL_ASSERT(rInfo.mpPrinter != nullptr);
 
         // Fill in page kind specific data.
         SdDrawDocument* pDocument = mrBase.GetMainViewShell()->GetDoc();
diff --git a/sd/source/ui/view/drawview.cxx b/sd/source/ui/view/drawview.cxx
index a5ebc69..5d901ce 100644
--- a/sd/source/ui/view/drawview.cxx
+++ b/sd/source/ui/view/drawview.cxx
@@ -91,7 +91,7 @@ DrawView::DrawView( DrawDocShell* pDocSh, OutputDevice* pOutDev, DrawViewShell*
 
 DrawView::~DrawView()
 {
-    delete mpVDev;
+    mpVDev.disposeAndClear();
 }
 
 /**
@@ -459,8 +459,7 @@ void DrawView::CompleteRedraw(OutputDevice* pOutDev, const vcl::Region& rReg, sd
 {
     if( mpVDev )
     {
-        delete mpVDev;
-        mpVDev = NULL;
+        mpVDev.disposeAndClear();
     }
 
     bool bStandardPaint = true;
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index b2c6933..7956ce2 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -607,11 +607,11 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any*
                         {
                             if ( !sPrinterName.isEmpty() )
                             {
-                                SfxPrinter *pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
+                                VclPtr<SfxPrinter> pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
                                 if (pNewPrinter->IsKnown())
                                     pDocSh->SetPrinter ( pNewPrinter );
                                 else
-                                    delete pNewPrinter;
+                                    pNewPrinter.disposeAndClear();
                             }
                         }
                         else
diff --git a/sw/source/core/inc/fntcache.hxx b/sw/source/core/inc/fntcache.hxx
index 5cf565c..6755965 100644
--- a/sw/source/core/inc/fntcache.hxx
+++ b/sw/source/core/inc/fntcache.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SW_SOURCE_CORE_INC_FNTCACHE_HXX
 
 #include <vcl/font.hxx>
+#include <vcl/vclptr.hxx>
 #include <tools/mempool.hxx>
 #include "swtypes.hxx"
 #include "swcache.hxx"
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 42cd02a..b85e351 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -338,7 +338,7 @@ sal_Int32 SwAttrIter::GetNextAttr( ) const
 class SwMinMaxArgs
 {
 public:
-    OutputDevice* pOut;
+    VclPtr<OutputDevice> pOut;
     SwViewShell const * pSh;
     sal_uLong &rMin;
     sal_uLong &rMax;
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index 77894fa..e4726ab 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -67,7 +67,7 @@ Color *pWaveCol = 0;
 
 long SwFntObj::nPixWidth;
 MapMode* SwFntObj::pPixMap = NULL;
-OutputDevice* SwFntObj::pPixOut = NULL;
+VclPtr<OutputDevice> SwFntObj::pPixOut;
 
 namespace
 {
@@ -1401,7 +1401,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
         if ( pPrinter )
         {
             // pTmpFont has already been set as current font for rInf.GetOut()
-            if ( pPrinter != rInf.GetpOut() || pTmpFont != pPrtFont )
+            if ( pPrinter.get() != rInf.GetpOut() || pTmpFont != pPrtFont )
             {
                 if( !pPrtFont->IsSameInstance( pPrinter->GetFont() ) )
                     pPrinter->SetFont( *pPrtFont );
@@ -1886,7 +1886,7 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
 
     // This is the part used e.g., for cursor travelling
     // See condition for DrawText or DrawTextArray (bDirectPrint)
-    if ( pPrinter && pPrinter != rInf.GetpOut() )
+    if ( pPrinter && pPrinter.get() != rInf.GetpOut() )
     {
         if( !pPrtFont->IsSameInstance( pPrinter->GetFont() ) )
             pPrinter->SetFont(*pPrtFont);
@@ -2247,7 +2247,7 @@ SwFntAccess::SwFntAccess( const void* &rMagic,
                               ( !pFntObj->pPrinter || pFntObj->pPrinter == pOut ) ) )
             pFntObj = pFntCache->Next( pFntObj );
 
-        if( pFntObj && pFntObj->pPrinter != pOut )
+        if( pFntObj && pFntObj->pPrinter.get() != pOut )
         {
             // found one without printer, let's see if there is one with
             // the same printer as well
@@ -2272,7 +2272,7 @@ SwFntAccess::SwFntAccess( const void* &rMagic,
         else  // Font has been found, so we lock it.
         {
             pFntObj->Lock();
-            if (pFntObj->pPrinter != pOut) // if no printer is known by now
+            if (pFntObj->pPrinter.get() != pOut) // if no printer is known by now
             {
                 OSL_ENSURE( !pFntObj->pPrinter, "SwFntAccess: Printer Changed" );
                 pFntObj->CreatePrtFont( *pOut );
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 0d2893c..c7efe3c 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -322,7 +322,7 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
 
                 pRegion->Compress();
 
-                VirtualDevice *pVout = 0;
+                VclPtr<VirtualDevice> pVout;
                 while ( !pRegion->empty() )
                 {
                     SwRect aRect( pRegion->back() );
@@ -375,7 +375,7 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
                             aMapMode.SetOrigin( aOrigin );
                             pVout->SetMapMode( aMapMode );
 
-                            mpOut = pVout;
+                            mpOut = pVout.get();
                             if ( bPaintsFromSystem )
                                 PaintDesktop( aRect );
                             pCurrentLayout->Paint( aRect );
@@ -411,7 +411,7 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
                     lcl_PaintTransparentFormControls(*this, aRect); // i#107365
                 }
 
-                delete pVout;
+                pVout.disposeAndClear();
                 delete pRegion;
                 Imp()->DelRegion();
             }
@@ -464,7 +464,7 @@ void SwViewShell::ImplUnlockPaint( bool bVirDev )
         if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() )
         {
             //Refresh with virtual device to avoid flickering.
-            VirtualDevice *pVout = new VirtualDevice( *mpOut );
+            VclPtr<VirtualDevice> pVout = new VirtualDevice( *mpOut );
             pVout->SetMapMode( mpOut->GetMapMode() );
             Size aSize( VisArea().SSize() );
             aSize.Width() += 20;
@@ -483,7 +483,7 @@ void SwViewShell::ImplUnlockPaint( bool bVirDev )
                 DLPrePaint2(aRepaintRegion);
 
                 OutputDevice *pOld = mpOut;
-                mpOut = pVout;
+                mpOut = pVout.get();
                 Paint( VisArea().SVRect() );
                 mpOut = pOld;
                 mpOut->DrawOutDev( VisArea().Pos(), aSize,
@@ -500,7 +500,7 @@ void SwViewShell::ImplUnlockPaint( bool bVirDev )
                 GetWin()->EnablePaint( true );
                 GetWin()->Invalidate( INVALIDATE_CHILDREN );
             }
-            delete pVout;
+            pVout.disposeAndClear();
         }
         else
         {
@@ -1207,7 +1207,7 @@ bool SwViewShell::SmoothScroll( long lXDiff, long lYDiff, const Rectangle *pRect
 
         //create virtual device and set.
         const Size aPixSz = GetWin()->PixelToLogic(Size(1,1));
-        VirtualDevice *pVout = new VirtualDevice( *GetWin() );
+        VclPtr<VirtualDevice> pVout = new VirtualDevice( *GetWin() );
         pVout->SetLineColor( GetWin()->GetLineColor() );
         pVout->SetFillColor( GetWin()->GetFillColor() );
         MapMode aMapMode( GetWin()->GetMapMode() );
@@ -1239,7 +1239,7 @@ bool SwViewShell::SmoothScroll( long lXDiff, long lYDiff, const Rectangle *pRect
             aMapMode.SetOrigin( aPt );
             pVout->SetMapMode( aMapMode );
             OutputDevice *pOld = mpOut;
-            mpOut = pVout;
+            mpOut = pVout.get();
 
             {
                 // #i75172# To get a clean repaint, a new ObjectContact is needed here. Without, the
@@ -1384,14 +1384,14 @@ bool SwViewShell::SmoothScroll( long lXDiff, long lYDiff, const Rectangle *pRect
                         --mnLockPaint;
                 }
             }
-            delete pVout;
+            pVout.disposeAndClear();
             GetWin()->Update();
             if ( !Imp()->bStopSmooth )
                 --mnLockPaint;
             SetFirstVisPageInvalid();
             return true;
         }
-        delete pVout;
+        pVout.disposeAndClear();
     }
 #endif
 
diff --git a/sw/source/ui/chrdlg/drpcps.cxx b/sw/source/ui/chrdlg/drpcps.cxx
index d5157f7..d0ba0a4 100644
--- a/sw/source/ui/chrdlg/drpcps.cxx
+++ b/sw/source/ui/chrdlg/drpcps.cxx
@@ -72,7 +72,7 @@ class SwDropCapsPict : public Control
     long            mnLineH;
     long            mnTextH;
     sal_uInt16      mnDistance;
-    Printer*        mpPrinter;
+    VclPtr<Printer> mpPrinter;
     bool            mbDelPrinter;
     /// The _ScriptInfo structure holds information on where we change from one
     /// script to another.
@@ -209,7 +209,7 @@ SwDropCapsPict::~SwDropCapsPict()
 void SwDropCapsPict::dispose()
 {
      if( mbDelPrinter )
-         delete mpPrinter;
+         mpPrinter.disposeAndClear();
      mpPage.clear();
      Control::dispose();
 }
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index ee6a85b..236fa93 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -636,9 +636,7 @@ void SwStdFontTabPage::dispose()
 {
     delete pFontList;
     if (bDeletePrinter)
-    {
-        delete pPrt;
-    }
+        pPrt.disposeAndClear();
     pLabelFT.clear();
     pStandardBox.clear();
     pStandardHeightLB.clear();
@@ -833,7 +831,7 @@ void SwStdFontTabPage::Reset( const SfxItemSet* rSet)
 
     if (bDeletePrinter)
     {
-        delete pPrt;
+        pPrt.disposeAndClear();
     }
 
     if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_PRINTER, false, &pItem))
diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx
index 7a95d49..82f7116 100644
--- a/sw/source/ui/dbui/mmoutputpage.cxx
+++ b/sw/source/ui/dbui/mmoutputpage.cxx
@@ -312,7 +312,7 @@ SwMailMergeOutputPage::~SwMailMergeOutputPage()
 
 void SwMailMergeOutputPage::dispose()
 {
-    delete m_pTempPrinter;
+    m_pTempPrinter.disposeAndClear();
     m_pSaveStartDocRB.clear();
     m_pSaveMergedDocRB.clear();
     m_pPrintRB.clear();
@@ -848,7 +848,7 @@ IMPL_LINK(SwMailMergeOutputPage, PrinterChangeHdl_Impl, ListBox*, pBox)
                 if( (m_pTempPrinter->GetName() != pInfo->GetPrinterName()) ||
                      (m_pTempPrinter->GetDriverName() != pInfo->GetDriver()) )
                 {
-                    delete m_pTempPrinter;
+                    m_pTempPrinter.disposeAndClear();
                     m_pTempPrinter = new Printer( *pInfo );
                 }
             }
diff --git a/sw/source/ui/envelp/labprt.cxx b/sw/source/ui/envelp/labprt.cxx
index de7d3cf..77be9df 100644
--- a/sw/source/ui/envelp/labprt.cxx
+++ b/sw/source/ui/envelp/labprt.cxx
@@ -67,7 +67,7 @@ SwLabPrtPage::~SwLabPrtPage()
 
 void SwLabPrtPage::dispose()
 {
-    delete pPrinter;
+    pPrinter.disposeAndClear();
     m_pPageButton.clear();
     m_pSingleButton.clear();
     m_pSingleGrid.clear();
diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index f0e5c1f..08583bf 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -931,7 +931,7 @@ void NumberingPreview::Paint( const Rectangle& /*rRect*/ )
 {
     const Size aSize(PixelToLogic(GetOutputSizePixel()));
 
-    boost::scoped_ptr<VirtualDevice> pVDev(new VirtualDevice(*this));
+    ScopedVclPtr<VirtualDevice> pVDev(new VirtualDevice(*this));
     pVDev->SetMapMode(GetMapMode());
     pVDev->SetOutputSize( aSize );
 
diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx
index c9da210..977d25f 100644
--- a/sw/source/ui/table/tautofmt.cxx
+++ b/sw/source/ui/table/tautofmt.cxx
@@ -61,7 +61,7 @@ protected:
 
 private:
     SwTableAutoFmt          aCurData;
-    VirtualDevice           aVD;
+    ScopedVclPtr<VirtualDevice> aVD;
     SvtScriptedTextHelper   aScriptedText;
     svx::frame::Array       maArray;            /// Implementation to draw the frame borders.
     bool                    bFitWidth;
@@ -517,8 +517,8 @@ IMPL_LINK_NOARG_INLINE_END(SwAutoFormatDlg, OkHdl)
 AutoFmtPreview::AutoFmtPreview(vcl::Window* pParent, WinBits nStyle) :
         Window          ( pParent, nStyle ),
         aCurData        ( OUString() ),
-        aVD             ( *this ),
-        aScriptedText   ( aVD ),
+        aVD             ( new VirtualDevice(*this) ),
+        aScriptedText   ( *aVD.get() ),
         bFitWidth       ( false ),
         mbRTL           ( false ),
         aStrJan         ( SW_RES( STR_JAN ) ),
@@ -796,11 +796,11 @@ void AutoFmtPreview::DrawBackground()
         {
             SvxBrushItem aBrushItem( aCurData.GetBoxFmt( GetFormatIndex( nCol, nRow ) ).GetBackground() );
 
-            aVD.Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
-            aVD.SetLineColor();
-            aVD.SetFillColor( aBrushItem.GetColor() );
-            aVD.DrawRect( maArray.GetCellRect( nCol, nRow ) );
-            aVD.Pop();
+            aVD->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
+            aVD->SetLineColor();
+            aVD->SetFillColor( aBrushItem.GetColor() );
+            aVD->DrawRect( maArray.GetCellRect( nCol, nRow ) );
+            aVD->Pop();
         }
     }
 }
@@ -816,7 +816,7 @@ void AutoFmtPreview::PaintCells()
 
     // 3) border
     if ( aCurData.IsFrame() )
-        maArray.DrawArray( aVD );
+        maArray.DrawArray( *aVD.get() );
 }
 
 void AutoFmtPreview::Init()
@@ -885,9 +885,9 @@ void AutoFmtPreview::NotifyChange( const SwTableAutoFmt& rNewData )
 
 void AutoFmtPreview::DoPaint( const Rectangle& /*rRect*/ )
 {
-    sal_uInt32 nOldDrawMode = aVD.GetDrawMode();
+    sal_uInt32 nOldDrawMode = aVD->GetDrawMode();
     if( GetSettings().GetStyleSettings().GetHighContrastMode() )
-        aVD.SetDrawMode( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
+        aVD->SetDrawMode( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
 
     Bitmap  thePreview;
     Point   aCenterPos;
@@ -895,36 +895,36 @@ void AutoFmtPreview::DoPaint( const Rectangle& /*rRect*/ )
     Color   oldColor;
     vcl::Font aFont;
 
-    aFont = aVD.GetFont();
+    aFont = aVD->GetFont();
     aFont.SetTransparent( true );
 
-    aVD.SetFont          ( aFont );
-    aVD.SetLineColor     ();
+    aVD->SetFont          ( aFont );
+    aVD->SetLineColor     ();
     const Color& rWinColor = GetSettings().GetStyleSettings().GetWindowColor();
-    aVD.SetBackground    ( Wallpaper(rWinColor) );
-    aVD.SetFillColor     ( rWinColor );
-    aVD.SetOutputSizePixel  ( aPrvSize );
+    aVD->SetBackground    ( Wallpaper(rWinColor) );
+    aVD->SetFillColor     ( rWinColor );
+    aVD->SetOutputSizePixel  ( aPrvSize );
 
     // Draw cells on virtual device
     // and save the result
     PaintCells();
-    thePreview = aVD.GetBitmap( Point(0,0), aPrvSize );
+    thePreview = aVD->GetBitmap( Point(0,0), aPrvSize );
 
     // Draw the Frame and center the preview:
     // (virtual Device for window output)
-    aVD.SetOutputSizePixel( theWndSize );
-    oldColor = aVD.GetLineColor();
-    aVD.SetLineColor();
-    aVD.DrawRect( Rectangle( Point(0,0), theWndSize ) );
+    aVD->SetOutputSizePixel( theWndSize );
+    oldColor = aVD->GetLineColor();
+    aVD->SetLineColor();
+    aVD->DrawRect( Rectangle( Point(0,0), theWndSize ) );
     SetLineColor( oldColor );
     aCenterPos  = Point( (theWndSize.Width()  - aPrvSize.Width() ) / 2,
                          (theWndSize.Height() - aPrvSize.Height()) / 2 );
-    aVD.DrawBitmap( aCenterPos, thePreview );
+    aVD->DrawBitmap( aCenterPos, thePreview );
 
     // Output in the preview window:
-    DrawBitmap( Point(0,0), aVD.GetBitmap( Point(0,0), theWndSize ) );
+    DrawBitmap( Point(0,0), aVD->GetBitmap( Point(0,0), theWndSize ) );
 
-    aVD.SetDrawMode( nOldDrawMode );
+    aVD->SetDrawMode( nOldDrawMode );
 }
 
 void AutoFmtPreview::Paint( const Rectangle& rRect )
diff --git a/sw/source/uibase/inc/swruler.hxx b/sw/source/uibase/inc/swruler.hxx
index 6d24690..7e57c2a 100644
--- a/sw/source/uibase/inc/swruler.hxx
+++ b/sw/source/uibase/inc/swruler.hxx
@@ -48,7 +48,7 @@ protected:
     bool        mbIsHighlighted; //< If comment control is highlighted (mouse is over it)
     Timer       maFadeTimer;     //< Timer for high/'low'light fading
     int         mnFadeRate;      //< From 0 to 100. 0 means not highlighted.
-    VirtualDevice maVirDev;      //< VirtualDevice of this window. Just for convenience.
+    ScopedVclPtr<VirtualDevice> maVirDev;      //< VirtualDevice of this window. Just for convenience.
 
     /**
      * Callback function to handle a mouse button down event.
diff --git a/sw/source/uibase/misc/swruler.cxx b/sw/source/uibase/misc/swruler.cxx
index 5440c22..1d95bd2 100644
--- a/sw/source/uibase/misc/swruler.cxx
+++ b/sw/source/uibase/misc/swruler.cxx
@@ -41,7 +41,7 @@ SwCommentRuler::SwCommentRuler( SwViewShell* pViewSh, vcl::Window* pParent, SwEd
 , mpSwWin(pWin)
 , mbIsHighlighted(false)
 , mnFadeRate(0)
-, maVirDev( *this )
+, maVirDev( new VirtualDevice(*this) )
 {
     // Set fading timeout: 5 x 40ms = 200ms
     maFadeTimer.SetTimeout(40);
@@ -75,25 +75,25 @@ void SwCommentRuler::DrawCommentControl()
     bool bIsCollapsed = ! mpViewShell->GetPostItMgr()->ShowNotes();
 
     Rectangle aControlRect = GetCommentControlRegion();
-    maVirDev.SetOutputSizePixel( aControlRect.GetSize() );
+    maVirDev->SetOutputSizePixel( aControlRect.GetSize() );
 
     // Paint comment control background
     // TODO Check if these are best colors to be used
     Color aBgColor = GetFadedColor( rStyleSettings.GetDarkShadowColor(), rStyleSettings.GetWorkspaceColor() );
-    maVirDev.SetFillColor( aBgColor );
+    maVirDev->SetFillColor( aBgColor );
 
     if ( mbIsHighlighted || !bIsCollapsed )
     {
         // Draw borders
-        maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
+        maVirDev->SetLineColor( rStyleSettings.GetShadowColor() );
     }
     else
     {
         // No borders
-        maVirDev.SetLineColor();
+        maVirDev->SetLineColor();
     }
 
-    maVirDev.DrawRect( Rectangle( Point(), aControlRect.GetSize() ) );
+    maVirDev->DrawRect( Rectangle( Point(), aControlRect.GetSize() ) );
 
     // Label and arrow tip
     OUString aLabel( SW_RESSTR ( STR_COMMENTS_LABEL ) );
@@ -142,9 +142,9 @@ void SwCommentRuler::DrawCommentControl()
 
     // Draw label
     Color aTextColor = GetFadedColor( rStyleSettings.GetButtonTextColor(), rStyleSettings.GetDarkShadowColor() );
-    maVirDev.SetTextColor( aTextColor );
+    maVirDev->SetTextColor( aTextColor );
     // FIXME Expected font size?
-    maVirDev.DrawText( aLabelPos, aLabel );
+    maVirDev->DrawText( aLabelPos, aLabel );
 
     // Draw arrow
     // FIXME consistence of button colors. http://opengrok.libreoffice.org/xref/core/vcl/source/control/button.cxx#785
@@ -152,26 +152,26 @@ void SwCommentRuler::DrawCommentControl()
     ImplDrawArrow ( aArrowPos.X(), aArrowPos.Y(), aArrowColor, bArrowToRight );
 
     // Blit comment control
-    DrawOutDev( aControlRect.TopLeft(), aControlRect.GetSize(), Point(), aControlRect.GetSize(), maVirDev );
+    DrawOutDev( aControlRect.TopLeft(), aControlRect.GetSize(), Point(), aControlRect.GetSize(), *maVirDev.get() );
 }
 
 void SwCommentRuler::ImplDrawArrow(long nX, long nY, const Color& rColor, bool bPointRight)
 {
-    maVirDev.SetLineColor();
-    maVirDev.SetFillColor( rColor );
+    maVirDev->SetLineColor();
+    maVirDev->SetFillColor( rColor );
     if ( bPointRight )
     {
-        maVirDev.DrawRect( Rectangle( nX+0, nY+0, nX+0, nY+6 ) );
-        maVirDev.DrawRect( Rectangle( nX+1, nY+1, nX+1, nY+5 ) );
-        maVirDev.DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
-        maVirDev.DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
+        maVirDev->DrawRect( Rectangle( nX+0, nY+0, nX+0, nY+6 ) );
+        maVirDev->DrawRect( Rectangle( nX+1, nY+1, nX+1, nY+5 ) );
+        maVirDev->DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
+        maVirDev->DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
     }
     else
     {
-        maVirDev.DrawRect( Rectangle( nX+0, nY+3, nX+0, nY+3 ) );
-        maVirDev.DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
-        maVirDev.DrawRect( Rectangle( nX+2, nY+1, nX+2, nY+5 ) );
-        maVirDev.DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+6 ) );
+        maVirDev->DrawRect( Rectangle( nX+0, nY+3, nX+0, nY+3 ) );
+        maVirDev->DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
+        maVirDev->DrawRect( Rectangle( nX+2, nY+1, nX+2, nY+5 ) );
+        maVirDev->DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+6 ) );
     }
 }
 
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 990c20a..ce19d65 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -388,7 +388,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
                     SfxPrinter* pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( true );
                     if ( OUString ( pPrinter->GetName()) != sPrinterName )
                     {
-                        SfxPrinter *pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
+                        VclPtr<SfxPrinter> pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
                         if( pNewPrinter->IsKnown() )
                         {
                             // set printer only once; in _postSetValues
@@ -396,7 +396,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
                         }
                         else
                         {
-                            delete pNewPrinter;
+                            pNewPrinter.disposeAndClear();
                         }
                     }
                 }
@@ -428,7 +428,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
                     SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet );
 
                     // set printer only once; in _postSetValues
-                    delete mpPrinter;
+                    mpPrinter.disposeAndClear();
                     mpPrinter = pPrinter;
                 }
             }
@@ -826,7 +826,7 @@ void SwXDocumentSettings::_postSetValues ()
         throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
 {
     // set printer only once, namely here!
-    if( mpPrinter != NULL )
+    if( mpPrinter != nullptr )
     {
         // #i86352# the printer is also used as container for options by sfx
         // when setting a printer it should have decent default options
commit e0eecf8ad57aa207d1db7fc63d9ad8f8d54866e4
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Apr 10 12:40:37 2015 +0100

    Cleanup a few issues with stack VirtualDevice conversion.

diff --git a/filter/source/graphicfilter/epict/epict.cxx b/filter/source/graphicfilter/epict/epict.cxx
index df3a4f6..d978c45 100644
--- a/filter/source/graphicfilter/epict/epict.cxx
+++ b/filter/source/graphicfilter/epict/epict.cxx
@@ -1699,7 +1699,7 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF )
 
                 if ( aSrcFont.GetAlign() != ALIGN_BASELINE )
                 {
-                    ScopedVclPtr<VirtualDevice> pVirDev( new VirtualDevice() );
+                    ScopedVclPtrInstance<VirtualDevice> pVirDev;
                     if (aSrcFont.GetAlign()==ALIGN_TOP)
                         aPt.Y()+=(long)pVirDev->GetFontMetric(aSrcFont).GetAscent();
                     else
@@ -1854,7 +1854,7 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF )
 
             case META_GRADIENT_ACTION:
             {
-                ScopedVclPtr<VirtualDevice> aVDev;
+                ScopedVclPtrInstance<VirtualDevice> aVDev;
                 GDIMetaFile                 aTmpMtf;
                 const MetaGradientAction*   pA = static_cast<const MetaGradientAction*>(pMA);
 
@@ -1866,7 +1866,7 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF )
 
             case META_HATCH_ACTION:
             {
-                ScopedVclPtr<VirtualDevice> aVDev;
+                ScopedVclPtrInstance<VirtualDevice> aVDev;
                 GDIMetaFile             aTmpMtf;
                 const MetaHatchAction*  pA = static_cast<const MetaHatchAction*>(pMA);
 
diff --git a/sc/source/ui/inc/autofmt.hxx b/sc/source/ui/inc/autofmt.hxx
index 3cd9bc3..8227376 100644
--- a/sc/source/ui/inc/autofmt.hxx
+++ b/sc/source/ui/inc/autofmt.hxx
@@ -56,7 +56,7 @@ protected:
 
 private:
     ScAutoFormatData*       pCurData;
-    ScopedVclPtr<VirtualDevice> aVD;
+    ScopedVclPtrInstance<VirtualDevice> aVD;
     SvtScriptedTextHelper   aScriptedText;
     ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBreakIter;
     bool                    bFitWidth;
commit 52789497db9f97beb8c95177fd2293287c5dc1e6
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Mar 20 14:27:53 2015 +0200

    wrap more stuff in VclPtr
    
    Change-Id: Ia742c47399231bc5914b6586132ad3daf694fdb0

diff --git a/canvas/source/vcl/backbuffer.hxx b/canvas/source/vcl/backbuffer.hxx
index 479f4dd..0beeda2 100644
--- a/canvas/source/vcl/backbuffer.hxx
+++ b/canvas/source/vcl/backbuffer.hxx
@@ -43,7 +43,7 @@ namespace vclcanvas
          */
         BackBuffer( const OutputDevice& rRefDevice,
                     bool                bMonochromeBuffer=false );
-        ~BackBuffer();
+        virtual ~BackBuffer();
 
         virtual OutputDevice&       getOutDev() SAL_OVERRIDE;
         virtual const OutputDevice& getOutDev() const SAL_OVERRIDE;
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index ffa73a8..092770d 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -243,6 +243,8 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) {
         && !startsWith(pVarDecl->getType().getAsString(), "::std::multimap<sal_Int32, class OTableWindow *>")
         && !startsWith(pVarDecl->getType().getAsString(), "::dbp::OMultiInstanceAutoRegistration< ::dbp::OUnoAutoPilot<")
         && !startsWith(pVarDecl->getType().getAsString(), "SwSidebarWin_iterator")
+        && !startsWith(pVarDecl->getType().getAsString(), "functor_vector_type")
+        && !startsWith(pVarDecl->getType().getAsString(), "const functor_vector_type")
         && containsWindowSubclass(pVarDecl->getType()))
     {
         report(
diff --git a/filter/source/graphicfilter/epict/epict.cxx b/filter/source/graphicfilter/epict/epict.cxx
index 33f5fdb..df3a4f6 100644
--- a/filter/source/graphicfilter/epict/epict.cxx
+++ b/filter/source/graphicfilter/epict/epict.cxx
@@ -1854,24 +1854,24 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF )
 
             case META_GRADIENT_ACTION:
             {
-                VirtualDevice               aVDev;
+                ScopedVclPtr<VirtualDevice> aVDev;
                 GDIMetaFile                 aTmpMtf;
                 const MetaGradientAction*   pA = static_cast<const MetaGradientAction*>(pMA);
 
-                aVDev.SetMapMode( aTargetMapMode );
-                aVDev.AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf );
+                aVDev->SetMapMode( aTargetMapMode );
+                aVDev->AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf );
                 WriteOpcodes( aTmpMtf );
             }
             break;
 
             case META_HATCH_ACTION:
             {
-                VirtualDevice           aVDev;
+                ScopedVclPtr<VirtualDevice> aVDev;
                 GDIMetaFile             aTmpMtf;
                 const MetaHatchAction*  pA = static_cast<const MetaHatchAction*>(pMA);
 
-                aVDev.SetMapMode( aTargetMapMode );
-                aVDev.AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
+                aVDev->SetMapMode( aTargetMapMode );
+                aVDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
                 WriteOpcodes( aTmpMtf );
             }
             break;
diff --git a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
index 3b525ed..d0e181b 100644
--- a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
+++ b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
@@ -401,7 +401,7 @@ void ScZoomSliderWnd::DoPaint( const Rectangle& /*rRect*/ )
     Size aSliderWindowSize = GetOutputSizePixel();
     Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
 
-    VirtualDevice* pVDev = new VirtualDevice( *this );
+    ScopedVclPtr<VirtualDevice> pVDev = new VirtualDevice( *this );
     pVDev->SetOutputSizePixel( aSliderWindowSize );
 
     Rectangle   aSlider = aRect;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list