summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-03-27 22:55:44 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-03-28 13:08:55 +0100
commit2ecae2b9b4d5b7280e308cbabed715f5d5042c46 (patch)
treed9c1c646751d0cf455a9d6e9acf54bba5f47f3dc /svtools
parent2f36279079e74e40a3fa2de5821c879e98d498e3 (diff)
don't leak pDirMutex and other code janitorials
don't leak pDirMutex drop intermediate UniString don't use static OUStrings drop C2U macro
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/config/extcolorcfg.cxx12
-rw-r--r--svtools/source/control/inettbc.cxx31
2 files changed, 16 insertions, 27 deletions
diff --git a/svtools/source/config/extcolorcfg.cxx b/svtools/source/config/extcolorcfg.cxx
index 89a3466ea2e7..3eaf165b0bf3 100644
--- a/svtools/source/config/extcolorcfg.cxx
+++ b/svtools/source/config/extcolorcfg.cxx
@@ -39,9 +39,6 @@
#include <svl/smplhint.hxx>
#include <osl/mutex.hxx>
- /* #100822# ----
-#include <vcl/wrkwin.hxx>
- ------------- */
#include <vcl/svapp.hxx>
#include <vcl/event.hxx>
#include <rtl/instance.hxx>
@@ -58,7 +55,6 @@ using ::rtl::OUString;
namespace svtools
{
-#define C2U(cChar) OUString::createFromAscii(cChar)
sal_Int32 nExtendedColorRefCount_Impl = 0;
namespace
{
@@ -208,7 +204,7 @@ ExtendedColorConfigValue ExtendedColorConfig_Impl::GetComponentColorConfigValue(
sal_Bool ExtendedColorConfig_Impl::m_bLockBroadcast = sal_False;
sal_Bool ExtendedColorConfig_Impl::m_bBroadcastWhenUnlocked = sal_False;
ExtendedColorConfig_Impl::ExtendedColorConfig_Impl(sal_Bool bEditMode) :
- ConfigItem(C2U("Office.ExtendedColorScheme")),
+ ConfigItem(rtl::OUString("Office.ExtendedColorScheme")),
m_bEditMode(bEditMode),
m_bIsBroadcastEnabled(sal_True)
{
@@ -476,7 +472,7 @@ void ExtendedColorConfig_Impl::CommitCurrentSchemeName()
{
//save current scheme name
uno::Sequence < ::rtl::OUString > aCurrent(1);
- aCurrent.getArray()[0] = C2U("ExtendedColorScheme/CurrentColorScheme");
+ aCurrent.getArray()[0] = rtl::OUString("ExtendedColorScheme/CurrentColorScheme");
uno::Sequence< uno::Any > aCurrentVal(1);
aCurrentVal.getArray()[0] <<= m_sLoadedScheme;
PutProperties(aCurrent, aCurrentVal);
@@ -509,7 +505,7 @@ void ExtendedColorConfig_Impl::SetColorConfigValue(const ::rtl::OUString& _sName
sal_Bool ExtendedColorConfig_Impl::AddScheme(const rtl::OUString& rScheme)
{
- if(ConfigItem::AddNode(C2U("ExtendedColorScheme/ColorSchemes"), rScheme))
+ if(ConfigItem::AddNode(rtl::OUString("ExtendedColorScheme/ColorSchemes"), rScheme))
{
m_sLoadedScheme = rScheme;
Commit();
@@ -522,7 +518,7 @@ sal_Bool ExtendedColorConfig_Impl::RemoveScheme(const rtl::OUString& rScheme)
{
uno::Sequence< rtl::OUString > aElements(1);
aElements.getArray()[0] = rScheme;
- return ClearNodeElements(C2U("ExtendedColorScheme/ColorSchemes"), aElements);
+ return ClearNodeElements(rtl::OUString("ExtendedColorScheme/ColorSchemes"), aElements);
}
void ExtendedColorConfig_Impl::SettingsChanged()
diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx
index ad5897de3ef8..1d05ea616f68 100644
--- a/svtools/source/control/inettbc.cxx
+++ b/svtools/source/control/inettbc.cxx
@@ -46,6 +46,7 @@
#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
+#include <rtl/instance.hxx>
#include <vcl/toolbox.hxx>
#include <salhelper/thread.hxx>
#include <osl/mutex.hxx>
@@ -121,20 +122,14 @@ class SvtMatchContext_Impl: public salhelper::Thread
void FillPicklist(std::vector<rtl::OUString>& rPickList);
public:
- static ::osl::Mutex* GetMutex();
-
SvtMatchContext_Impl( SvtURLBox* pBoxP, const String& rText );
void Stop();
};
-::osl::Mutex* SvtMatchContext_Impl::pDirMutex = 0;
-
-::osl::Mutex* SvtMatchContext_Impl::GetMutex()
+namespace
{
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if( !pDirMutex )
- pDirMutex = new ::osl::Mutex;
- return pDirMutex;
+ struct theSvtMatchContextMutex
+ : public rtl::Static< ::osl::Mutex, theSvtMatchContextMutex > {};
}
SvtMatchContext_Impl::SvtMatchContext_Impl(
@@ -558,7 +553,7 @@ String SvtURLBox::ParseSmart( String aText, String aBaseURL, String aWorkDir )
//-------------------------------------------------------------------------
void SvtMatchContext_Impl::doExecute()
{
- ::osl::MutexGuard aGuard( GetMutex() );
+ ::osl::MutexGuard aGuard( theSvtMatchContextMutex::get() );
if( bStop )
// have we been stopped while we were waiting for the mutex?
return;
@@ -930,7 +925,7 @@ sal_Bool SvtURLBox::ProcessKey( const KeyCode& rKey )
if ( aCode == KEY_RETURN && GetText().Len() )
{
// wait for completion of matching thread
- ::osl::MutexGuard aGuard( SvtMatchContext_Impl::GetMutex() );
+ ::osl::MutexGuard aGuard( theSvtMatchContextMutex::get() );
if ( bAutoCompleteMode )
{
@@ -1097,7 +1092,7 @@ void SvtURLBox::SetNoURLSelection( sal_Bool bSet )
String SvtURLBox::GetURL()
{
// wait for end of autocompletion
- ::osl::MutexGuard aGuard( SvtMatchContext_Impl::GetMutex() );
+ ::osl::MutexGuard aGuard( theSvtMatchContextMutex::get() );
String aText( GetText() );
if ( MatchesPlaceHolder( aText ) )
@@ -1134,8 +1129,8 @@ String SvtURLBox::GetURL()
if ( aObj.GetProtocol() == INET_PROT_NOT_VALID )
{
- String aName = ParseSmart( aText, aBaseURL, SvtPathOptions().GetWorkPath() );
- aObj.SetURL( aName );
+ rtl::OUString aName = ParseSmart( aText, aBaseURL, SvtPathOptions().GetWorkPath() );
+ aObj.SetURL(aName);
::rtl::OUString aURL( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
if ( aURL.isEmpty() )
// aText itself is invalid, and even together with aBaseURL, it could not
@@ -1144,13 +1139,11 @@ String SvtURLBox::GetURL()
bool bSlash = aObj.hasFinalSlash();
{
- static const rtl::OUString aPropName(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CasePreservingURL" )));
+ const rtl::OUString aPropName("CasePreservingURL");
rtl::OUString aFileURL;
- Any aAny =
- UCBContentHelper::GetProperty(aURL,aPropName);
+ Any aAny = UCBContentHelper::GetProperty(aURL, aPropName);
sal_Bool success = (aAny >>= aFileURL);
rtl::OUString aTitle;
if(success)
@@ -1185,7 +1178,7 @@ void SvtURLBox::DisableHistory()
void SvtURLBox::SetBaseURL( const String& rURL )
{
- ::osl::MutexGuard aGuard( SvtMatchContext_Impl::GetMutex() );
+ ::osl::MutexGuard aGuard( theSvtMatchContextMutex::get() );
// Reset match lists
pImp->aCompletions.clear();