[Libreoffice-commits] core.git: 2 commits - cui/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Dec 19 06:05:55 UTC 2018
cui/source/dialogs/hangulhanjadlg.cxx | 68 +++++++++-------------------------
cui/source/options/optupdt.cxx | 1
2 files changed, 19 insertions(+), 50 deletions(-)
New commits:
commit c7fa3b1da45f1af95962f504f36695b656f38f4b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Dec 18 17:11:16 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Dec 19 07:05:42 2018 +0100
don't delete out param from GetOutputString
we don't own this memory, belongs to svl module
Change-Id: Ief12408e4254ab3fc2069a8490ecf062a728b3d3
Reviewed-on: https://gerrit.libreoffice.org/65349
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx
index a42f9050220a..281250a8bf6b 100644
--- a/cui/source/options/optupdt.cxx
+++ b/cui/source/options/optupdt.cxx
@@ -152,7 +152,6 @@ void SvxOnlineUpdateTabPage::UpdateLastCheckedText()
nFormat = pNumberFormatter->GetStandardFormat( SvNumFormatType::TIME, eUILang );
pNumberFormatter->GetOutputString( aTime.GetTimeInDays(), nFormat, aTimeStr, &pColor );
- delete pColor;
delete pNumberFormatter;
aText = m_aLastCheckedTemplate;
commit 06942d373560cd84246df03a404cebfba4f7d28f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Dec 18 17:03:46 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Dec 19 07:05:27 2018 +0100
simplify HangulHanjaEditDictDialog::m_vElements
no need to store a ref-counted thing like OUString using the heap
Change-Id: I372417f1a60d120e867f4f4b3b9335b73693accb
Reviewed-on: https://gerrit.libreoffice.org/65348
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx
index f22866b0bea3..18338fa0f79c 100644
--- a/cui/source/dialogs/hangulhanjadlg.cxx
+++ b/cui/source/dialogs/hangulhanjadlg.cxx
@@ -1222,7 +1222,7 @@ namespace svx
{
private:
protected:
- std::vector<OUString*> m_vElements;
+ std::vector<OUString> m_vElements;
sal_uInt16 m_nNumOfEntries;
// index of the internal iterator, used for First() and Next() methods
sal_uInt16 m_nAct;
@@ -1233,8 +1233,8 @@ namespace svx
~SuggestionList();
void Set( const OUString& _rElement, sal_uInt16 _nNumOfElement );
- bool Reset( sal_uInt16 _nNumOfElement );
- const OUString* Get( sal_uInt16 _nNumOfElement ) const;
+ void Reset( sal_uInt16 _nNumOfElement );
+ const OUString & Get( sal_uInt16 _nNumOfElement ) const;
void Clear();
const OUString* First();
@@ -1244,7 +1244,7 @@ namespace svx
};
SuggestionList::SuggestionList() :
- m_vElements(MAXNUM_SUGGESTIONS, static_cast<OUString*>(nullptr))
+ m_vElements(MAXNUM_SUGGESTIONS)
{
m_nAct = m_nNumOfEntries = 0;
}
@@ -1256,40 +1256,19 @@ namespace svx
void SuggestionList::Set( const OUString& _rElement, sal_uInt16 _nNumOfElement )
{
- bool bRet = _nNumOfElement < m_vElements.size();
- if( bRet )
- {
- if( m_vElements[_nNumOfElement] != nullptr )
- *(m_vElements[_nNumOfElement]) = _rElement;
- else
- {
- m_vElements[_nNumOfElement] = new OUString( _rElement );
- ++m_nNumOfEntries;
- }
- }
+ m_vElements[_nNumOfElement] = _rElement;
+ ++m_nNumOfEntries;
}
- bool SuggestionList::Reset( sal_uInt16 _nNumOfElement )
+ void SuggestionList::Reset( sal_uInt16 _nNumOfElement )
{
- bool bRet = _nNumOfElement < m_vElements.size();
- if( bRet )
- {
- if( m_vElements[_nNumOfElement] != nullptr )
- {
- delete m_vElements[_nNumOfElement];
- m_vElements[_nNumOfElement] = nullptr;
- --m_nNumOfEntries;
- }
- }
-
- return bRet;
+ m_vElements[_nNumOfElement].clear();
+ --m_nNumOfEntries;
}
- const OUString* SuggestionList::Get( sal_uInt16 _nNumOfElement ) const
+ const OUString& SuggestionList::Get( sal_uInt16 _nNumOfElement ) const
{
- if( _nNumOfElement < m_vElements.size())
- return m_vElements[_nNumOfElement];
- return nullptr;
+ return m_vElements[_nNumOfElement];
}
void SuggestionList::Clear()
@@ -1297,29 +1276,22 @@ namespace svx
if( m_nNumOfEntries )
{
for (auto & vElement : m_vElements)
- {
- if( vElement != nullptr )
- {
- delete vElement;
- vElement = nullptr;
- }
- }
-
+ vElement.clear();
m_nNumOfEntries = m_nAct = 0;
}
}
const OUString* SuggestionList::Next_()
{
- const OUString* pRet = nullptr;
- while( m_nAct < m_vElements.size() && !pRet )
+ while( m_nAct < m_vElements.size() )
{
- pRet = m_vElements[ m_nAct ];
- if( !pRet )
- ++m_nAct;
+ auto & s = m_vElements[ m_nAct ];
+ if (!s.isEmpty())
+ return &s;
+ ++m_nAct;
}
- return pRet;
+ return nullptr;
}
const OUString* SuggestionList::First()
@@ -1688,9 +1660,7 @@ namespace svx
OUString aStr;
if( m_pSuggestions )
{
- const OUString* p = m_pSuggestions->Get( _nEntryNum );
- if( p )
- aStr = *p;
+ aStr = m_pSuggestions->Get( _nEntryNum );
}
_rEdit.SetText( aStr );
More information about the Libreoffice-commits
mailing list