[Libreoffice-commits] core.git: Branch 'feature/vclref' - 2 commits - basctl/source desktop/source sfx2/source starmath/source svtools/source sw/source vcl/source

Michael Meeks michael.meeks at collabora.com
Fri Mar 20 16:03:56 PDT 2015


 basctl/source/basicide/basdoc.cxx            |    4 
 desktop/source/splash/splash.cxx             |  140 +++++++++++++++------------
 sfx2/source/view/viewprn.cxx                 |    9 -
 starmath/source/unomodel.cxx                 |    2 
 svtools/source/dialogs/prnsetup.cxx          |   10 +
 sw/source/uibase/uno/SwXDocumentSettings.cxx |    2 
 vcl/source/outdev/map.cxx                    |    3 
 7 files changed, 100 insertions(+), 70 deletions(-)

New commits:
commit ed1bd1867da5459dcefdc8f066aabe2ae5c08667
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Mar 20 23:08:41 2015 +0000

    protect more printer code-paths.
    
    Change-Id: Ic5bc5c3325b460cba0d95484454c9bb826684890

diff --git a/basctl/source/basicide/basdoc.cxx b/basctl/source/basicide/basdoc.cxx
index 2f00c5c..6e0c4de 100644
--- a/basctl/source/basicide/basdoc.cxx
+++ b/basctl/source/basicide/basdoc.cxx
@@ -51,7 +51,9 @@ DocShell::DocShell()
 }
 
 DocShell::~DocShell()
-{ }
+{
+    pPrinter.disposeAndClear();
+}
 
 SfxPrinter* DocShell::GetPrinter( bool bCreate )
 {
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index c9e5d0d..7e13153 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -628,7 +628,7 @@ Printer* SfxViewShell::GetActivePrinter() const
 void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
 {
     sal_uInt16              nDialogRet = RET_CANCEL;
-    SfxPrinter*             pPrinter = 0;
+    VclPtr<SfxPrinter>      pPrinter;
     bool                    bSilent = false;
 
     // does the function have been called by the user interface or by an API call
@@ -765,7 +765,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
 
                 // if printer is unknown, it can't be used - now printer from document will be used
                 if ( !pPrinter->IsKnown() )
-                    DELETEZ(pPrinter);
+                    pPrinter.disposeAndClear();
             }
 
             if ( SID_PRINTER_NAME == nId )
@@ -807,7 +807,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
             if ( !bIsAPI )
             {
                 // PrinterDialog needs a temporary printer
-                SfxPrinter* pDlgPrinter = pPrinter->Clone();
+                VclPtr<SfxPrinter> pDlgPrinter = pPrinter->Clone();
                 nDialogRet = 0;
 
                 // execute PrinterSetupDialog
@@ -859,13 +859,12 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
 
                     // forget new printer, it was taken over (as pPrinter) or deleted
                     pDlgPrinter = NULL;
-
                 }
                 else
                 {
                     // PrinterDialog is used to transfer information on printing,
                     // so it will only be deleted here if dialog was cancelled
-                    DELETEZ( pDlgPrinter );
+                    pDlgPrinter.disposeAndClear();
                     rReq.Ignore();
                 }
             }
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 2cee1b3..dfd260a 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -656,7 +656,7 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any*
                     SfxItemSet *pItemSet = new SfxItemSet( pDocSh->GetPool(), nRange );
                     SmModule *pp = SM_MOD();
                     pp->GetConfig()->ConfigToItemSet(*pItemSet);
-                    SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet );
+                    VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, pItemSet );
 
                     pDocSh->SetPrinter( pPrinter );
                 }
diff --git a/svtools/source/dialogs/prnsetup.cxx b/svtools/source/dialogs/prnsetup.cxx
index 72da5fd..84ed57f 100644
--- a/svtools/source/dialogs/prnsetup.cxx
+++ b/svtools/source/dialogs/prnsetup.cxx
@@ -53,8 +53,9 @@ void ImplFreePrnDlgListBox( ListBox* pBox, bool bClear )
 
 
 Printer* ImplPrnDlgListBoxSelect( ListBox* pBox, PushButton* pPropBtn,
-                                  Printer* pPrinter, Printer* pTempPrinter )
+                                  Printer* pPrinter, Printer* pTempPrinterIn )
 {
+    VclPtr<Printer> pTempPrinter( pTempPrinterIn );
     if ( pBox->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
     {
         const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->GetSelectEntry(), true );
@@ -73,7 +74,7 @@ Printer* ImplPrnDlgListBoxSelect( ListBox* pBox, PushButton* pPropBtn,
                 if ( (pTempPrinter->GetName() != pInfo->GetPrinterName()) ||
                      (pTempPrinter->GetDriverName() != pInfo->GetDriver()) )
                 {
-                    VclPtr<Printer>(pTempPrinter).disposeAndClear();
+                    pTempPrinter.disposeAndClear();
                     pTempPrinter = new Printer( *pInfo );
                 }
             }
@@ -91,8 +92,9 @@ Printer* ImplPrnDlgListBoxSelect( ListBox* pBox, PushButton* pPropBtn,
 
 
 
-Printer* ImplPrnDlgUpdatePrinter( Printer* pPrinter, Printer* pTempPrinter )
+Printer* ImplPrnDlgUpdatePrinter( Printer* pPrinter, Printer* pTempPrinterIn )
 {
+    VclPtr<Printer> pTempPrinter( pTempPrinterIn );
     OUString aPrnName;
     if ( pTempPrinter )
         aPrnName = pTempPrinter->GetName();
@@ -101,7 +103,7 @@ Printer* ImplPrnDlgUpdatePrinter( Printer* pPrinter, Printer* pTempPrinter )
 
     if ( ! Printer::GetQueueInfo( aPrnName, false ) )
     {
-        VclPtr<Printer>(pTempPrinter).disposeAndClear();
+        pTempPrinter.disposeAndClear();
         pTempPrinter = new Printer;
     }
 
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index dfd2cb1..f6f07f7 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -425,7 +425,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
                         0
                     };
                     SfxItemSet *pItemSet = new SfxItemSet( mpDoc->GetAttrPool(), nRange );
-                    SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet );
+                    VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, pItemSet );
 
                     // set printer only once; in _postSetValues
                     mpPrinter.disposeAndClear();
diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx
index 41909dc..dc57390 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -351,6 +351,9 @@ inline void ImplCalcMapResolution( const MapMode& rMapMode,
 // #i75163#
 void OutputDevice::ImplInvalidateViewTransform()
 {
+    if(!mpOutDevData)
+        return;
+
     if(mpOutDevData->mpViewTransform)
     {
         delete mpOutDevData->mpViewTransform;
commit c549b1bbb559deb2a9a8e5c571c380956b1ccd52
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 1fdc406..73e9649 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,14 +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;
 };
 
-SplashScreen::SplashScreen()
+SplashScreenWindow::SplashScreenWindow(SplashScreen *pSplash)
     : IntroWindow()
-    , _vdev(new VirtualDevice(*((IntroWindow*)this)))
+    , pSpl( pSplash )
+    , _vdev(new VirtualDevice(*this))
+{
+    _vdev->EnableRTL(IsRTLEnabled());
+}
+
+void SplashScreenWindow::dispose()
+{
+    pSpl = NULL;
+    IntroWindow::dispose();
+}
+
+SplashScreen::SplashScreen()
+    : 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))
@@ -149,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)
@@ -173,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();
     }
 }
 
@@ -187,8 +205,8 @@ void SAL_CALL SplashScreen::end()
     if (_bVisible )
     {
         if ( _eBitmapMode == BM_FULLSCREEN )
-            EndFullScreenMode();
-        Hide();
+            pWindow->EndFullScreenMode();
+        pWindow->Hide();
     }
     _bProgressEnd = true;
 }
@@ -200,8 +218,8 @@ void SAL_CALL SplashScreen::reset()
     if (_bVisible && !_bProgressEnd )
     {
         if ( _eBitmapMode == BM_FULLSCREEN )
-            ShowFullScreenMode( true );
-        Show();
+            pWindow->ShowFullScreenMode( true );
+        pWindow->Show();
         updateStatus();
     }
 }
@@ -217,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 +251,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 +277,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 +348,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 +364,7 @@ IMPL_LINK( SplashScreen, AppEventListenerHdl, VclWindowEvent *, inEvent )
         switch ( inEvent->GetId() )
         {
             case VCLEVENT_WINDOW_SHOW:
-                Paint( Rectangle() );
+                pWindow->Paint( Rectangle() );
                 break;
             default:
                 break;
@@ -583,18 +605,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 +625,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,
-                                            CTRL_STATE_ENABLED, aValue, _sProgressText )) )
+                                CTRL_STATE_ENABLED, aValue, pSpl->_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() );
 }


More information about the Libreoffice-commits mailing list