|
|
Home » Developing U++ » UppHub » Something wrong with Dispatcher?
Something wrong with Dispatcher? [message #36961] |
Tue, 31 July 2012 22:42 |
|
bushman
Messages: 134 Registered: February 2009
|
Experienced Member |
|
|
I created a class that includes a Dispatcher obj
class MyClass {
public:
MyClass() {}
...
Dispatcher<String> disp;
};
, which I included in my app.
Now I'm getting following fatal error when shutting down app:
Quote: | Assertion failed in c:\upp\bazaar\Dispatcher.h, line 51 dests.IsEmpty()
|
Line 51 gives me Dispatcher destructor:
virtual ~Dispatcher() { ASSERT(dests.IsEmpty()); }
I assume error is due to dests not cleared before Dispatcher obj destruction. So I included destructor to MyClass, to perform just that:
class MyClass {
public:
MyClass() {}
~MyClass() { disp.Clear(); }
...
Dispatcher<String> disp; // line 35
};
Next I got the following compiler error:
Quote: |
c:\upp\bazaar\dispatcher\Dispatcher.h(60) : error C2228: left of '.Unregister' must have class/struct/union
type is 'Dispatchable<T> '
with
[
T=Upp::String
]
did you intend to use '->' instead?
c:\upp\bazaar\dispatcher\Dispatcher.h(60) : while compiling class template member function 'void Dispatch
er<T>::Clear(void)'
with
[
T=Upp::String
]
c:\myapps\MyApp\MyClass.h(35) : see reference to class template instantiation 'Dispatcher<
T>' being compiled
with
[
T=Upp::String
]
|
Changing '.' to '->' didnīt work either. Finally, I decided to inherit a workaround from Dispatcher:
template <class T>
class MyDispatcher : public Dispatcher<T>
{
public:
MyDispatcher() {}
~MyDispatcher() {
const VectorMap<unsigned,Dispatchable<T>*>& dests=GetDests();
while(dests.GetCount()>0) dests[0]->UnregisterAll(); // * NOTICE '->' INSTEAD OF '.' IN Dispatcher.h CODE!!??
}
};
Now, replacing Quote: | Dispatcher<String> disp
| by Quote: | MyDispatcher<String> disp
| compiles perfectly and solves the issue completely.
Anyone else having the same??
Tks.
[Updated on: Tue, 31 July 2012 22:51] Report message to a moderator
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Thu Jan 23 19:27:04 CET 2025
Total time taken to generate the page: 0.04299 seconds
|
|
|