[Libreoffice-commits] core.git: Branch 'feature/vclref' - include/vcl sw/source vcl/README.lifecycle vcl/source
Michael Meeks
michael.meeks at collabora.com
Mon Mar 23 02:12:04 PDT 2015
include/vcl/outdev.hxx | 1 +
sw/source/core/doc/DocumentDeviceManager.cxx | 7 +++++++
sw/source/uibase/uno/SwXDocumentSettings.cxx | 3 ++-
vcl/README.lifecycle | 4 +++-
vcl/source/outdev/font.cxx | 5 +++++
5 files changed, 18 insertions(+), 2 deletions(-)
New commits:
commit 9cea77d7810f9cd647b9551bf90da9701b99de60
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Mon Mar 23 09:14:13 2015 +0000
vclptr: add isDisposed method - and assert for it here & there.
Change-Id: I2b154e0ed9eee0a45900ada7f805a1d444a31bc0
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index c85bfbd..586a8a2 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -383,6 +383,7 @@ protected:
public:
/// call the dispose() method if we have not already been disposed.
void disposeOnce();
+ bool isDisposed() const { return mbDisposed; }
public:
diff --git a/sw/source/core/doc/DocumentDeviceManager.cxx b/sw/source/core/doc/DocumentDeviceManager.cxx
index ac86e69..3e8f6c9 100644
--- a/sw/source/core/doc/DocumentDeviceManager.cxx
+++ b/sw/source/core/doc/DocumentDeviceManager.cxx
@@ -65,6 +65,7 @@ SfxPrinter* DocumentDeviceManager::getPrinter(/*[in]*/ bool bCreate ) const
void DocumentDeviceManager::setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged )
{
+ assert ( !pP->isDisposed() );
if ( pP != mpPrt )
{
if ( bDeleteOld )
@@ -100,11 +101,15 @@ VirtualDevice* DocumentDeviceManager::getVirtualDevice(/*[in]*/ bool bCreate ) c
else
pRet = &CreateVirtualDevice_();
+ assert ( !pRet->isDisposed() );
+
return pRet;
}
void DocumentDeviceManager::setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool )
{
+ assert ( !pVd->isDisposed() );
+
if ( mpVirDev.get() != pVd )
{
if ( bDeleteOld )
@@ -133,6 +138,8 @@ OutputDevice* DocumentDeviceManager::getReferenceDevice(/*[in]*/ bool bCreate )
pRet = getVirtualDevice( bCreate );
}
+ assert ( !pRet->isDisposed() );
+
return pRet;
}
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index f6f07f7..8715422 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -389,6 +389,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
if ( OUString ( pPrinter->GetName()) != sPrinterName )
{
VclPtr<SfxPrinter> pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
+ assert (! pNewPrinter->isDisposed() );
if( pNewPrinter->IsKnown() )
{
// set printer only once; in _postSetValues
@@ -426,7 +427,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
};
SfxItemSet *pItemSet = new SfxItemSet( mpDoc->GetAttrPool(), nRange );
VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, pItemSet );
-
+ assert (! pPrinter->isDisposed() );
// set printer only once; in _postSetValues
mpPrinter.disposeAndClear();
mpPrinter = pPrinter;
diff --git a/vcl/README.lifecycle b/vcl/README.lifecycle
index 1ee7eab..0edd0c8 100644
--- a/vcl/README.lifecycle
+++ b/vcl/README.lifecycle
@@ -144,11 +144,13 @@ or:
their constructors.
* Pass 'const VclPtr<> &' instead of pointers everywhere
+ + add 'explicit' keywords to VclPtr constructors to
+ accelerate compilation etc.
* Cleanup common existing methods such that they continue to
work post-dispose.
- * Dispose functions shoudl be audited to:
+ * Dispose functions should be audited to:
+ not leave dangling pointsr
+ shrink them - some work should incrementally
migrate back to destructors.
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 3868a6b..6f38eb3 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -91,7 +91,12 @@ vcl::FontInfo OutputDevice::GetDevFont( int nDevFontIndex ) const
int OutputDevice::GetDevFontCount() const
{
if( !mpGetDevFontList )
+ {
+ if (!mpFontCollection)
+ return 0;
+
mpGetDevFontList = mpFontCollection->GetDevFontList();
+ }
return mpGetDevFontList->Count();
}
More information about the Libreoffice-commits
mailing list