How to prevent double Glib::signal_timeout execution? (original) (raw)
September 12, 2024, 4:08am 1
I’m using following construction for progress_fraction
animation:
// Animate progress function
Glib::signal_timeout().connect(
[this]() -> bool
{
double current_progress_fraction = get_progress_fraction();
// Animation in progress
if (current_progress_fraction < progress_fraction)
{
set_progress_fraction(
current_progress_fraction + PROGRESS_PULSE_STEP
);
return true; // continue
}
// 100% of value, reset
set_progress_fraction(
progress_fraction = 0
);
return false; // stop
},
PROGRESS_ANIMATION_TIME
);
But when activate new action before current Glib::signal_timeout
completed, progress animation going wrong.
How can I stop Glib::signal_timeout
before activating new one?
agpotter (Andrew Potter) September 14, 2024, 9:59pm 2
Glib::signal_timeout()
returns a sigc::connection
. You should store this object. When you activate a new action, you can call sigc::connection::disconnect()
on the stored connection before starting the new action’s timeout.
system (system) Closed October 14, 2024, 10:00pm 3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.