[Libreoffice-commits] .: 5 commits - comphelper/source l10ntools/source svtools/source vcl/source vcl/unx
David Tardon
dtardon at kemper.freedesktop.org
Thu May 12 05:34:03 PDT 2011
comphelper/source/misc/componentmodule.cxx | 9 ++++++++-
l10ntools/source/help/HelpCompiler.cxx | 10 +---------
svtools/source/misc/embedhlp.cxx | 1 +
vcl/source/gdi/pngwrite.cxx | 10 +++++-----
vcl/unx/source/gdi/salgdi3.cxx | 10 ++++------
5 files changed, 19 insertions(+), 21 deletions(-)
New commits:
commit 9e25aabc9ea679755b577efd2e97af472ec51f0d
Author: David Tardon <dtardon at redhat.com>
Date: Thu May 12 12:26:39 2011 +0200
prefer C++ wrapper to avoid leak
diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx
index 97f4e70..e7f93a5 100644
--- a/vcl/unx/source/gdi/salgdi3.cxx
+++ b/vcl/unx/source/gdi/salgdi3.cxx
@@ -65,6 +65,7 @@
#include "rtl/tencinfo.h"
#include "osl/file.hxx"
+#include "osl/module.hxx"
#include "tools/string.hxx"
#include "tools/debug.hxx"
@@ -250,7 +251,7 @@ namespace {
class CairoWrapper
{
private:
- oslModule mpCairoLib;
+ osl::Module mpCairoLib;
cairo_surface_t* (*mp_xlib_surface_create_with_xrender_format)(Display *, Drawable , Screen *, XRenderPictFormat *, int , int );
void (*mp_surface_destroy)(cairo_surface_t *);
@@ -327,7 +328,6 @@ CairoWrapper& CairoWrapper::get()
}
CairoWrapper::CairoWrapper()
-: mpCairoLib( NULL )
{
static const char* pDisableCairoText = getenv( "SAL_DISABLE_CAIROTEXT" );
if( pDisableCairoText && (pDisableCairoText[0] != '0') )
@@ -342,8 +342,7 @@ CairoWrapper::CairoWrapper()
#else
OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( "libcairo.so.2" ));
#endif
- mpCairoLib = osl_loadModule( aLibName.pData, SAL_LOADMODULE_DEFAULT );
- if( !mpCairoLib )
+ if ( !mpCairoLib.load( aLibName, SAL_LOADMODULE_DEFAULT ) )
return;
#ifdef DEBUG
@@ -411,8 +410,7 @@ CairoWrapper::CairoWrapper()
mp_ft_font_options_substitute
) )
{
- osl_unloadModule( mpCairoLib );
- mpCairoLib = NULL;
+ mpCairoLib.unload();
#if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "not all needed symbols were found\n" );
#endif
commit a8fbd645ac25d78af807554c0e10b40d33e27028
Author: David Tardon <dtardon at redhat.com>
Date: Thu May 12 12:13:14 2011 +0200
do not leak memory
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index cb533db..83058d5 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -294,6 +294,7 @@ EmbeddedObjectRef::~EmbeddedObjectRef()
{
delete mpImp->pGraphic;
Clear();
+ delete mpImp;
}
void EmbeddedObjectRef::Assign( const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& xObj, sal_Int64 nAspect )
commit 5ce97cd6e74d6b2cd40593814b5885d3044b23bd
Author: David Tardon <dtardon at redhat.com>
Date: Thu May 12 10:14:39 2011 +0200
the else branch is unreachable
diff --git a/l10ntools/source/help/HelpCompiler.cxx b/l10ntools/source/help/HelpCompiler.cxx
index b53e824..9e25ee9 100644
--- a/l10ntools/source/help/HelpCompiler.cxx
+++ b/l10ntools/source/help/HelpCompiler.cxx
@@ -464,7 +464,7 @@ bool HelpCompiler::compile( void ) throw( HelpProcessingException )
streamTable.default_helptexts = aparser.helptexts;
streamTable.default_keywords = aparser.keywords;
}
- else if (modulename == module)
+ else
{
streamTable.dropappl();
streamTable.appl_doc = docResolvedDoc;
@@ -472,14 +472,6 @@ bool HelpCompiler::compile( void ) throw( HelpProcessingException )
streamTable.appl_helptexts = aparser.helptexts;
streamTable.appl_keywords = aparser.keywords;
}
- else
- {
- std::stringstream aStrStream;
- aStrStream << "ERROR: Found unexpected module name \"" << modulename
- << "\" in file" << src.native_file_string().c_str() << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
} // end iteration over all applications
streamTable.document_id = documentId;
commit d5a093d760bc23fa4f3336e78fb5e989e83568cc
Author: David Tardon <dtardon at redhat.com>
Date: Thu May 12 09:24:07 2011 +0200
ensure the pointer is 0
diff --git a/vcl/source/gdi/pngwrite.cxx b/vcl/source/gdi/pngwrite.cxx
index be78b1b..0146d66 100644
--- a/vcl/source/gdi/pngwrite.cxx
+++ b/vcl/source/gdi/pngwrite.cxx
@@ -186,7 +186,7 @@ PNGWriterImpl::PNGWriterImpl( const BitmapEx& rBmpEx,
ImplWriteTransparent();
ImplWriteIDAT();
}
- aBmp.ReleaseAccess( mpAccess );
+ aBmp.ReleaseAccess( mpAccess ), mpAccess = 0;
}
else
mbStatus = sal_False;
@@ -207,7 +207,7 @@ PNGWriterImpl::PNGWriterImpl( const BitmapEx& rBmpEx,
ImplWritepHYs( rBmpEx );
ImplWriteIDAT();
}
- aMask.ReleaseAccess( mpMaskAccess );
+ aMask.ReleaseAccess( mpMaskAccess ), mpMaskAccess = 0;
}
else
mbStatus = sal_False;
@@ -223,12 +223,12 @@ PNGWriterImpl::PNGWriterImpl( const BitmapEx& rBmpEx,
ImplWritepHYs( rBmpEx );
ImplWriteIDAT();
}
- aMask.ReleaseAccess( mpMaskAccess );
+ aMask.ReleaseAccess( mpMaskAccess ), mpMaskAccess = 0;
}
else
mbStatus = sal_False;
}
- aBmp.ReleaseAccess( mpAccess );
+ aBmp.ReleaseAccess( mpAccess ), mpAccess = 0;
}
else
mbStatus = sal_False;
@@ -247,7 +247,7 @@ PNGWriterImpl::PNGWriterImpl( const BitmapEx& rBmpEx,
ImplWriteIDAT();
}
- aBmp.ReleaseAccess( mpAccess );
+ aBmp.ReleaseAccess( mpAccess ), mpAccess = 0;
}
else
mbStatus = sal_False;
commit f9496177a4c942f2acc39a978a3cd65689f14d8d
Author: David Tardon <dtardon at redhat.com>
Date: Thu May 12 06:44:54 2011 +0200
do not leak memory
diff --git a/comphelper/source/misc/componentmodule.cxx b/comphelper/source/misc/componentmodule.cxx
index 56183da..bb1cd73 100644
--- a/comphelper/source/misc/componentmodule.cxx
+++ b/comphelper/source/misc/componentmodule.cxx
@@ -85,7 +85,7 @@ namespace comphelper
//-------------------------------------------------------------------------
OModule::OModule()
:m_nClients( 0 )
- ,m_pImpl( new OModuleImpl )
+ ,m_pImpl( 0 )
{
}
@@ -110,17 +110,24 @@ namespace comphelper
//--------------------------------------------------------------------------
void OModule::onFirstClient()
{
+ OSL_PRECOND( !m_pImpl, "called out of sequence" );
+ if ( !m_pImpl )
+ m_pImpl = new OModuleImpl;
}
//--------------------------------------------------------------------------
void OModule::onLastClient()
{
+ OSL_PRECOND( m_pImpl, "called out of sequence" );
+ delete m_pImpl;
+ m_pImpl = 0;
}
//--------------------------------------------------------------------------
void OModule::registerImplementation( const ComponentDescription& _rComp )
{
::osl::MutexGuard aGuard( m_aMutex );
+ OSL_PRECOND( m_pImpl, "not initialized properly" );
if ( !m_pImpl )
throw RuntimeException();
More information about the Libreoffice-commits
mailing list