Skip to content

Commit

Permalink
Fix reset of int options on OptionWidget destructor
Browse files Browse the repository at this point in the history
Int durations were set to 0 after adjusting an int or animation option
and susequently clicking the back button or closing wcm. Fix this by
using the solution found in gtkmm bug #128 on gitlab. Thanks to ammen99
for pointing out the initial solution.
  • Loading branch information
soreau committed Jun 29, 2024
1 parent 6ab4136 commit 525d5b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/wcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,11 @@ OptionWidget::OptionWidget(Option *option) : Gtk::Box(Gtk::ORIENTATION_HORIZONTA
auto spin_button = std::make_unique<Gtk::SpinButton>(
Gtk::Adjustment::create(value, option->data.min, option->data.max,
1));
spin_button->signal_value_changed().connect(
spin_button->signal_changed().connect(sigc::track_obj(
[=, widget = spin_button.get()]
{
option->set_save(widget->get_value_as_int());
});
}, tracker));
reset_button.signal_clicked().connect(
[=, widget = spin_button.get()]
{
Expand Down Expand Up @@ -423,7 +423,7 @@ OptionWidget::OptionWidget(Option *option) : Gtk::Box(Gtk::ORIENTATION_HORIZONTA
option->set_save(std::to_string(
length_widget->get_value_as_int()) + "ms " + easing_widget->get_active_text().c_str());
};
spin_button->signal_changed().connect(update_option_value);
spin_button->signal_changed().connect(sigc::track_obj(update_option_value, tracker));
combo_box->signal_changed().connect(std::move(update_option_value));
reset_button.signal_clicked().connect([=, length_widget = spin_button.get(),
easing_widget = combo_box.get()]
Expand Down Expand Up @@ -470,10 +470,10 @@ OptionWidget::OptionWidget(Option *option) : Gtk::Box(Gtk::ORIENTATION_HORIZONTA
Gtk::Adjustment::create(value, option->data.min, option->data.max,
option->data.precision),
option->data.precision, 3);
spin_box->signal_changed().connect([=, widget = spin_box.get()]
spin_box->signal_changed().connect(sigc::track_obj([=, widget = spin_box.get()]
{
option->set_save(widget->get_value());
});
}, tracker));
reset_button.signal_clicked().connect(
[=, widget = spin_box.get()]
{
Expand Down
1 change: 1 addition & 0 deletions src/wcm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class OptionWidget : public Gtk::Box
Gtk::Label name_label;
std::vector<std::unique_ptr<Gtk::Widget>> widgets;
Gtk::Button reset_button;
sigc::trackable tracker;

inline void pack_end(std::unique_ptr<Gtk::Widget> && widget, bool expand = false,
bool fill = false)
Expand Down

0 comments on commit 525d5b0

Please sign in to comment.