another memory leak based on release().release()
Thanks Michael Meeks for noticing. Change-Id: I8c27215d3cf4624a19f4fd905758e588b342c6c9
This commit is contained in:
parent
6af3bc396e
commit
1e9baadcb7
@ -499,24 +499,6 @@ void ScChartListenerCollection::ChangeListening( const OUString& rName,
|
||||
pCL->SetDirty( true );
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class InsertChartListener : public std::unary_function<ScChartListener*, void>
|
||||
{
|
||||
ScChartListenerCollection::ListenersType& mrListeners;
|
||||
public:
|
||||
InsertChartListener(ScChartListenerCollection::ListenersType& rListeners) :
|
||||
mrListeners(rListeners) {}
|
||||
|
||||
void operator() (ScChartListener* p)
|
||||
{
|
||||
OUString aName = p->GetName();
|
||||
mrListeners.insert(aName, p);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void ScChartListenerCollection::FreeUnused()
|
||||
{
|
||||
ListenersType aUsed, aUnused;
|
||||
@ -550,29 +532,21 @@ void ScChartListenerCollection::FreeUnused()
|
||||
void ScChartListenerCollection::FreeUno( const uno::Reference< chart::XChartDataChangeEventListener >& rListener,
|
||||
const uno::Reference< chart::XChartData >& rSource )
|
||||
{
|
||||
std::vector<ScChartListener*> aUsed, aUnused;
|
||||
ListenersType aUsed, aUnused;
|
||||
|
||||
// First, filter each listener into 'used' and 'unused' categories.
|
||||
{
|
||||
ListenersType::iterator it = maListeners.begin(), itEnd = maListeners.end();
|
||||
for (; it != itEnd; ++it)
|
||||
while(!maListeners.empty())
|
||||
{
|
||||
ScChartListener* p = it->second;
|
||||
ScChartListener* p = maListeners.begin()->second;
|
||||
if (p->IsUno() && p->GetUnoListener() == rListener && p->GetUnoSource() == rSource)
|
||||
aUnused.push_back(p);
|
||||
aUnused.transfer(maListeners.begin(), maListeners);
|
||||
else
|
||||
aUsed.push_back(p);
|
||||
aUsed.transfer(maListeners.begin(), maListeners);
|
||||
}
|
||||
}
|
||||
|
||||
// Release all pointers currently managed by the ptr_map container.
|
||||
maListeners.release().release();
|
||||
|
||||
// Re-insert the listeners we need to keep.
|
||||
std::for_each(aUsed.begin(), aUsed.end(), InsertChartListener(maListeners));
|
||||
|
||||
// Now, delete the ones no longer needed.
|
||||
std::for_each(aUnused.begin(), aUnused.end(), boost::checked_deleter<ScChartListener>());
|
||||
std::swap(aUsed, maListeners);
|
||||
}
|
||||
|
||||
void ScChartListenerCollection::StartTimer()
|
||||
|
Loading…
x
Reference in New Issue
Block a user