I am debugging some code. Execution has arrived to this method:
void EventNotifier::notify_observers(SpEventInfo pEvent, Observable* target)
{
std::list<Observer*>::iterator it;
for (it = m_observers.begin(); it != m_observers.end(); ++it)
{
Observable* observedTarget = (*it)->target();
bool fNotify = (observedTarget == target);
...
The last sentence of previous excerpt has been executed. Both variables, observedTarget and target, have the same value but boolean fNotify is false! (please see attached image)
I have no idea of were is the problem. Any help is greately appreciated. Thank you
Cecilio Salmeron
www.lenmus.org
[attachment deleted by admin]
I didn't mean to offend you. I don't mind that you posted the question. What I meant was that I was hoping that admins don't mind that I give you a pointer on your problem.
void EventNotifier::notify_observers(SpEventInfo pEvent, Observable* target)
{
std::list<Observer*>::iterator it;
for (it = m_observers.begin(); it != m_observers.end(); ++it)
{
Observable* observedTarget = (*it)->target();
bool fNotify = (observedTarget == target);
...
replace
bool fNotify = (observedTarget == target);
with
bool fNotify = (*observedTarget == *target);
If you get a compiler error then you need to define a function that's visible to your function above.
bool operator==(const Observable& left, const Observable& right)
{
return left.foo_member_data_stuff == right.foo_member_data_stuff;
}