Glib::signal_timeout().connect_seconds

View: New views
3 Messages — Rating Filter:   Alert me  

Glib::signal_timeout().connect_seconds

by mik-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello everybody!

I have a strange problem when using signal_timeout(). The code below triggers
every 30 seconds the member function onTimeout30s. Everything works fine
inside KDevelop. Kompiling it into a openSUSE rpm the memberfunction is
called once and never again. The only difference I can imagine is that
KDevelop compiles with debug statement which only should help gnu debugger to
find break points.

Any idea whats wrong?

Thanks in advance.


-- MIK



BTW: gtkmm is great and easy to use. Thanks for that peace of software.


8< 8< 8< code 8< 8< 8<

Konstruktor {

  mTimeoutConnection =
      Glib::signal_timeout().connect_seconds(sigc::bind(sigc::mem_fun(*this,
      &MainWindow::onTimeout30s),0), 30);
}


bool MainWindow::onTimeout30s(int timerNumber)
{
  clog << "MainWindow::onTimeout30s" << std::endl;

  clog << "mTimeoutConnection::empty " <<
      (mTimeoutConnection.empty()?"true":"false") << endl;
  clog << "mTimeoutConnection::connected " <<
      (mTimeoutConnection.connected()?"true":"false") << endl;
}

8 >8 >8 >8  code >8 >8 >8  
_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

RE: Glib::signal_timeout().connect_seconds

by sledge hammer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
I am surprised that g++ doesn't give you a warning while compiling that piece of code. In "MainWindow::onTimeout30s()" you have forgotten to return a value. Put "return true;" If you want MainWindow::onTimeout30s() to be called again or "return false" to disconnect the signal handler.

> From: mik@...
> To: gtkmm-list@...
> Subject: Glib::signal_timeout().connect_seconds
> Date: Sat, 17 Oct 2009 12:52:11 +0200
>
> Hello everybody!
>
> I have a strange problem when using signal_timeout(). The code below triggers
> every 30 seconds the member function onTimeout30s. Everything works fine
> inside KDevelop. Kompiling it into a openSUSE rpm the memberfunction is
> called once and never again. The only difference I can imagine is that
> KDevelop compiles with debug statement which only should help gnu debugger to
> find break points.
>
> Any idea whats wrong?
>
> Thanks in advance.
>
>
> -- MIK
>
>
>
> BTW: gtkmm is great and easy to use. Thanks for that peace of software.
>
>
> 8< 8< 8< code 8< 8< 8<
>
> Konstruktor {
>
> mTimeoutConnection =
> Glib::signal_timeout().connect_seconds(sigc::bind(sigc::mem_fun(*this,
> &MainWindow::onTimeout30s),0), 30);
> }
>
>
> bool MainWindow::onTimeout30s(int timerNumber)
> {
> clog << "MainWindow::onTimeout30s" << std::endl;
>
> clog << "mTimeoutConnection::empty " <<
> (mTimeoutConnection.empty()?"true":"false") << endl;
> clog << "mTimeoutConnection::connected " <<
> (mTimeoutConnection.connected()?"true":"false") << endl;
> }
>
> 8 >8 >8 >8 code >8 >8 >8
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list@...
> http://mail.gnome.org/mailman/listinfo/gtkmm-list


Windows Live: Κρατήστε τους φίλους σας ενήμερους για τις δραστηριότητές σας στο Internet.
_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

RE: Glib::signal_timeout().connect_seconds

by Mark Roberts-10 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mik wrote:

> > bool MainWindow::onTimeout30s(int timerNumber)
> > {
> > clog << "MainWindow::onTimeout30s" << std::endl;
> >
> > clog << "mTimeoutConnection::empty " <<
> > (mTimeoutConnection.empty()?"true":"false") << endl;
> > clog << "mTimeoutConnection::connected " <<
> > (mTimeoutConnection.connected()?"true":"false") << endl;
> > }

Sledge Hammer wrote:

> I am surprised that g++ doesn't give you a warning while compiling that
> piece of code. In "MainWindow::onTimeout30s()" you have forgotten to
> return a value. Put "return true;" If you want MainWindow::onTimeout30s()
> to be called again or "return false" to disconnect the signal handler.

In other words: you should use -Wall when compiling with g++. You can
catch a lot of silly typos early in the production cycle.

More generally spoken: write code that, if incorrect, will produce
compiler warnings or errors, instead of code that, if incorrect, will fail
while your customer is running the program.

Mark
_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list