[Libreoffice-commits] core.git: Branch 'feature/vclptr' - include/vcl vcl/generic vcl/qa vcl/quartz vcl/source vcl/unx vcl/win vcl/workben

Michael Meeks michael.meeks at collabora.com
Mon Apr 20 07:32:12 PDT 2015


 include/vcl/layout.hxx                   |    4 +--
 vcl/generic/print/prtsetup.cxx           |    4 +--
 vcl/qa/cppunit/complextext.cxx           |    4 +--
 vcl/qa/cppunit/outdev.cxx                |    2 -
 vcl/quartz/cairo_quartz_cairo.cxx        |    2 -
 vcl/source/app/dbggui.cxx                |   18 ++++++++---------
 vcl/source/app/help.cxx                  |    6 ++---
 vcl/source/app/svdata.cxx                |    2 -
 vcl/source/control/combobox.cxx          |    8 +++----
 vcl/source/control/ilstbox.cxx           |    8 +++----
 vcl/source/control/spinfld.cxx           |    4 +--
 vcl/source/control/tabctrl.cxx           |    2 -
 vcl/source/edit/vclmedit.cxx             |    8 +++----
 vcl/source/filter/wmf/emfwr.hxx          |    2 -
 vcl/source/gdi/pdfwriter_impl.cxx        |    2 -
 vcl/source/gdi/pdfwriter_impl2.cxx       |    2 -
 vcl/source/gdi/print.cxx                 |    4 +--
 vcl/source/gdi/print3.cxx                |    2 -
 vcl/source/gdi/virdev.cxx                |    2 -
 vcl/source/opengl/OpenGLContext.cxx      |    6 ++---
 vcl/source/outdev/text.cxx               |    2 -
 vcl/source/window/btndlg.cxx             |    8 +++----
 vcl/source/window/clipping.cxx           |    2 -
 vcl/source/window/dialog.cxx             |    4 +--
 vcl/source/window/dockmgr.cxx            |    7 +++---
 vcl/source/window/dockwin.cxx            |    5 ++--
 vcl/source/window/floatwin.cxx           |    2 -
 vcl/source/window/layout.cxx             |   32 +++++++++++++++----------------
 vcl/source/window/menu.cxx               |    4 +--
 vcl/source/window/menubarwindow.cxx      |    6 ++---
 vcl/source/window/msgbox.cxx             |    6 ++---
 vcl/source/window/openglwin.cxx          |    2 -
 vcl/source/window/printdlg.cxx           |    6 ++---
 vcl/source/window/status.cxx             |    2 -
 vcl/source/window/tabdlg.cxx             |    2 -
 vcl/source/window/window.cxx             |    2 -
 vcl/source/window/window2.cxx            |    2 -
 vcl/source/window/wrkwin.cxx             |    2 -
 vcl/unx/generic/app/i18n_status.cxx      |    8 +++----
 vcl/unx/generic/gdi/cairo_xlib_cairo.cxx |    2 -
 vcl/win/source/gdi/cairo_win32_cairo.cxx |    6 +----
 vcl/workben/icontest.cxx                 |    4 +--
 vcl/workben/mtfdemo.cxx                  |    2 -
 vcl/workben/svpclient.cxx                |    8 +++----
 vcl/workben/vcldemo.cxx                  |   10 ++++-----
 45 files changed, 114 insertions(+), 114 deletions(-)

New commits:
commit 4fed8865be56ac431fb91e2432c6e93ce3f781c7
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Apr 20 15:35:54 2015 +0100

    vcl: convert new to ::Create
    
    Change-Id: Ifd52953086ea923fa1770892d13f32c2263aec54

diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 650ec61..bec9976 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -517,7 +517,7 @@ public:
     VclExpander(vcl::Window *pParent)
         : VclBin(pParent)
         , m_bResizeTopLevel(true)
-        , m_pDisclosureButton(new DisclosureButton(this))
+        , m_pDisclosureButton(VclPtr<DisclosureButton>::Create(this))
     {
         m_pDisclosureButton->SetToggleHdl(LINK(this, VclExpander, ClickHdl));
         m_pDisclosureButton->Show();
@@ -630,7 +630,7 @@ protected:
 public:
     VclEventBox(vcl::Window* pParent)
         : VclBin(pParent)
-        , m_aEventBoxHelper(new EventBoxHelper(this))
+        , m_aEventBoxHelper(VclPtr<EventBoxHelper>::Create(this))
     {
         m_aEventBoxHelper->Show();
     }
diff --git a/vcl/generic/print/prtsetup.cxx b/vcl/generic/print/prtsetup.cxx
index b446787..738d00d 100644
--- a/vcl/generic/print/prtsetup.cxx
+++ b/vcl/generic/print/prtsetup.cxx
@@ -117,9 +117,9 @@ IMPL_LINK( RTSDialog, ActivatePage, TabControl*, pTabCtrl )
     {
         TabPage *pPage = NULL;
         if (sPage == "paper")
-            pPage = m_pPaperPage = new RTSPaperPage( this );
+            pPage = m_pPaperPage = VclPtr<RTSPaperPage>::Create( this );
         else if (sPage == "device")
-            pPage = m_pDevicePage = new RTSDevicePage( this );
+            pPage = m_pDevicePage = VclPtr<RTSDevicePage>::Create( this );
         if( pPage )
             m_pTabControl->SetTabPage( nId, pPage );
     }
diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index a6330e4..7e3550b 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -43,10 +43,10 @@ void VclComplexTextTest::testArabic()
     OUString aOneTwoThree( reinterpret_cast<char const *>(pOneTwoThreeUTF8),
                            SAL_N_ELEMENTS( pOneTwoThreeUTF8 ) - 1,
                            RTL_TEXTENCODING_UTF8 );
-    vcl::Window* pWin = new WorkWindow( (vcl::Window *)NULL );
+    VclPtr<vcl::Window> pWin = VclPtr<WorkWindow>::Create( (vcl::Window *)nullptr );
     CPPUNIT_ASSERT( pWin != NULL );
 
-    OutputDevice *pOutDev = static_cast< OutputDevice * >( pWin );
+    OutputDevice *pOutDev = static_cast< OutputDevice * >( pWin.get() );
 
     vcl::Font aFont = OutputDevice::GetDefaultFont(
                         DEFAULTFONT_CTL_SPREADSHEET,
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index cb0b0a2..80687af 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -73,7 +73,7 @@ void VclOutdevTest::testVirtualDevice()
     CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(pAcc->GetPixel(31,30)).GetColor());
 
 #if 0
-    vcl::Window* pWin = new WorkWindow( (vcl::Window *)NULL );
+    VclPtr<vcl::Window> pWin = VclPtr<WorkWindow>::Create( (vcl::Window *)nullptr );
     CPPUNIT_ASSERT( pWin != NULL );
     OutputDevice *pOutDev = static_cast< OutputDevice * >( pWin );
 #endif
diff --git a/vcl/quartz/cairo_quartz_cairo.cxx b/vcl/quartz/cairo_quartz_cairo.cxx
index cec50a2..0b0835c 100644
--- a/vcl/quartz/cairo_quartz_cairo.cxx
+++ b/vcl/quartz/cairo_quartz_cairo.cxx
@@ -250,7 +250,7 @@ namespace cairo
         aSystemGraphicsData.nSize = sizeof(SystemGraphicsData);
         aSystemGraphicsData.rCGContext = getCGContext();
         return VclPtr<VirtualDevice>(
-            new VirtualDevice( &aSystemGraphicsData, Size(1, 1), getDepth() ));
+            VclPtr<VirtualDevice>::Create( &aSystemGraphicsData, Size(1, 1), getDepth() ));
     }
 
 }  // namespace cairo
diff --git a/vcl/source/app/dbggui.cxx b/vcl/source/app/dbggui.cxx
index a3578fb..e8d27ae 100644
--- a/vcl/source/app/dbggui.cxx
+++ b/vcl/source/app/dbggui.cxx
@@ -244,13 +244,13 @@ private:
 
 DbgDialog::DbgDialog() :
     ModalDialog( NULL, WB_STDMODAL | WB_SYSTEMWINDOW ),
-    maRes(new CheckBox(this)),
-    maDialog(new CheckBox(this)),
-    maBoldAppFont(new CheckBox(this)),
-    maBox3(new GroupBox(this)),
-    maOKButton(new OKButton(this, WB_DEFBUTTON)),
-    maCancelButton(new CancelButton(this)),
-    maHelpButton(new HelpButton(this))
+    maRes(VclPtr<CheckBox>::Create(this)),
+    maDialog(VclPtr<CheckBox>::Create(this)),
+    maBoldAppFont(VclPtr<CheckBox>::Create(this)),
+    maBox3(VclPtr<GroupBox>::Create(this)),
+    maOKButton(VclPtr<OKButton>::Create(this, WB_DEFBUTTON)),
+    maCancelButton(VclPtr<CancelButton>::Create(this)),
+    maHelpButton(VclPtr<HelpButton>::Create(this))
 {
     DbgData*    pData = DbgGetData();
     MapMode     aAppMap( MAP_APPFONT );
@@ -397,8 +397,8 @@ void DbgDialog::dispose()
 
 DbgInfoDialog::DbgInfoDialog( vcl::Window* pParent, bool bHelpText ) :
     ModalDialog( pParent, WB_STDMODAL ),
-    maListBox(new ListBox( this, WB_BORDER | WB_AUTOHSCROLL )),
-    maOKButton(new OKButton(this, WB_DEFBUTTON))
+    maListBox(VclPtr<ListBox>::Create( this, WB_BORDER | WB_AUTOHSCROLL )),
+    maOKButton(VclPtr<OKButton>::Create(this, WB_DEFBUTTON))
 {
     mbHelpText = bHelpText;
 
diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index c13acfa..8812ee4 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -204,9 +204,9 @@ sal_uIntPtr Help::ShowTip( vcl::Window* pParent, const Rectangle& rScreenRect,
                      const OUString& rText, sal_uInt16 nStyle )
 {
     sal_uInt16 nHelpWinStyle = ( ( nStyle & QUICKHELP_TIP_STYLE_BALLOON ) != 0 ) ? HELPWINSTYLE_BALLOON : HELPWINSTYLE_QUICK;
-    HelpTextWindow* pHelpWin = new HelpTextWindow( pParent, rText, nHelpWinStyle, nStyle );
+    VclPtrInstance<HelpTextWindow> pHelpWin( pParent, rText, nHelpWinStyle, nStyle );
 
-    sal_uIntPtr nId = reinterpret_cast< sal_uIntPtr >( pHelpWin );
+    sal_uIntPtr nId = reinterpret_cast< sal_uIntPtr >( pHelpWin.get() );
     UpdateTip( nId, pParent, rScreenRect, rText );
 
     pHelpWin->ShowHelp( HELPDELAY_NONE );
@@ -530,7 +530,7 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, sal_uIn
             nDelayMode = HELPDELAY_NONE;
 
         DBG_ASSERT( !pHelpWin, "Noch ein HelpWin ?!" );
-        pHelpWin = new HelpTextWindow( pParent, rHelpText, nHelpWinStyle, nStyle );
+        pHelpWin = VclPtr<HelpTextWindow>::Create( pParent, rHelpText, nHelpWinStyle, nStyle );
         pSVData->maHelpData.mpHelpWin = pHelpWin;
         pHelpWin->SetStatusText( rStatusText );
         if ( pHelpArea )
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 3a4920a..14cf94d 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -136,7 +136,7 @@ vcl::Window* ImplGetDefaultWindow()
         if ( !pSVData->mpDefaultWin && !pSVData->mbDeInit )
         {
             DBG_WARNING( "ImplGetDefaultWindow(): No AppWindow" );
-            pSVData->mpDefaultWin = new WorkWindow( 0, WB_DEFAULTWIN );
+            pSVData->mpDefaultWin = VclPtr<WorkWindow>::Create( nullptr, WB_DEFAULTWIN );
             pSVData->mpDefaultWin->SetText( OUString( "VCL ImplGetDefaultWindow"  ) );
 
             // Add a reference to the default context so it never gets deleted
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 2c78507..94b8f3cfa 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -147,11 +147,11 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
     WinBits nListStyle = nStyle;
     if( nStyle & WB_DROPDOWN )
     {
-        mpFloatWin = new ImplListBoxFloatingWindow( this );
+        mpFloatWin = VclPtr<ImplListBoxFloatingWindow>::Create( this );
         mpFloatWin->SetAutoWidth( true );
         mpFloatWin->SetPopupModeEndHdl( LINK( this, ComboBox, ImplPopupModeEndHdl ) );
 
-        mpBtn = new ImplBtn( this, WB_NOLIGHTBORDER | WB_RECTSTYLE );
+        mpBtn = VclPtr<ImplBtn>::Create( this, WB_NOLIGHTBORDER | WB_RECTSTYLE );
         ImplInitDropDownButton( mpBtn );
         mpBtn->buttonDownSignal.connect( boost::bind( &ComboBox::ImplClickButtonHandler, this, _1 ));
         mpBtn->Show();
@@ -170,7 +170,7 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
         }
     }
 
-    mpSubEdit.set( new Edit( this, nEditStyle ) );
+    mpSubEdit.set( VclPtr<Edit>::Create( this, nEditStyle ) );
     mpSubEdit->EnableRTL( false );
     SetSubEdit( mpSubEdit );
     mpSubEdit->SetPosPixel( Point() );
@@ -180,7 +180,7 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
     vcl::Window* pLBParent = this;
     if ( mpFloatWin )
         pLBParent = mpFloatWin;
-    mpImplLB = new ImplListBox( pLBParent, nListStyle|WB_SIMPLEMODE|WB_AUTOHSCROLL );
+    mpImplLB = VclPtr<ImplListBox>::Create( pLBParent, nListStyle|WB_SIMPLEMODE|WB_AUTOHSCROLL );
     mpImplLB->SetPosPixel( Point() );
     mpImplLB->SetSelectHdl( LINK( this, ComboBox, ImplSelectHdl ) );
     mpImplLB->SetCancelHdl( LINK( this, ComboBox, ImplCancelHdl ) );
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index dc09182..83d76a3 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -2141,16 +2141,16 @@ sal_uInt16 ImplListBoxWindow::ImplGetTextStyle() const
 
 ImplListBox::ImplListBox( vcl::Window* pParent, WinBits nWinStyle ) :
     Control( pParent, nWinStyle ),
-    maLBWindow(new ImplListBoxWindow( this, nWinStyle&(~WB_BORDER) ))
+    maLBWindow(VclPtr<ImplListBoxWindow>::Create( this, nWinStyle&(~WB_BORDER) ))
 {
     maLBWindow->userDrawSignal.connect( userDrawSignal );
 
     // for native widget rendering we must be able to detect this window type
     SetType( WINDOW_LISTBOXWINDOW );
 
-    mpVScrollBar    = new ScrollBar( this, WB_VSCROLL | WB_DRAG );
-    mpHScrollBar    = new ScrollBar( this, WB_HSCROLL | WB_DRAG );
-    mpScrollBarBox  = new ScrollBarBox( this );
+    mpVScrollBar    = VclPtr<ScrollBar>::Create( this, WB_VSCROLL | WB_DRAG );
+    mpHScrollBar    = VclPtr<ScrollBar>::Create( this, WB_HSCROLL | WB_DRAG );
+    mpScrollBarBox  = VclPtr<ScrollBarBox>::Create( this );
 
     Link aLink( LINK( this, ImplListBox, ScrollBarHdl ) );
     mpVScrollBar->SetScrollHdl( aLink );
diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx
index 03af006..f26845d 100644
--- a/vcl/source/control/spinfld.cxx
+++ b/vcl/source/control/spinfld.cxx
@@ -311,11 +311,11 @@ void SpinField::ImplInit( vcl::Window* pParent, WinBits nWinStyle )
         if ( (nWinStyle & WB_SPIN) && ImplUseNativeBorder( nWinStyle ) )
         {
             SetBackground();
-            mpEdit.set( new Edit( this, WB_NOBORDER ) );
+            mpEdit.set( VclPtr<Edit>::Create( this, WB_NOBORDER ) );
             mpEdit->SetBackground();
         }
         else
-            mpEdit.set( new Edit( this, WB_NOBORDER ) );
+            mpEdit.set( VclPtr<Edit>::Create( this, WB_NOBORDER ) );
 
         mpEdit->EnableRTL( false );
         mpEdit->SetPosPixel( Point() );
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 90184ec..d03446f 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -112,7 +112,7 @@ void TabControl::ImplInit( vcl::Window* pParent, WinBits nStyle )
 
     if( (nStyle & WB_DROPDOWN) )
     {
-        mpTabCtrlData->mpListBox = new ListBox( this, WB_DROPDOWN );
+        mpTabCtrlData->mpListBox = VclPtr<ListBox>::Create( this, WB_DROPDOWN );
         mpTabCtrlData->mpListBox->SetPosSizePixel( Point( 0, 0 ), Size( 200, 20 ) );
         mpTabCtrlData->mpListBox->SetSelectHdl( LINK( this, TabControl, ImplListBoxSelectHdl ) );
         mpTabCtrlData->mpListBox->Show();
diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx
index 6371297..cc3a589 100644
--- a/vcl/source/edit/vclmedit.cxx
+++ b/vcl/source/edit/vclmedit.cxx
@@ -153,7 +153,7 @@ ImpVclMEdit::ImpVclMEdit( VclMultiLineEdit* pEdt, WinBits nWinStyle )
 {
     pVclMultiLineEdit = pEdt;
     mnTextWidth = 0;
-    mpTextWindow = new TextWindow( pEdt );
+    mpTextWindow = VclPtr<TextWindow>::Create( pEdt );
     mpTextWindow->Show();
     InitFromStyle( nWinStyle );
     StartListening( *mpTextWindow->GetTextEngine() );
@@ -185,7 +185,7 @@ void ImpVclMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle )
     if ( bHaveVScroll != bNeedVScroll )
     {
         mpVScrollBar.disposeAndClear();
-        mpVScrollBar = bNeedVScroll ? new ScrollBar( pVclMultiLineEdit, WB_VSCROLL|WB_DRAG ) : NULL;
+        mpVScrollBar = bNeedVScroll ? VclPtr<ScrollBar>::Create( pVclMultiLineEdit, WB_VSCROLL|WB_DRAG ) : nullptr;
 
         if ( bNeedVScroll )
         {
@@ -199,7 +199,7 @@ void ImpVclMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle )
     if ( bHaveHScroll != bNeedHScroll )
     {
         mpHScrollBar.disposeAndClear();
-        mpHScrollBar = bNeedHScroll ? new ScrollBar( pVclMultiLineEdit, WB_HSCROLL|WB_DRAG ) : NULL;
+        mpHScrollBar = bNeedHScroll ? VclPtr<ScrollBar>::Create( pVclMultiLineEdit, WB_HSCROLL|WB_DRAG ) : nullptr;
 
         if ( bNeedHScroll )
         {
@@ -213,7 +213,7 @@ void ImpVclMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle )
     if ( bHaveScrollBox != bNeedScrollBox )
     {
         mpScrollBox.disposeAndClear();
-        mpScrollBox = bNeedScrollBox ? new ScrollBarBox( pVclMultiLineEdit, WB_SIZEABLE ) : NULL;
+        mpScrollBox = bNeedScrollBox ? VclPtr<ScrollBarBox>::Create( pVclMultiLineEdit, WB_SIZEABLE ) : nullptr;
 
         if ( bNeedScrollBox )
             mpScrollBox->Show();
diff --git a/vcl/source/filter/wmf/emfwr.hxx b/vcl/source/filter/wmf/emfwr.hxx
index 3e9f2fc..d037bde 100644
--- a/vcl/source/filter/wmf/emfwr.hxx
+++ b/vcl/source/filter/wmf/emfwr.hxx
@@ -90,7 +90,7 @@ private:
 public:
 
     EMFWriter(SvStream &rStream)
-        : maVDev( new VirtualDevice() )
+        : maVDev( VclPtr<VirtualDevice>::Create() )
         , m_rStm(rStream)
         , mpHandlesUsed(NULL)
         , mnHandleCount(0)
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index ba5a0bf..9ed2d19 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2220,7 +2220,7 @@ OutputDevice* PDFWriterImpl::getReferenceDevice()
 {
     if( ! m_pReferenceDevice )
     {
-        VirtualDevice*  pVDev = new VirtualDevice( 0 );
+        VclPtrInstance<VirtualDevice> pVDev( 0 );
 
         m_pReferenceDevice = pVDev;
 
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index 74db239..b3d6b6b 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -247,7 +247,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa
     ScopedVclPtr<VirtualDevice> xPrivateDevice;
     if( ! pDummyVDev )
     {
-        xPrivateDevice.reset(new VirtualDevice());
+        xPrivateDevice.reset(VclPtr<VirtualDevice>::Create());
         pDummyVDev = xPrivateDevice.get();
         pDummyVDev->EnableOutput( false );
         pDummyVDev->SetMapMode( i_rMtf.GetPrefMapMode() );
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 3cbc34d..85da523 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -792,9 +792,9 @@ void Printer::ImplInitDisplay( const vcl::Window* pWindow )
     mpJobGraphics       = NULL;
 
     if ( pWindow )
-        mpDisplayDev = new VirtualDevice( *pWindow );
+        mpDisplayDev = VclPtr<VirtualDevice>::Create( *pWindow );
     else
-        mpDisplayDev = new VirtualDevice();
+        mpDisplayDev = VclPtr<VirtualDevice>::Create();
     mpFontCollection          = pSVData->maGDIData.mpScreenFontList;
     mpFontCache         = pSVData->maGDIData.mpScreenFontCache;
     mnDPIX              = mpDisplayDev->mnDPIX;
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 56809da..bf5c5ee 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -1661,7 +1661,7 @@ void PrinterController::createProgressDialog()
 
         if( bShow && ! Application::IsHeadlessModeEnabled() )
         {
-            mpImplData->mpProgress = new PrintProgressDialog( NULL, getPageCountProtected() );
+            mpImplData->mpProgress = VclPtr<PrintProgressDialog>::Create( nullptr, getPageCountProtected() );
             mpImplData->mpProgress->Show();
         }
     }
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 748eba0..25655e0 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -405,7 +405,7 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
 
             if( !mpAlphaVDev )
             {
-                mpAlphaVDev = new VirtualDevice( *this, mnAlphaDepth );
+                mpAlphaVDev = VclPtr<VirtualDevice>::Create( *this, mnAlphaDepth );
                 mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase,
                                                          basebmp::RawMemorySharedArray(),
                                                          bTopDown );
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index e61231e..a619f93 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -658,7 +658,7 @@ bool OpenGLContext::init( vcl::Window* pParent )
     if(mbInitialized)
         return true;
 
-    m_xWindow.reset(pParent ? NULL : new vcl::Window(0, WB_NOBORDER|WB_NODIALOGCONTROL));
+    m_xWindow.reset(pParent ? nullptr : VclPtr<vcl::Window>::Create(nullptr, WB_NOBORDER|WB_NODIALOGCONTROL));
     mpWindow = pParent ? pParent : m_xWindow.get();
     if(m_xWindow)
         m_xWindow->setPosSizePixel(0,0,0,0);
@@ -1081,7 +1081,7 @@ bool OpenGLContext::initWindow()
     if( !m_pChildWindow )
     {
         SystemWindowData winData = generateWinData(mpWindow, false);
-        m_pChildWindow = new SystemChildWindow(mpWindow, 0, &winData, false);
+        m_pChildWindow = VclPtr<SystemChildWindow>::Create(mpWindow, 0, &winData, false);
     }
 
     if( m_pChildWindow )
@@ -1108,7 +1108,7 @@ bool OpenGLContext::initWindow()
     if( !m_pChildWindow )
     {
         SystemWindowData winData = generateWinData(mpWindow, mbRequestLegacyContext);
-        m_pChildWindow = new SystemChildWindow(mpWindow, 0, &winData, false);
+        m_pChildWindow = VclPtr<SystemChildWindow>::Create(mpWindow, 0, &winData, false);
     }
 
     if( m_pChildWindow )
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index acbfd4b..a9db317 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -236,7 +236,7 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout )
 
     // cache virtual device for rotation
     if (!mpOutDevData->mpRotateDev)
-        mpOutDevData->mpRotateDev = new VirtualDevice( *this, 1 );
+        mpOutDevData->mpRotateDev = VclPtr<VirtualDevice>::Create( *this, 1 );
     VirtualDevice* pVDev = mpOutDevData->mpRotateDev;
 
     // size it accordingly
diff --git a/vcl/source/window/btndlg.cxx b/vcl/source/window/btndlg.cxx
index 3acbad5..2e8532c 100644
--- a/vcl/source/window/btndlg.cxx
+++ b/vcl/source/window/btndlg.cxx
@@ -81,13 +81,13 @@ PushButton* ButtonDialog::ImplCreatePushButton( sal_uInt16 nBtnFlags )
     if ( nBtnFlags & BUTTONDIALOG_DEFBUTTON )
         nStyle |= WB_DEFBUTTON;
     if ( nBtnFlags & BUTTONDIALOG_CANCELBUTTON )
-        pBtn = new CancelButton( this, nStyle );
+        pBtn = VclPtr<CancelButton>::Create( this, nStyle );
     else if ( nBtnFlags & BUTTONDIALOG_OKBUTTON )
-        pBtn = new OKButton( this, nStyle );
+        pBtn = VclPtr<OKButton>::Create( this, nStyle );
     else if ( nBtnFlags & BUTTONDIALOG_HELPBUTTON )
-        pBtn = new HelpButton( this, nStyle );
+        pBtn = VclPtr<HelpButton>::Create( this, nStyle );
     else
-        pBtn = new PushButton( this, nStyle );
+        pBtn = VclPtr<PushButton>::Create( this, nStyle );
 
     if ( !(nBtnFlags & BUTTONDIALOG_HELPBUTTON) )
         pBtn->SetClickHdl( LINK( this, ButtonDialog, ImplClickHdl ) );
diff --git a/vcl/source/window/clipping.cxx b/vcl/source/window/clipping.cxx
index 0e11542..38efc37 100644
--- a/vcl/source/window/clipping.cxx
+++ b/vcl/source/window/clipping.cxx
@@ -842,7 +842,7 @@ void Window::ImplSaveOverlapBackground()
             if ( nSaveBackSize+mpWindowImpl->mpFrameData->mnAllSaveBackSize <= IMPL_MAXALLSAVEBACKSIZE )
             {
                 Size aOutSize( mnOutWidth, mnOutHeight );
-                mpWindowImpl->mpOverlapData->mpSaveBackDev = new VirtualDevice( *mpWindowImpl->mpFrameWindow );
+                mpWindowImpl->mpOverlapData->mpSaveBackDev = VclPtr<VirtualDevice>::Create( *mpWindowImpl->mpFrameWindow );
                 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev->SetOutputSizePixel( aOutSize ) )
                 {
                     mpWindowImpl->mpFrameWindow->ImplUpdateAll();
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 54fb42d..9e6d4bf 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -403,7 +403,7 @@ void Dialog::ImplInit( vcl::Window* pParent, WinBits nStyle )
         // create window with a small border ?
         if ( (nStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE)) == WB_BORDER )
         {
-            ImplBorderWindow* pBorderWin  = new ImplBorderWindow( pParent, nStyle, BORDERWINDOW_STYLE_FRAME );
+            VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle, BORDERWINDOW_STYLE_FRAME );
             SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
             pBorderWin->mpWindowImpl->mpClientWindow = this;
             pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
@@ -421,7 +421,7 @@ void Dialog::ImplInit( vcl::Window* pParent, WinBits nStyle )
     }
     else
     {
-        ImplBorderWindow* pBorderWin  = new ImplBorderWindow( pParent, nStyle, BORDERWINDOW_STYLE_OVERLAP | BORDERWINDOW_STYLE_BORDER );
+        VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle, BORDERWINDOW_STYLE_OVERLAP | BORDERWINDOW_STYLE_BORDER );
         SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
         pBorderWin->mpWindowImpl->mpClientWindow = this;
         pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index c5726af..aaf8427 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -860,7 +860,7 @@ bool ImplDockingWindowWrapper::ImplStartDocking( const Point& rPos )
     if ( mpFloatWin )
         pWin = mpFloatWin;
     else
-        pWin = new ImplDockFloatWin2( mpParent, mnFloatBits, NULL );
+        pWin = VclPtr<ImplDockFloatWin2>::Create( mpParent, mnFloatBits, nullptr );
     pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom );
     if ( !mpFloatWin )
         pWin.disposeAndClear();
@@ -1116,7 +1116,7 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, sal_uLon
         mpOldBorderWin = NULL;  // no border window found
 
     // the new parent for popup mode
-    ImplPopupFloatWin* pWin = new ImplPopupFloatWin( mpParent, this, (nFlags & FLOATWIN_POPUPMODE_ALLOWTEAROFF) != 0 );
+    VclPtrInstance<ImplPopupFloatWin> pWin( mpParent, this, (nFlags & FLOATWIN_POPUPMODE_ALLOWTEAROFF) != 0 );
 
     pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
     pWin->SetText( GetWindow()->GetText() );
@@ -1225,7 +1225,8 @@ void ImplDockingWindowWrapper::SetFloatingMode( bool bFloatMode )
                     mpOldBorderWin = NULL;  // no border window found
 
                 ImplDockFloatWin2* pWin =
-                    new ImplDockFloatWin2(
+                    VclPtr<ImplDockFloatWin2>::Create(
+
                                          mpParent,
                                          mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ?
                                           mnFloatBits | WB_SYSTEMWINDOW
diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx
index 6cc6301..d6ed20d 100644
--- a/vcl/source/window/dockwin.cxx
+++ b/vcl/source/window/dockwin.cxx
@@ -268,7 +268,7 @@ bool DockingWindow::ImplStartDocking( const Point& rPos )
     if ( mpFloatWin )
         pWin = mpFloatWin;
     else
-        pWin = new ImplDockFloatWin( mpImplData->mpParent, mnFloatBits, NULL );
+        pWin = VclPtr<ImplDockFloatWin>::Create( mpImplData->mpParent, mnFloatBits, nullptr );
     pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom );
     if ( !mpFloatWin )
         pWin.disposeAndClear();
@@ -801,7 +801,8 @@ void DockingWindow::SetFloatingMode( bool bFloatMode )
                 mpOldBorderWin = mpWindowImpl->mpBorderWindow;
 
                 ImplDockFloatWin* pWin =
-                    new ImplDockFloatWin(
+                    VclPtr<ImplDockFloatWin>::Create(
+
                                          mpImplData->mpParent,
                                          mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ?  mnFloatBits | WB_SYSTEMWINDOW : mnFloatBits,
                                          this );
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index 3b41ab0..65a5ef4 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -107,7 +107,7 @@ void FloatingWindow::ImplInit( vcl::Window* pParent, WinBits nStyle )
                 nBorderStyle |= BORDERWINDOW_STYLE_FRAME;
                 nStyle |= WB_CLOSEABLE; // make undecorated floaters closeable
             }
-            pBorderWin  = new ImplBorderWindow( pParent, nStyle, nBorderStyle );
+            pBorderWin  = VclPtr<ImplBorderWindow>::Create( pParent, nStyle, nBorderStyle );
             SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
             pBorderWin->mpWindowImpl->mpClientWindow = this;
             pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 309a8b7..cb983d5 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1627,9 +1627,9 @@ IMPL_LINK( VclExpander, ClickHdl, DisclosureButton*, pBtn )
 VclScrolledWindow::VclScrolledWindow(vcl::Window *pParent, WinBits nStyle)
     : VclBin(pParent, nStyle)
     , m_bUserManagedScrolling(false)
-    , m_pVScroll(new ScrollBar(this, WB_HIDE | WB_VERT))
-    , m_pHScroll(new ScrollBar(this, WB_HIDE | WB_HORZ))
-    , m_aScrollBarBox(new ScrollBarBox(this, WB_HIDE))
+    , m_pVScroll(VclPtr<ScrollBar>::Create(this, WB_HIDE | WB_VERT))
+    , m_pHScroll(VclPtr<ScrollBar>::Create(this, WB_HIDE | WB_HORZ))
+    , m_aScrollBarBox(VclPtr<ScrollBarBox>::Create(this, WB_HIDE))
 {
     SetType(WINDOW_SCROLLWINDOW);
 
@@ -1975,10 +1975,10 @@ bool VclSizeGroup::set_property(const OString &rKey, const OString &rValue)
 void MessageDialog::create_owned_areas()
 {
     set_border_width(12);
-    m_pOwnedContentArea.set(new VclVBox(this, false, 24));
+    m_pOwnedContentArea.set(VclPtr<VclVBox>::Create(this, false, 24));
     set_content_area(m_pOwnedContentArea);
     m_pOwnedContentArea->Show();
-    m_pOwnedActionArea.set( new VclHButtonBox(m_pOwnedContentArea) );
+    m_pOwnedActionArea.set( VclPtr<VclHButtonBox>::Create(m_pOwnedContentArea) );
     set_action_area(m_pOwnedActionArea);
     m_pOwnedActionArea->Show();
 }
@@ -2134,12 +2134,12 @@ short MessageDialog::Execute()
         VclContainer *pContainer = get_content_area();
         assert(pContainer);
 
-        m_pGrid.set( new VclGrid(pContainer) );
+        m_pGrid.set( VclPtr<VclGrid>::Create(pContainer) );
         m_pGrid->reorderWithinParent(0);
         m_pGrid->set_column_spacing(12);
         m_pGrid->set_row_spacing(GetTextHeight());
 
-        m_pImage = new FixedImage(m_pGrid, WB_CENTER | WB_VCENTER | WB_3DLOOK);
+        m_pImage = VclPtr<FixedImage>::Create(m_pGrid, WB_CENTER | WB_VCENTER | WB_3DLOOK);
         switch (m_eMessageType)
         {
             case VCL_MESSAGE_INFO:
@@ -2164,7 +2164,7 @@ short MessageDialog::Execute()
 
         bool bHasSecondaryText = !m_sSecondaryString.isEmpty();
 
-        m_pPrimaryMessage = new VclMultiLineEdit(m_pGrid, nWinStyle);
+        m_pPrimaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pGrid, nWinStyle);
         m_pPrimaryMessage->SetPaintTransparent(true);
         m_pPrimaryMessage->EnableCursor(false);
 
@@ -2174,7 +2174,7 @@ short MessageDialog::Execute()
         m_pPrimaryMessage->SetText(m_sPrimaryString);
         m_pPrimaryMessage->Show(!m_sPrimaryString.isEmpty());
 
-        m_pSecondaryMessage = new VclMultiLineEdit(m_pGrid, nWinStyle);
+        m_pSecondaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pGrid, nWinStyle);
         m_pSecondaryMessage->SetPaintTransparent(true);
         m_pSecondaryMessage->EnableCursor(false);
         m_pSecondaryMessage->set_grid_left_attach(1);
@@ -2194,33 +2194,33 @@ short MessageDialog::Execute()
             case VCL_BUTTONS_NONE:
                 break;
             case VCL_BUTTONS_OK:
-                pBtn.set( new OKButton(pButtonBox) );
+                pBtn.set( VclPtr<OKButton>::Create(pButtonBox) );
                 pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
                 pBtn->Show();
                 m_aOwnedButtons.push_back(pBtn);
                 m_aResponses[pBtn] = RET_OK;
                 break;
             case VCL_BUTTONS_CLOSE:
-                pBtn.set( new CloseButton(pButtonBox) );
+                pBtn.set( VclPtr<CloseButton>::Create(pButtonBox) );
                 pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
                 pBtn->Show();
                 m_aOwnedButtons.push_back(pBtn);
                 m_aResponses[pBtn] = RET_CLOSE;
                 break;
             case VCL_BUTTONS_CANCEL:
-                pBtn.set( new CancelButton(pButtonBox) );
+                pBtn.set( VclPtr<CancelButton>::Create(pButtonBox) );
                 pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
                 m_aOwnedButtons.push_back(pBtn);
                 m_aResponses[pBtn] = RET_CANCEL;
                 break;
             case VCL_BUTTONS_YES_NO:
-                pBtn = new PushButton(pButtonBox);
+                pBtn = VclPtr<PushButton>::Create(pButtonBox);
                 pBtn->SetText(Button::GetStandardText(StandardButtonType::Yes));
                 pBtn->Show();
                 m_aOwnedButtons.push_back(pBtn);
                 m_aResponses[pBtn] = RET_YES;
 
-                pBtn.set( new PushButton(pButtonBox) );
+                pBtn.set( VclPtr<PushButton>::Create(pButtonBox) );
                 pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
                 pBtn->SetText(Button::GetStandardText(StandardButtonType::No));
                 pBtn->Show();
@@ -2228,12 +2228,12 @@ short MessageDialog::Execute()
                 m_aResponses[pBtn] = RET_NO;
                 break;
             case VCL_BUTTONS_OK_CANCEL:
-                pBtn.set( new OKButton(pButtonBox) );
+                pBtn.set( VclPtr<OKButton>::Create(pButtonBox) );
                 pBtn->Show();
                 m_aOwnedButtons.push_back(pBtn);
                 m_aResponses[pBtn] = RET_OK;
 
-                pBtn.set( new CancelButton(pButtonBox) );
+                pBtn.set( VclPtr<CancelButton>::Create(pButtonBox) );
                 pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
                 pBtn->Show();
                 m_aOwnedButtons.push_back(pBtn);
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 7323c14..40a2545 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2505,7 +2505,7 @@ vcl::Window* MenuBar::ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, Men
     MenuBarWindow *pMenuBarWindow = dynamic_cast<MenuBarWindow*>(pWindow);
     if (!pMenuBarWindow)
     {
-        pWindow = pMenuBarWindow = new MenuBarWindow( pParent );
+        pWindow = pMenuBarWindow = VclPtr<MenuBarWindow>::Create( pParent );
     }
 
     pMenu->pStartedFrom = 0;
@@ -2929,7 +2929,7 @@ sal_uInt16 PopupMenu::ImplExecute( vcl::Window* pW, const Rectangle& rRect, sal_
         CreateAutoMnemonics();
     }
 
-    MenuFloatingWindow* pWin = new MenuFloatingWindow( this, pW, nStyle | WB_SYSTEMWINDOW );
+    VclPtrInstance<MenuFloatingWindow> pWin( this, pW, nStyle | WB_SYSTEMWINDOW );
     if( pSVData->maNWFData.mbFlatMenu )
         pWin->SetBorderStyle( WindowBorderStyle::NOBORDER );
     else
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 7c0bca7..47f61ad 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -119,9 +119,9 @@ void DecoToolBox::SetImages( long nMaxHeight, bool bForce )
 
 MenuBarWindow::MenuBarWindow( vcl::Window* pParent ) :
     Window( pParent, 0 ),
-    aCloseBtn(new DecoToolBox(this)),
-    aFloatBtn(new PushButton( this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE )),
-    aHideBtn(new PushButton(this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE ))
+    aCloseBtn(VclPtr<DecoToolBox>::Create(this)),
+    aFloatBtn(VclPtr<PushButton>::Create( this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE )),
+    aHideBtn(VclPtr<PushButton>::Create(this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE ))
 {
     SetType( WINDOW_MENUBARWINDOW );
     pMenu = NULL;
diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx
index a96011b..9f2fd75 100644
--- a/vcl/source/window/msgbox.cxx
+++ b/vcl/source/window/msgbox.cxx
@@ -231,7 +231,7 @@ void MessBox::ImplPosControls()
         aImageSize.Width()  += 4;
         aImageSize.Height() += 4;
         aTextPos.X() += aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE;
-        mpFixedImage = new FixedImage( this );
+        mpFixedImage = VclPtr<FixedImage>::Create( this );
         mpFixedImage->SetPosSizePixel( Point( IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_X,
                                               IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_Y ),
                                        aImageSize );
@@ -321,7 +321,7 @@ void MessBox::ImplPosControls()
             }
         }
 
-        mpCheckBox = new CheckBox( this );
+        mpCheckBox = VclPtr<CheckBox>::Create( this );
         mpCheckBox->Check( mbCheck );
         mpCheckBox->SetText( aMnemonicString );
         mpCheckBox->SetStyle( mpCheckBox->GetStyle() | WB_WORDBREAK );
@@ -343,7 +343,7 @@ void MessBox::ImplPosControls()
         mpCheckBox->Show();
     }
 
-    mpVCLMultiLineEdit = new VclMultiLineEdit( this, nWinStyle );
+    mpVCLMultiLineEdit = VclPtr<VclMultiLineEdit>::Create( this, nWinStyle );
     mpVCLMultiLineEdit->SetText( aMessText );
     mpVCLMultiLineEdit->SetPosSizePixel( aTextPos, aMEditSize );
     mpVCLMultiLineEdit->Show();
diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx
index bb7ef27..1ef46da 100644
--- a/vcl/source/window/openglwin.cxx
+++ b/vcl/source/window/openglwin.cxx
@@ -25,7 +25,7 @@ private:
 OpenGLWindowImpl::OpenGLWindowImpl(vcl::Window* pWindow)
 {
     SystemWindowData aData = OpenGLContext::generateWinData(pWindow, false);
-    mxChildWindow.reset(new SystemChildWindow(pWindow, 0, &aData));
+    mxChildWindow.reset(VclPtr<SystemChildWindow>::Create(pWindow, 0, &aData));
     mxChildWindow->Show();
     maContext.init(mxChildWindow.get());
     pWindow->SetMouseTransparent(false);
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index f173ad3..f24755d 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -64,11 +64,11 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeShowNupOrderWindow(vcl
 PrintDialog::PrintPreviewWindow::PrintPreviewWindow( vcl::Window* i_pParent )
     : Window( i_pParent, 0 )
     , maOrigSize( 10, 10 )
-    , maPageVDev( new VirtualDevice(*this) )
+    , maPageVDev( VclPtr<VirtualDevice>::Create(*this) )
     , maToolTipString(VclResId( SV_PRINT_PRINTPREVIEW_TXT).toString())
     , mbGreyscale( false )
-    , maHorzDim(new FixedLine(this, WB_HORZ | WB_CENTER))
-    , maVertDim(new FixedLine(this, WB_VERT | WB_VCENTER))
+    , maHorzDim(VclPtr<FixedLine>::Create(this, WB_HORZ | WB_CENTER))
+    , maVertDim(VclPtr<FixedLine>::Create(this, WB_VERT | WB_VCENTER))
 {
     SetPaintTransparent( true );
     SetBackground();
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 0cfbbaa..7f43c18 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -123,7 +123,7 @@ void StatusBar::ImplInit( vcl::Window* pParent, WinBits nStyle )
 
     // remember WinBits
     mpItemList      = new ImplStatusItemList;
-    mpImplData->mpVirDev        = new VirtualDevice( *this );
+    mpImplData->mpVirDev        = VclPtr<VirtualDevice>::Create( *this );
     mnCurItemId     = 0;
     mbFormat        = true;
     mbVisibleItems  = true;
diff --git a/vcl/source/window/tabdlg.cxx b/vcl/source/window/tabdlg.cxx
index 3f31767..e5c9061 100644
--- a/vcl/source/window/tabdlg.cxx
+++ b/vcl/source/window/tabdlg.cxx
@@ -197,7 +197,7 @@ void TabDialog::ImplPosControls()
     {
         Size aDlgSize = GetOutputSizePixel();
         if ( !mpFixedLine )
-            mpFixedLine = new FixedLine( this );
+            mpFixedLine = VclPtr<FixedLine>::Create( this );
         mpFixedLine->SetPosSizePixel( Point( 0, nOffY ),
                                       Size( aDlgSize.Width(), 2 ) );
         mpFixedLine->Show();
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 1ec060b..b596026 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -904,7 +904,7 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
             nBorderTypeStyle |= BORDERWINDOW_STYLE_FRAME;
             nStyle |= WB_BORDER;
         }
-        ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, nStyle & (WB_BORDER | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_NEEDSFOCUS), nBorderTypeStyle );
+        VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle & (WB_BORDER | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_NEEDSFOCUS), nBorderTypeStyle );
         ((vcl::Window*)pBorderWin)->mpWindowImpl->mpClientWindow = this;
         pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
         mpWindowImpl->mpBorderWindow  = pBorderWin;
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index cf8fd3f..bd64654 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -457,7 +457,7 @@ void Window::StartAutoScroll( sal_uInt16 nFlags )
 
     pSVData->maWinData.mpAutoScrollWin = this;
     pSVData->maWinData.mnAutoScrollFlags = nFlags;
-    pSVData->maAppData.mpWheelWindow = new ImplWheelWindow( this );
+    pSVData->maAppData.mpWheelWindow = VclPtr<ImplWheelWindow>::Create( this );
 }
 
 void Window::EndAutoScroll()
diff --git a/vcl/source/window/wrkwin.cxx b/vcl/source/window/wrkwin.cxx
index cdd4be9..136adc8 100644
--- a/vcl/source/window/wrkwin.cxx
+++ b/vcl/source/window/wrkwin.cxx
@@ -49,7 +49,7 @@ void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentDat
     if ( nStyle & WB_APP )
         nFrameStyle |= BORDERWINDOW_STYLE_APP;
 
-    ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, pSystemParentData, nStyle, nFrameStyle );
+    VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, pSystemParentData, nStyle, nFrameStyle );
     Window::ImplInit( pBorderWin, nStyle & (WB_3DLOOK | WB_CLIPCHILDREN | WB_DIALOGCONTROL | WB_SYSTEMFLOATWIN), NULL );
     pBorderWin->mpWindowImpl->mpClientWindow = this;
     pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
diff --git a/vcl/unx/generic/app/i18n_status.cxx b/vcl/unx/generic/app/i18n_status.cxx
index 13cfdb1..5df56b0 100644
--- a/vcl/unx/generic/app/i18n_status.cxx
+++ b/vcl/unx/generic/app/i18n_status.cxx
@@ -111,7 +111,7 @@ public:
 
 XIMStatusWindow::XIMStatusWindow( bool bOn ) :
         StatusWindow( WB_BORDER | WB_SYSTEMFLOATWIN | WB_TOOLTIPWIN ),
-        m_aStatusText(new FixedText(this, 0)),
+        m_aStatusText(VclPtr<FixedText>::Create(this, 0)),
         m_pLastParent( NULL ),
         m_bAnchoredAtRight( false ),
         m_bDelayedShow( false ),
@@ -330,7 +330,7 @@ public:
 
 IIIMPStatusWindow::IIIMPStatusWindow( SalFrame* pParent, bool bOn ) :
         StatusWindow( WB_MOVEABLE ),
-        m_aStatusBtn(new MenuButton(this, WB_BORDER)),
+        m_aStatusBtn(VclPtr<MenuButton>::Create(this, WB_BORDER)),
         m_pResetFocus( pParent ),
         m_bShow( true ),
         m_bOn( bOn )
@@ -535,10 +535,10 @@ void I18NStatus::setParent( SalFrame* pParent )
     {
         bool bIIIMPmode = m_aChoices.begin() != m_aChoices.end();
         if( bIIIMPmode )
-            m_pStatusWindow = new IIIMPStatusWindow( pParent,
+            m_pStatusWindow = VclPtr<IIIMPStatusWindow>::Create( pParent,
                                                      getStatusWindowMode() );
         else
-            m_pStatusWindow = new XIMStatusWindow( getStatusWindowMode() );
+            m_pStatusWindow = VclPtr<XIMStatusWindow>::Create( getStatusWindowMode() );
         setStatusText( m_aCurrentIM );
     }
     m_pStatusWindow->setPosition( m_pParent );
diff --git a/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx b/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx
index 99944d1..0bc8004 100644
--- a/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx
+++ b/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx
@@ -269,7 +269,7 @@ namespace cairo
         int height = cairo_xlib_surface_get_height(mpSurface.get());
 
         return VclPtr<VirtualDevice>(
-            new VirtualDevice(&aSystemGraphicsData,
+            VclPtr<VirtualDevice>::Create(&aSystemGraphicsData,
                               Size(width, height),
                               std::max(getDepth(), 0)));
     }
diff --git a/vcl/win/source/gdi/cairo_win32_cairo.cxx b/vcl/win/source/gdi/cairo_win32_cairo.cxx
index 3571067..65dd478 100644
--- a/vcl/win/source/gdi/cairo_win32_cairo.cxx
+++ b/vcl/win/source/gdi/cairo_win32_cairo.cxx
@@ -173,11 +173,9 @@ namespace cairo
     VclPtr<VirtualDevice> Win32Surface::createVirtualDevice() const
     {
         SystemGraphicsData aSystemGraphicsData;
-        aSystemGraphicsData.nSize = sizeof(SystemGraphicsData);
+        aSystemGraphicsData.nSize = sizeof( SystemGraphicsData );
         aSystemGraphicsData.hDC = cairo_win32_surface_get_dc( mpSurface.get() );
-
-        return VclPtr<VirtualDevice>(
-            new VirtualDevice( &aSystemGraphicsData, Size(1, 1), sal::static_int_cast<USHORT>(getDepth()) ));
+        return VclPtr<VirtualDevice>::Create( &aSystemGraphicsData, Size(1, 1), sal::static_int_cast<USHORT>( getDepth() ) );
     }
 
 }  // namespace cairo
diff --git a/vcl/workben/icontest.cxx b/vcl/workben/icontest.cxx
index 8562feb..cef8ac6 100644
--- a/vcl/workben/icontest.cxx
+++ b/vcl/workben/icontest.cxx
@@ -186,12 +186,12 @@ void IconTestApp::DoItWithVcl( const OUString& sImageFile)
 {
     try
     {
-        MyWorkWindow *pWindow = new MyWorkWindow( NULL, WB_APP | WB_STDWORK | WB_SIZEABLE | WB_CLOSEABLE | WB_CLIPCHILDREN );
+        VclPtrInstance<MyWorkWindow> pWindow( nullptr, WB_APP | WB_STDWORK | WB_SIZEABLE | WB_CLOSEABLE | WB_CLIPCHILDREN );
 
         pWindow->SetText(OUString("VCL Image Test"));
 
         pWindow->LoadGraphic( sImageFile );
-        pWindow->mpFixedBitmap = new FixedBitmap( pWindow );
+        pWindow->mpFixedBitmap = VclPtr<FixedBitmap>::Create( pWindow );
         pWindow->mpFixedBitmap->SetPosPixel( Point( 0, 0 ) );
         pWindow->mpFixedBitmap->Show();
 
diff --git a/vcl/workben/mtfdemo.cxx b/vcl/workben/mtfdemo.cxx
index 54c64ff..05ab644 100644
--- a/vcl/workben/mtfdemo.cxx
+++ b/vcl/workben/mtfdemo.cxx
@@ -88,7 +88,7 @@ public:
     {
         try
         {
-            mpWin = new DemoMtfWin(maFileName);
+            mpWin = VclPtr<DemoMtfWin>::Create(maFileName);
             mpWin->SetText(OUString("Display metafile"));
 
             mpWin->Show();
diff --git a/vcl/workben/svpclient.cxx b/vcl/workben/svpclient.cxx
index 428cfa7..01ad3e9 100644
--- a/vcl/workben/svpclient.cxx
+++ b/vcl/workben/svpclient.cxx
@@ -130,10 +130,10 @@ void Main()
 
 MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) :
     WorkWindow( pParent, nWinStyle ),
-    m_aListButton(new PushButton(this, 0)),
-    m_aSvpBitmaps(new ListBox(this, WB_BORDER)),
-    m_aImage(new ImageControl(this, WB_BORDER)),
-    m_aQuitButton(new PushButton(this, 0))
+    m_aListButton(VclPtr<PushButton>::Create(this, 0)),
+    m_aSvpBitmaps(VclPtr<ListBox>::Create(this, WB_BORDER)),
+    m_aImage(VclPtr<ImageControl>::Create(this, WB_BORDER)),
+    m_aQuitButton(VclPtr<PushButton>::Create(this, 0))
 {
     m_aListButton->SetPosSizePixel( Point( 10, 10 ), Size( 120, 25 ) );
     m_aListButton->SetText( OUString( "List Elements" ) );
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 33682e1..4f42f93 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -777,9 +777,9 @@ public:
             ScopedVclPtr<VirtualDevice> pNested;
 
             if ((int)eType < RENDER_AS_BITMAPEX)
-                pNested = new VirtualDevice(rDev);
+                pNested = VclPtr<VirtualDevice>::Create(rDev).get();
             else
-                pNested = new VirtualDevice(rDev,0,0);
+                pNested = VclPtr<VirtualDevice>::Create(rDev,0,0).get();
 
             pNested->SetOutputSizePixel(r.GetSize());
             Rectangle aWhole(Point(0,0), r.GetSize());
@@ -1230,8 +1230,8 @@ bool DemoRenderer::MouseButtonDown(const MouseEvent& rMEvt)
     // otherwise bounce floating windows
     if (!mpButton)
     {
-        mpButtonWin = new FloatingWindow(this);
-        mpButton = new PushButton(mpButtonWin);
+        mpButtonWin = VclPtr<FloatingWindow>::Create(this);
+        mpButton = VclPtr<PushButton>::Create(mpButtonWin);
         mpButton->SetSymbol(SymbolType::HELP);
         mpButton->SetText("PushButton demo");
         mpButton->SetPosSizePixel(Point(0,0), mpButton->GetOptimalSize());
@@ -1406,7 +1406,7 @@ public:
             }
             else
             { // spawn another window
-                DemoWin *pNewWin = new DemoWin(mrRenderer, testThreads);
+                VclPtrInstance<DemoWin> pNewWin(mrRenderer, testThreads);
                 pNewWin->SetText("Another interactive VCL demo window");
                 pNewWin->Show();
             }


More information about the Libreoffice-commits mailing list