[Libreoffice-commits] core.git: Branch 'feature/vclref' - 3 commits - canvas/source framework/source include/sfx2 include/vcl sd/source sfx2/source sw/source

Noel Grandin noel at peralex.com
Mon Mar 23 04:50:50 PDT 2015


 canvas/source/vcl/bitmapbackbuffer.cxx                |    3 +--
 framework/source/uielement/fontsizemenucontroller.cxx |    2 +-
 include/sfx2/printer.hxx                              |    1 +
 include/sfx2/viewsh.hxx                               |    2 +-
 include/vcl/outdev.hxx                                |    2 ++
 include/vcl/vclptr.hxx                                |    1 +
 sd/source/ui/presenter/PresenterTextView.cxx          |    7 +++----
 sfx2/source/view/printer.cxx                          |    6 ++++++
 sfx2/source/view/viewprn.cxx                          |    4 ++--
 sw/source/ui/dialog/ascfldlg.cxx                      |    4 ++--
 10 files changed, 20 insertions(+), 12 deletions(-)

New commits:
commit a304135e156d0b616766570790106879d783262e
Author: Noel Grandin <noel at peralex.com>
Date:   Mon Mar 23 13:47:50 2015 +0200

    vclwidget: some small fixes
    
    Change-Id: I094163c894ff9accf70050d5a4fab83e905a282b

diff --git a/framework/source/uielement/fontsizemenucontroller.cxx b/framework/source/uielement/fontsizemenucontroller.cxx
index 3e09765..1c0af14 100644
--- a/framework/source/uielement/fontsizemenucontroller.cxx
+++ b/framework/source/uielement/fontsizemenucontroller.cxx
@@ -135,7 +135,7 @@ void FontSizeMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& r
     if ( pVCLPopupMenu )
     {
         boost::scoped_ptr<FontList> pFontList;
-        boost::scoped_ptr<Printer>  pInfoPrinter;
+        ScopedVclPtr<Printer>  pInfoPrinter;
         OUString   aPrinterName;
 
         SolarMutexGuard aSolarMutexGuard;
diff --git a/include/sfx2/printer.hxx b/include/sfx2/printer.hxx
index f07a135..694e2e8 100644
--- a/include/sfx2/printer.hxx
+++ b/include/sfx2/printer.hxx
@@ -51,6 +51,7 @@ public:
                                         const JobSetup &rTheOrigJobSetup );
                             SfxPrinter( const SfxPrinter &rPrinter );
                             virtual ~SfxPrinter();
+    virtual void            dispose() SAL_OVERRIDE;
 
     SfxPrinter*             Clone() const;
 
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index a9347ad..29fba0d 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -285,7 +285,7 @@ public:
     SAL_DLLPRIVATE void ResetAllClients_Impl( SfxInPlaceClient *pIP );
     SAL_DLLPRIVATE void DiscardClients_Impl();
 
-    SAL_DLLPRIVATE SfxPrinter* SetPrinter_Impl( SfxPrinter *pNewPrinter );
+    SAL_DLLPRIVATE SfxPrinter* SetPrinter_Impl( VclPtr<SfxPrinter>& pNewPrinter );
     SAL_DLLPRIVATE bool IsShowView_Impl() const;
 
     SAL_DLLPRIVATE bool HandleNotifyEvent_Impl( NotifyEvent& rEvent );
diff --git a/sd/source/ui/presenter/PresenterTextView.cxx b/sd/source/ui/presenter/PresenterTextView.cxx
index 4f2e6ca..7a9f18e 100644
--- a/sd/source/ui/presenter/PresenterTextView.cxx
+++ b/sd/source/ui/presenter/PresenterTextView.cxx
@@ -101,7 +101,7 @@ public:
 private:
     Reference<rendering::XBitmap> mxBitmap;
     cppcanvas::CanvasSharedPtr mpCanvas;
-    VirtualDevice* mpOutputDevice;
+    VclPtr<VirtualDevice> mpOutputDevice;
     EditEngine* mpEditEngine;
     SfxItemPool* mpEditEngineItemPool;
     Size maSize;
@@ -280,7 +280,7 @@ PresenterTextView::Implementation::~Implementation (void)
 {
     delete mpEditEngine;
     SfxItemPool::Free(mpEditEngineItemPool);
-    delete mpOutputDevice;
+    mpOutputDevice.disposeAndClear();
 }
 
 EditEngine * PresenterTextView::Implementation::GetEditEngine (void)
@@ -473,8 +473,7 @@ Reference<rendering::XBitmap> PresenterTextView::Implementation::GetBitmap (void
 
     if ( ! mxBitmap.is())
     {
-        if (mpOutputDevice != NULL)
-            delete mpOutputDevice;
+        mpOutputDevice.disposeAndClear();
         mpOutputDevice = new VirtualDevice(*Application::GetDefaultDevice(), 0, 0);
         mpOutputDevice->SetMapMode(MAP_PIXEL);
         mpOutputDevice->SetOutputSizePixel(maSize, true);
diff --git a/sfx2/source/view/printer.cxx b/sfx2/source/view/printer.cxx
index ee08f4d..add92b0 100644
--- a/sfx2/source/view/printer.cxx
+++ b/sfx2/source/view/printer.cxx
@@ -189,8 +189,14 @@ SfxPrinter* SfxPrinter::Clone() const
 
 SfxPrinter::~SfxPrinter()
 {
+    disposeOnce();
+}
+
+void SfxPrinter::dispose()
+{
     delete pOptions;
     delete pImpl;
+    Printer::dispose();
 }
 
 
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 7e13153..44f2731 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -471,7 +471,7 @@ IMPL_LINK_NOARG(SfxDialogExecutor_Impl, Execute)
    Internal method for setting the differences between 'pNewPrinter' to the
    current printer. pNewPrinter is either taken over or deleted.
 */
-SfxPrinter* SfxViewShell::SetPrinter_Impl( SfxPrinter *pNewPrinter )
+SfxPrinter* SfxViewShell::SetPrinter_Impl( VclPtr<SfxPrinter>& pNewPrinter )
 {
     // get current Printer
     SfxPrinter *pDocPrinter = GetPrinter();
@@ -560,7 +560,7 @@ SfxPrinter* SfxViewShell::SetPrinter_Impl( SfxPrinter *pNewPrinter )
 
         // Keep old changed Printer.
         pDocPrinter->SetPrinterProps( pNewPrinter );
-        delete pNewPrinter;
+        pNewPrinter.disposeAndClear();
     }
 
     if ( 0 != nChangedFlags )
diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx
index 308e819..e3e83fc 100644
--- a/sw/source/ui/dialog/ascfldlg.cxx
+++ b/sw/source/ui/dialog/ascfldlg.cxx
@@ -174,7 +174,7 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( vcl::Window* pParent, SwDocShell& rDocSh,
 
         {
             bool bDelPrinter = false;
-            SfxPrinter* pPrt = pDoc ? pDoc->getIDocumentDeviceAccess().getPrinter(false) : 0;
+            VclPtr<SfxPrinter> pPrt = pDoc ? pDoc->getIDocumentDeviceAccess().getPrinter(false) : 0;
             if( !pPrt )
             {
                 SfxItemSet* pSet = new SfxItemSet( rDocSh.GetPool(),
@@ -211,7 +211,7 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( vcl::Window* pParent, SwDocShell& rDocSh,
             m_pFontLB->SelectEntry( aOpt.GetFontName() );
 
             if( bDelPrinter )
-                delete pPrt;
+                pPrt.disposeAndClear();
         }
 
     }
commit bc72e49b4b79569a2fe46690e449804d51f6609f
Author: Noel Grandin <noel at peralex.com>
Date:   Mon Mar 23 10:25:26 2015 +0200

    vclwidget: add some safety net asserts
    
    Change-Id: I5fa19ec6161ab97eb7df8b52a268917f41ae2205

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 586a8a2..0662dbc 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -270,11 +270,13 @@ private:
 
     inline void acquire() const
     {
+        assert(!mbDisposed);
         mnRefCnt++;
     }
 
     inline void release() const
     {
+        assert(mnRefCnt>0);
         if (!--mnRefCnt)
             delete const_cast<OutputDevice*>(this);
     }
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index 3e0de76..6ab6373 100644
--- a/include/vcl/vclptr.hxx
+++ b/include/vcl/vclptr.hxx
@@ -270,6 +270,7 @@ public:
     ~ScopedVclPtr()
     {
         VclPtr<reference_type>::disposeAndClear();
+        assert(VclPtr<reference_type>::get() == nullptr); // make sure there are no lingering references
     }
 private:
     // Most likely we don't want this default copy-construtor.
commit 3416145f4264db8aa4504e54cedb2fde371cef3e
Author: Noel Grandin <noel at peralex.com>
Date:   Mon Mar 23 10:24:57 2015 +0200

    calling delete on VclPtr
    
    Change-Id: I25346435d2129086281783636624b1bb430d0096

diff --git a/canvas/source/vcl/bitmapbackbuffer.cxx b/canvas/source/vcl/bitmapbackbuffer.cxx
index d140ea0..1bbf73c 100644
--- a/canvas/source/vcl/bitmapbackbuffer.cxx
+++ b/canvas/source/vcl/bitmapbackbuffer.cxx
@@ -45,8 +45,7 @@ namespace vclcanvas
         // are supposed to be called with already locked solar mutex)
         SolarMutexGuard aGuard;
 
-        if( mpVDev )
-            delete mpVDev;
+        mpVDev.disposeAndClear();
     }
 
     OutputDevice& BitmapBackBuffer::getOutDev()


More information about the Libreoffice-commits mailing list