Entry::signal_changed() and slot::block()



Allthough i have a workaround, which yet fits better to the things i want to do, i whould be courios to unterstand why the following piece of code produces this output:

1.)code: [minimized to what i think is important; proteced member variables start with _; ... for various unimportant statements]

shiftAttributeWindowConnected::shiftAttributeWindowConnected(unsigned context)
: ...
_slot_startChanged(sigc::mem_fun(*this, &shiftAttributeWindowConnected::cb_startChanged)), _slot_durChanged(sigc::mem_fun(*this, &shiftAttributeWindowConnected::cb_durChanged)), _slot_endChanged(sigc::mem_fun(*this, &shiftAttributeWindowConnected::cb_endChanged)),
 _recBlock(false)

{ establishConnections(); }

void shiftAttributeWindowConnected::establishConnections()
{
   using namespace sigc;
... _entryStart.signal_changed().connect(_slot_startChanged);
   _entryDur.signal_changed().connect(_slot_durChanged);
   _entryEnd.signal_changed().connect(_slot_endChanged);
... }

void shiftAttributeWindowConnected::cb_startChanged()
{ cout << "shiftAttributeWindowConnected::cb_startChanged()" << endl;
   timeUpdate(true);
}
void shiftAttributeWindowConnected::cb_durChanged()
{ cout << "shiftAttributeWindowConnected::cb_durChanged()" << endl;
   timeUpdate(false);
}
void shiftAttributeWindowConnected::cb_endChanged()
{ cout << "shiftAttributeWindowConnected::cb_endChanged()" << endl;
   timeUpdate(true);
}

void shiftAttributeWindowConnected::timeUpdate(bool adjustDur)
{
   if(!_recBlock) //this is the workaround i'm talking of
   {
       _recBlock = true;
       _slot_startChanged.block();
       _slot_durChanged.block();
       _slot_endChanged.block();
       cout << "all blocked" << endl;
try
       {
time_duration start(duration_from_string(_entryStart.get_text()));
           if(adjustDur)
           {
                   ... some calculations ...
                   _entryDur.set_text(to_simple_string(dur));
           }
           else
           {
               ... some calculations ...
               _entryEnd.set_text(to_simple_string(end));
           }
       }
       catch(...)
       {
           //do nothing
       }
       _slot_startChanged.unblock();
       _slot_durChanged.unblock();
       _slot_endChanged.unblock();
       cout << "unblocked again" << endl;
       _recBlock = false;
   }
}

2.) i get output like this (when i modify the contents of the entries):

all blocked
unblocked again

shiftAttributeWindowConnected::cb_endChanged()

all blocked
shiftAttributeWindowConnected::cb_durChanged()
shiftAttributeWindowConnected::cb_durChanged()
unblocked again

shiftAttributeWindowConnected::cb_endChanged()

all blocked
shiftAttributeWindowConnected::cb_durChanged()
shiftAttributeWindowConnected::cb_durChanged()
unblocked again

shiftAttributeWindowConnected::cb_durChanged()

all blocked
unblocked again

shiftAttributeWindowConnected::cb_durChanged()

all blocked
shiftAttributeWindowConnected::cb_endChanged()
shiftAttributeWindowConnected::cb_endChanged()
unblocked again

so my question is: why are callbacks triggered when my slots are blocked ?
thanks in advance,
                                antonio




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]