From 11d22e164ec5e62e067a38ce11929b157381d1b7 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 3 Oct 2014 15:17:43 +0200 Subject: cid#1194925 Resource leak reorganise the code to keep coverity happy Change-Id: I18fc2dfd17f97edf1d17c57caaed4cc9d2fedd13 --- svtools/inc/roadmap.hxx | 2 +- svtools/source/control/roadmap.cxx | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/svtools/inc/roadmap.hxx b/svtools/inc/roadmap.hxx index c1f8e4689dbe..362f797e5a09 100644 --- a/svtools/inc/roadmap.hxx +++ b/svtools/inc/roadmap.hxx @@ -110,7 +110,7 @@ namespace svt ItemId GetNextAvailableItemId( ItemIndex _NewIndex ); ItemId GetPreviousAvailableItemId( ItemIndex _NewIndex ); RoadmapItem* GetByPointer(vcl::Window* pWindow); - RoadmapItem* InsertHyperLabel( ItemIndex _Index, const OUString& _aStr, ItemId _RMID, bool _bEnabled = true ); + RoadmapItem* InsertHyperLabel( ItemIndex _Index, const OUString& _aStr, ItemId _RMID, bool _bEnabled, bool _bIncomplete ); void UpdatefollowingHyperLabels( ItemIndex _Index ); }; diff --git a/svtools/source/control/roadmap.cxx b/svtools/source/control/roadmap.cxx index 58f3d06ba0e8..ce709005dbd2 100644 --- a/svtools/source/control/roadmap.cxx +++ b/svtools/source/control/roadmap.cxx @@ -30,7 +30,6 @@ #define ROADMAP_INDENT_X 4 #define ROADMAP_INDENT_Y 27 #define ROADMAP_ITEM_DISTANCE_Y 6 -#define RMINCOMPLETE -1 namespace svt @@ -235,7 +234,7 @@ namespace svt - RoadmapItem* ORoadmap::InsertHyperLabel( ItemIndex _Index, const OUString& _sLabel, ItemId _RMID, bool _bEnabled) + RoadmapItem* ORoadmap::InsertHyperLabel( ItemIndex _Index, const OUString& _sLabel, ItemId _RMID, bool _bEnabled, bool _bIncomplete) { if ( m_pImpl->getItemCount() == 0 ) m_pImpl->initItemSize(); @@ -244,14 +243,14 @@ namespace svt RoadmapItem* pOldItem = GetPreviousHyperLabel( _Index ); pItem = new RoadmapItem( *this, m_pImpl->getItemSize() ); - if ( _RMID != RMINCOMPLETE ) + if ( _bIncomplete ) { - pItem->SetInteractive( m_pImpl->isInteractive() ); - m_pImpl->insertHyperLabel( _Index, pItem ); + pItem->SetInteractive( false ); } else { - pItem->SetInteractive( false ); + pItem->SetInteractive( m_pImpl->isInteractive() ); + m_pImpl->insertHyperLabel( _Index, pItem ); } pItem->SetPosition( pOldItem ); pItem->Update( _Index, _sLabel ); @@ -306,7 +305,7 @@ namespace svt } } else if ( bWasComplete ) - m_pImpl->InCompleteHyperLabel = InsertHyperLabel( m_pImpl->getItemCount(), OUString("..."), RMINCOMPLETE ); + m_pImpl->InCompleteHyperLabel = InsertHyperLabel( m_pImpl->getItemCount(), OUString("..."), -1, true/*bEnabled*/, true/*bIncomplete*/ ); } @@ -365,10 +364,7 @@ namespace svt void ORoadmap::InsertRoadmapItem( ItemIndex _Index, const OUString& _RoadmapItem, ItemId _nUniqueId, bool _bEnabled ) { - // make coverity happy, because then it knows the return value from InsertHyperLabel won't leak - assert( _nUniqueId != RMINCOMPLETE ); - - InsertHyperLabel( _Index, _RoadmapItem, _nUniqueId, _bEnabled ); + InsertHyperLabel( _Index, _RoadmapItem, _nUniqueId, _bEnabled, false/*bIncomplete*/ ); // TODO YPos is superfluous, if items are always appended UpdatefollowingHyperLabels( _Index + 1 ); } -- cgit