Re: Disconnecting signals and connection control



mån 2011-10-17 klockan 08:41 -0700 skrev eypros:
> Anyway it works up to a point. The problem is that instead of getting the
> value of SpinButton as an argument for signal_timeout connection it just
> increases the speed. This makes me think that maybe I install new connection
> with each SpinButton button press so they all work simultaneously and there
> explained the speed increase?

You guessed it! That's what happens.

> So if this is the catch how do I disconnect signal_timeout?

Save the connection that is returned from
Glib::signal_timeout().connect() and use disconnect().

In Spin::Spin:
// m_connection is a sigc::connection.
m_connection = Glib::signal_timeout().connect(sigc::mem_fun(*this,
&Spin::on_timeout), m_Spin.get_value_as_int());
....
void Spin::on_spinbutton_digits_changed()
{
  m_connection.disconnect();
  m_connection = Glib::signal_timeout().connect(sigc::mem_fun(*this,
&Spin::on_timeout), m_Spin.get_value_as_int());
}




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