bazaar/Dispatcher Clear fix

git-svn-id: svn://ultimatepp.org/upp/trunk@5400 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
kohait 2012-10-01 20:06:29 +00:00
parent b5f95d214d
commit d4619d299b
3 changed files with 8 additions and 2 deletions

View file

@ -27,7 +27,7 @@ public:
virtual void Dispatch(const T& o) = 0;
void Unregister(const Any& _src);
void UnregisterAll() { while(src.GetCount()>0) Unregister(src[0]); }
void UnregisterAll() { while(src.GetCount()>0) Unregister(src[0]); } //will remove elements
void Unregister(Dispatcher<T>& from) { int i = src.Find(GetPtrHashValue(&from)); if(i<0) return; Unregister(src[i]); }
void Unregister(DispatcherGen& from) { int i = src.Find(GetPtrHashValue(&from)); if(i<0) return; Unregister(src[i]); }
@ -57,7 +57,7 @@ public:
void Unregister(Dispatchable<T>& d, unsigned key = 0);
Dispatchable<T>* GetDispatchable(unsigned key) const;
const VectorMap<unsigned, Dispatchable<T>*>& GetDests() const { return dests; }
void Clear() { while(dests.GetCount()>0) dests[0].Unregister(); }
void Clear() { while(dests.GetCount()>0) dests[0]->Unregister(*this); }
private:
VectorMap<unsigned, Dispatchable<T>*> dests;

View file

@ -26,6 +26,7 @@ class DispatcherTest : public WithDispatcherTestLayout<TopWindow>
public:
typedef DispatcherTest CLASSNAME;
DispatcherTest();
~DispatcherTest();
void sliderCB();

View file

@ -53,6 +53,11 @@ DispatcherTest::DispatcherTest()
sliderCB();
}
DispatcherTest::~DispatcherTest()
{
disp.Clear();
}
GUI_APP_MAIN
{
DispatcherTest().Run();