Kaydet (Commit) 0e491a7a authored tarafından Michael Meeks's avatar Michael Meeks

vclptr: add isDisposed method - and assert for it here & there.

Change-Id: I2b154e0ed9eee0a45900ada7f805a1d444a31bc0
üst c612c3b0
...@@ -390,6 +390,7 @@ protected: ...@@ -390,6 +390,7 @@ protected:
public: public:
/// call the dispose() method if we have not already been disposed. /// call the dispose() method if we have not already been disposed.
void disposeOnce(); void disposeOnce();
bool isDisposed() const { return mbDisposed; }
public: public:
......
...@@ -65,6 +65,7 @@ SfxPrinter* DocumentDeviceManager::getPrinter(/*[in]*/ bool bCreate ) const ...@@ -65,6 +65,7 @@ SfxPrinter* DocumentDeviceManager::getPrinter(/*[in]*/ bool bCreate ) const
void DocumentDeviceManager::setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged ) void DocumentDeviceManager::setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged )
{ {
assert ( !pP->isDisposed() );
if ( pP != mpPrt ) if ( pP != mpPrt )
{ {
if ( bDeleteOld ) if ( bDeleteOld )
...@@ -100,11 +101,15 @@ VirtualDevice* DocumentDeviceManager::getVirtualDevice(/*[in]*/ bool bCreate ) c ...@@ -100,11 +101,15 @@ VirtualDevice* DocumentDeviceManager::getVirtualDevice(/*[in]*/ bool bCreate ) c
else else
pRet = &CreateVirtualDevice_(); pRet = &CreateVirtualDevice_();
assert ( !pRet->isDisposed() );
return pRet; return pRet;
} }
void DocumentDeviceManager::setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool ) void DocumentDeviceManager::setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool )
{ {
assert ( !pVd->isDisposed() );
if ( mpVirDev.get() != pVd ) if ( mpVirDev.get() != pVd )
{ {
if ( bDeleteOld ) if ( bDeleteOld )
...@@ -133,6 +138,8 @@ OutputDevice* DocumentDeviceManager::getReferenceDevice(/*[in]*/ bool bCreate ) ...@@ -133,6 +138,8 @@ OutputDevice* DocumentDeviceManager::getReferenceDevice(/*[in]*/ bool bCreate )
pRet = getVirtualDevice( bCreate ); pRet = getVirtualDevice( bCreate );
} }
assert ( !pRet->isDisposed() );
return pRet; return pRet;
} }
......
...@@ -389,6 +389,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf ...@@ -389,6 +389,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
if ( OUString ( pPrinter->GetName()) != sPrinterName ) if ( OUString ( pPrinter->GetName()) != sPrinterName )
{ {
VclPtr<SfxPrinter> pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName ); VclPtr<SfxPrinter> pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
assert (! pNewPrinter->isDisposed() );
if( pNewPrinter->IsKnown() ) if( pNewPrinter->IsKnown() )
{ {
// set printer only once; in _postSetValues // set printer only once; in _postSetValues
...@@ -426,7 +427,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf ...@@ -426,7 +427,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
}; };
SfxItemSet *pItemSet = new SfxItemSet( mpDoc->GetAttrPool(), nRange ); SfxItemSet *pItemSet = new SfxItemSet( mpDoc->GetAttrPool(), nRange );
VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, pItemSet ); VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, pItemSet );
assert (! pPrinter->isDisposed() );
// set printer only once; in _postSetValues // set printer only once; in _postSetValues
mpPrinter.disposeAndClear(); mpPrinter.disposeAndClear();
mpPrinter = pPrinter; mpPrinter = pPrinter;
......
...@@ -144,11 +144,13 @@ or: ...@@ -144,11 +144,13 @@ or:
their constructors. their constructors.
* Pass 'const VclPtr<> &' instead of pointers everywhere * 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 * Cleanup common existing methods such that they continue to
work post-dispose. work post-dispose.
* Dispose functions shoudl be audited to: * Dispose functions should be audited to:
+ not leave dangling pointsr + not leave dangling pointsr
+ shrink them - some work should incrementally + shrink them - some work should incrementally
migrate back to destructors. migrate back to destructors.
......
...@@ -91,7 +91,12 @@ vcl::FontInfo OutputDevice::GetDevFont( int nDevFontIndex ) const ...@@ -91,7 +91,12 @@ vcl::FontInfo OutputDevice::GetDevFont( int nDevFontIndex ) const
int OutputDevice::GetDevFontCount() const int OutputDevice::GetDevFontCount() const
{ {
if( !mpGetDevFontList ) if( !mpGetDevFontList )
{
if (!mpFontCollection)
return 0;
mpGetDevFontList = mpFontCollection->GetDevFontList(); mpGetDevFontList = mpFontCollection->GetDevFontList();
}
return mpGetDevFontList->Count(); return mpGetDevFontList->Count();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment