[Libreoffice-commits] .: linguistic/source

2012-02-16 Thread Caolán McNamara
 linguistic/source/dlistimp.cxx |4 ++--
 linguistic/source/dlistimp.hxx |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 77eaa51bc47ff6b02f319053d4ca5aaf37b28f37
Author: Mariusz Dykierek mariuszdykie...@gmail.com
Date:   Thu Feb 16 12:20:09 2012 +

possible inefficient checking for emptiness

diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx
index e824888..316d86d 100644
--- a/linguistic/source/dlistimp.cxx
+++ b/linguistic/source/dlistimp.cxx
@@ -608,7 +608,7 @@ void SAL_CALL
 pDicEvtLstnrHelper-DisposeAndClear( aEvtObj );
 
 //! avoid creation of dictionaries if not already done
-if (aDicList.size()  0)
+if ( !aDicList.empty() )
 {
 DictionaryVec_t rDicList = GetOrCreateDicList();
 size_t nCount = rDicList.size();
@@ -720,7 +720,7 @@ void DicList::SaveDics()
 {
 // save dics only if they have already been used/created.
 //! don't create them just for the purpose of saving them !
-if (aDicList.size()  0)
+if ( !aDicList.empty() )
 {
 // save (modified) dictionaries
 DictionaryVec_t rDicList = GetOrCreateDicList();
diff --git a/linguistic/source/dlistimp.hxx b/linguistic/source/dlistimp.hxx
index 4eb9a1a..b4de818 100644
--- a/linguistic/source/dlistimp.hxx
+++ b/linguistic/source/dlistimp.hxx
@@ -89,7 +89,7 @@ class DicList :
 void_CreateDicList();
 DictionaryVec_tGetOrCreateDicList()
 {
-if (!bInCreation  aDicList.size() == 0)
+if ( !bInCreation  aDicList.empty() )
 _CreateDicList();
 return aDicList;
 }
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: linguistic/source

2012-02-11 Thread Julien Nabet
 linguistic/source/spelldsp.hxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit fef3122259092e03b3cf11721171d4b621c3a97f
Author: Julien Nabet serval2...@yahoo.fr
Date:   Sat Feb 11 17:34:20 2012 +0100

Avoid Possible null pointer dereference in linguistic/source/spelldsp.hxx

(Thank you to Ivan and Riccardo for their suggestions)

diff --git a/linguistic/source/spelldsp.hxx b/linguistic/source/spelldsp.hxx
index 9ae9cd4..e2186f9 100644
--- a/linguistic/source/spelldsp.hxx
+++ b/linguistic/source/spelldsp.hxx
@@ -73,7 +73,7 @@ class SpellCheckerDispatcher :
 ::com::sun::star::linguistic2::XSearchableDictionaryList   xDicList;
 
 LngSvcMgr   rMgr;
-linguistic::SpellCache  *pCache; // Spell Cache (holds known words)
+mutable linguistic::SpellCache  *pCache; // Spell Cache (holds known 
words)
 
 // disallow copy-constructor and assignment-operator for now
 SpellCheckerDispatcher(const SpellCheckerDispatcher );
@@ -134,7 +134,7 @@ public:
 inline linguistic::SpellCache  SpellCheckerDispatcher::GetCache() const
 {
 if (!pCache)
-((SpellCheckerDispatcher *) this)-pCache = new 
linguistic::SpellCache();
+pCache = new linguistic::SpellCache();
 return *pCache;
 }
 
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: linguistic/source

2011-12-30 Thread Jan Holesovsky
 linguistic/source/dicimp.cxx  |   10 +-
 linguistic/source/dlistimp.cxx|2 +-
 linguistic/source/gciterator.cxx  |8 
 linguistic/source/hyphdsp.cxx |2 +-
 linguistic/source/lngprophelp.cxx |4 ++--
 linguistic/source/lngsvcmgr.cxx   |   24 
 linguistic/source/misc.cxx|4 ++--
 linguistic/source/misc2.cxx   |6 +++---
 linguistic/source/spelldsp.cxx|   12 ++--
 linguistic/source/spelldta.cxx|2 +-
 linguistic/source/thesdsp.cxx |2 +-
 11 files changed, 38 insertions(+), 38 deletions(-)

New commits:
commit c3fc5c9c9b17cef63fa7c77a39a0971c27a004f9
Author: Olivier Hallot olivier.hal...@alta.org.br
Date:   Tue Dec 27 11:08:04 2011 -0200

Fix for fdo43460 Part XXIII getLength() to isEmpty()

Part XXIII
Modules
linguistic

diff --git a/linguistic/source/dicimp.cxx b/linguistic/source/dicimp.cxx
index 1af7d36..0a09ad5 100644
--- a/linguistic/source/dicimp.cxx
+++ b/linguistic/source/dicimp.cxx
@@ -230,7 +230,7 @@ DictionaryNeo::DictionaryNeo(const OUString rName,
 bIsModified  = bIsActive = sal_False;
 bIsReadonly = !bWriteable;
 
-if( rMainURL.getLength()  0 )
+if( !rMainURL.isEmpty())
 {
 sal_Bool bExists = FileExists( rMainURL );
 if( !bExists )
@@ -271,7 +271,7 @@ sal_uLong DictionaryNeo::loadEntries(const OUString 
rMainURL)
 // function should only be called once in order to load entries from file
 bNeedEntries = sal_False;
 
-if (rMainURL.getLength() == 0)
+if (rMainURL.isEmpty())
 return 0;
 
 uno::Reference lang::XMultiServiceFactory  xServiceFactory( 
comphelper::getProcessServiceFactory() );
@@ -411,7 +411,7 @@ sal_uLong DictionaryNeo::saveEntries(const OUString rURL)
 {
 MutexGuard  aGuard( GetLinguMutex() );
 
-if (rURL.getLength() == 0)
+if (rURL.isEmpty())
 return 0;
 DBG_ASSERT(!INetURLObject( rURL ).HasError(), lng : invalid URL);
 
@@ -999,7 +999,7 @@ sal_Bool SAL_CALL DictionaryNeo::hasLocation()
 throw(RuntimeException)
 {
 MutexGuard  aGuard( GetLinguMutex() );
-return aMainURL.getLength()  0;
+return !aMainURL.isEmpty();
 }
 
 OUString SAL_CALL DictionaryNeo::getLocation()
@@ -1075,7 +1075,7 @@ void SAL_CALL DictionaryNeo::storeToURL(
 DicEntry::DicEntry(const OUString rDicFileWord,
sal_Bool bIsNegativWord)
 {
-if (rDicFileWord.getLength())
+if (!rDicFileWord.isEmpty())
 splitDicFileWord( rDicFileWord, aDicWord, aReplacement );
 bIsNegativ = bIsNegativWord;
 }
diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx
index ac4f143..e824888 100644
--- a/linguistic/source/dlistimp.cxx
+++ b/linguistic/source/dlistimp.cxx
@@ -698,7 +698,7 @@ void DicList::_CreateDicList()
 sal_Int32 nLen = aActiveDics.getLength();
 for (sal_Int32 i = 0;  i  nLen;  ++i)
 {
-if (pActiveDic[i].getLength())
+if (!pActiveDic[i].isEmpty())
 {
 uno::Reference XDictionary  xDic( getDictionaryByName( 
pActiveDic[i] ) );
 if (xDic.is())
diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 1f6ef14..bdd6ee3 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -552,7 +552,7 @@ void GrammarCheckingIterator::DequeueAndCheck()
 
 sal_Int32 nStartPos = aFPEntryItem.m_nStartIndex;
 sal_Int32 nSuggestedEnd = GetSuggestedEndOfSentence( 
aCurTxt, nStartPos, aCurLocale );
-DBG_ASSERT( (nSuggestedEnd == 0  aCurTxt.getLength() == 
0) || nSuggestedEnd  nStartPos,
+DBG_ASSERT( (nSuggestedEnd == 0  aCurTxt.isEmpty()) || 
nSuggestedEnd  nStartPos,
 nSuggestedEndOfSentencePos calculation failed? );
 
 linguistic2::ProofreadingResult aRes;
@@ -824,7 +824,7 @@ throw (uno::RuntimeException)
 {
 // check in document is checked automatically in the background...
 OUString aDocId = aIt-second;
-if (m_aCurCheckedDocId.getLength()  0  m_aCurCheckedDocId == 
aDocId)
+if (!m_aCurCheckedDocId.isEmpty()  m_aCurCheckedDocId == aDocId)
 {
 // an entry for that document was dequed and is currently 
being checked.
 bRes = sal_True;
@@ -1099,7 +1099,7 @@ void GrammarCheckingIterator::SetServiceList(
 
 if (nLanguage != LANGUAGE_NONE  nLanguage != LANGUAGE_DONTKNOW)
 {
-if (aImplName.getLength()  0)
+if (!aImplName.isEmpty())
 m_aGCImplNamesByLang[ nLanguage ] = aImplName;
 else
 m_aGCImplNamesByLang.erase( nLanguage );
@@ -1120,7 +1120,7 @@ uno::Sequence OUString  
GrammarCheckingIterator::GetServiceList(
 if (aIt != m_aGCImplNamesByLang.end())
 aImplName = aIt-second;
 
-if (aImplName.getLength()  0)
+if (!aImplName.isEmpty())
 

[Libreoffice-commits] .: linguistic/source vcl/source

2011-12-16 Thread Stephan Bergmann
 linguistic/source/gciterator.cxx |   61 +--
 linguistic/source/gciterator.hxx |5 ++-
 vcl/source/app/svmain.cxx|4 ++
 3 files changed, 36 insertions(+), 34 deletions(-)

New commits:
commit c5cf78e1529970c04e1999e1f96f3e374ecd211e
Author: Stephan Bergmann sberg...@redhat.com
Date:   Fri Dec 16 17:06:42 2011 +0100

Properly join spawned GrammarCheckingIterator thread.

It was still running during shutdown of sw_complex's checkFlies test, 
causing
problems.
For this to work, Desktop::DeInit needs to be called with SolarMutex 
unlocked,
which looks like the right way, anyway.  Hopefully it does not unearth 
another
round of bugs...

diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 9828052..91c407c 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -252,15 +252,31 @@ GrammarCheckingIterator::GrammarCheckingIterator( const 
uno::Reference lang::XM
 m_aEventListeners( MyMutex::get() ),
 m_aNotifyListeners( MyMutex::get() )
 {
-osl_createThread( workerfunc, this );
+m_thread = osl_createThread( workerfunc, this );
 }
 
 
 GrammarCheckingIterator::~GrammarCheckingIterator()
 {
-::osl::Guard ::osl::Mutex  aGuard( MyMutex::get() );
+TerminateThread();
 }
 
+void GrammarCheckingIterator::TerminateThread()
+{
+oslThread t;
+{
+::osl::Guard ::osl::Mutex  aGuard( MyMutex::get() );
+t = m_thread;
+m_thread = 0;
+m_bEnd = sal_True;
+m_aWakeUpThread.set();
+}
+if (t != 0)
+{
+osl_joinWithThread(t);
+osl_destroyThread(t);
+}
+}
 
 sal_Int32 GrammarCheckingIterator::NextDocId()
 {
@@ -489,19 +505,16 @@ void GrammarCheckingIterator::DequeueAndCheck()
 uno::Sequence sal_Int32   aLangPortions;
 uno::Sequence lang::LocaleaLangPortionsLocale;
 
-//  THREAD SAFE START 
-bool bEnd = false;
-{
-::osl::Guard ::osl::Mutex  aGuard( MyMutex::get() );
-bEnd = m_bEnd;
-}
-//  THREAD SAFE END 
-while (!bEnd)
+for (;;)
 {
 //  THREAD SAFE START 
 bool bQueueEmpty = false;
 {
 ::osl::Guard ::osl::Mutex  aGuard( MyMutex::get() );
+if (m_bEnd)
+{
+break;
+}
 bQueueEmpty = m_aFPEntriesQueue.empty();
 }
 //  THREAD SAFE END 
@@ -605,6 +618,10 @@ void GrammarCheckingIterator::DequeueAndCheck()
 //  THREAD SAFE START 
 {
 ::osl::Guard ::osl::Mutex  aGuard( MyMutex::get() );
+if (m_bEnd)
+{
+break;
+}
 // Check queue state again
 if (m_aFPEntriesQueue.empty())
 m_aWakeUpThread.reset();
@@ -618,17 +635,7 @@ void GrammarCheckingIterator::DequeueAndCheck()
 // safe implemented.
 m_aWakeUpThread.wait();
 }
-
-//  THREAD SAFE START 
-{
-::osl::Guard ::osl::Mutex  aGuard( MyMutex::get() );
-bEnd = m_bEnd;
-}
-//  THREAD SAFE END 
 }
-
-//!! This one must be the very last statement to call in this function !!
-m_aRequestEndThread.set();
 }
 
 
@@ -901,19 +908,7 @@ throw (uno::RuntimeException)
 lang::EventObject aEvt( (linguistic2::XProofreadingIterator *) this );
 m_aEventListeners.disposeAndClear( aEvt );
 
-// now end the thread...
-m_aRequestEndThread.reset();
-//  THREAD SAFE START 
-{
-::osl::Guard ::osl::Mutex  aGuard( MyMutex::get() );
-m_bEnd = sal_True;
-}
-//  THREAD SAFE END 
-m_aWakeUpThread.set();
-const TimeValue aTime = { 3, 0 };   // wait 3 seconds...
-m_aRequestEndThread.wait( aTime );
-// if the call ends because of time-out we will end anyway...
-
+TerminateThread();
 
 //  THREAD SAFE START 
 {
diff --git a/linguistic/source/gciterator.hxx b/linguistic/source/gciterator.hxx
index aab04dd..8dda009 100644
--- a/linguistic/source/gciterator.hxx
+++ b/linguistic/source/gciterator.hxx
@@ -43,6 +43,7 @@
 #include cppuhelper/weakref.hxx
 #include osl/mutex.hxx
 #include osl/conditn.hxx
+#include osl/thread.h
 #include rtl/instance.hxx
 
 #include map
@@ -122,7 +123,7 @@ class GrammarCheckingIterator:
 sal_Int32   m_nDocIdCounter;
 sal_Int32   m_nLastEndOfSentencePos;
 osl::Condition  m_aWakeUpThread;
-osl::Condition  m_aRequestEndThread;
+oslThread   m_thread;
 
 //! beware of initilization order !
 struct MyMutex : public rtl::Static osl::Mutex, MyMutex  {};
@@ -132,6 +133,8 @@ class GrammarCheckingIterator:
 ::com::sun::star::uno::Reference ::com::sun::star::i18n::XBreakIterator  
m_xBreakIterator;
 mutable ::com::sun::star::uno::Reference