Re: Re: Timeout problem
- From: Jorge Villalobos Beato <tiusender gmail com>
- To: gtkmm-list gnome org
- Subject: Re: Re: Timeout problem
- Date: Wed, 31 Aug 2005 10:50:55 +0200
Hola :) Bob, the problem was Glib::signal_timeout?? arrgg, I was
obfuscated with sigc::bind & sig::mem_fun, trying to find the error... I
suppose that I must look closer to signal_timeout documentation. As you
can see in my previous post, I've solved this situation with threads,
because my program involves a GUI. This way the GUI doesn't freeze and I
can sleep threads, so there's a good emulation of what
Glib::signal_timeout does (I call over and over a function from itself
which is first called at thread creation). Thanks a lot for your help,
I'll use your solution in a future code ;)
Bob Caryl wrote:
> Hola Jorge,
>
> Here's how you want to do this:
>
> bool Protocol::control_servidor(int timer_number)
> {
> // do something here
> return true;
> }
>
> void Protocol::init_function()
> {
> sigc::slot<bool> my_slot = sigc::bind(sigc::mem_fun(*this,
> &Protocol::control_servidor),1);
> sigc::connection conn = Glib::signal_timeout().connect(my_slot, 1500);
> }
>
> The Glib::signal_timeout function is looking for a callback slot that
> has as its formal paramter an integer. Your
> Protocol::control_servidor did not provide that and so the compiler
> complained.
> I apologize for not looking closer at this before.
>
> Bob
>
> Jorge Villalobos Beato wrote:
>
>> Hi people. I'm trying to do a timer, so every 1500 miliseconds (1,5
>> seconds) I want the function 'control_servidor' to be called. This
>> function is declared as public in the class 'Protocol' ( bool
>> control_servidor(void); ), but I want to call the one within the current
>> object (a Protocol one), I mean, there's a function inside Protocol
>> which start the timer to call another function of the same object.
>>
>> Reading the Gtkmm tutorial I found a chapter talking on that issue
>> (http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch17.html) and this is
>> what it says:
>>
>> // Creation of a new object prevents long lines and shows us a little
>> // how slots work. We have 0 parameters and bool as a return value
>> // after calling SigC::bind.
>> SigC::Slot0<bool> my_slot = SigC::bind(SigC::slot(*this,
>> &TimerExample::on_timeout), m_timer_number);
>>
>> // This is where we connect the slot to the Glib::signal_timeout()
>> SigC::Connection conn = Glib::signal_timeout().connect(my_slot,
>> timeout_value);
>>
>>
>> This what I'm doing at this moment, with 'timeout_value' equals to 1500
>> and no 'm_timer_numer', because my function waits for no arguments.
>> Doing the replacing, this is what I get:
>>
>> bool Protocol::control_servidor(){
>> //...
>> return true;
>> }
>>
>> void Protocol::init_function(){
>>
>> //...
>>
>> SigC::Slot0<bool> my_slot = SigC::bind(SigC::slot(*this,
>> &Protocol::control_servidor)); //line 193
>> Glib::signal_timeout().connect(my_slot, 1500);
>>
>> //...
>> }
>>
>> When compiled, got this error:
>>
>> protocol.cc:193: error: no matching function for call to
>> `slot(Protocol&, bool (Protocol::*)())'
>>
>> Does anyone know what I'm doing wrong??
>>
>> Thanks a lot
>>
>> ----------------
>> Jorge Villalobos Beato
>> <tiusender gmail com>
>> <tiusender.blogspot.com>
>> _______________________________________________
>> gtkmm-list mailing list
>> gtkmm-list gnome org
>> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>>
>>
>>
>
>
--
Jorge Villalobos Beato
<tiusender gmail com>
<tiusender.blogspot.com>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]