Fix bug #25539: crash if a checkbox in a listbox is initially selected
This commit is contained in:
parent
ebf16031cb
commit
0dbf686c4f
2 changed files with 11 additions and 2 deletions
|
@ -28,6 +28,7 @@
|
|||
#include "gui/widgets/pane.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/selectable_item.hpp"
|
||||
#include "gui/widgets/toggle_button.hpp"
|
||||
#include "gui/widgets/viewport.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
|
@ -276,7 +277,13 @@ void listbox::list_item_clicked(widget& caller)
|
|||
for(size_t i = 0; i < generator_->get_item_count(); ++i) {
|
||||
|
||||
if(generator_->item(i).has_widget(caller)) {
|
||||
generator_->toggle_item(i);
|
||||
toggle_button* checkbox = dynamic_cast<toggle_button*>(&caller);
|
||||
if(checkbox != nullptr) {
|
||||
generator_->select_item(i, checkbox->get_value_bool());
|
||||
} else {
|
||||
generator_->toggle_item(i);
|
||||
}
|
||||
|
||||
if(callback_item_changed_) {
|
||||
callback_item_changed_(i);
|
||||
}
|
||||
|
|
|
@ -119,7 +119,9 @@ void toggle_button::set_value(const unsigned selected)
|
|||
state_num_ = selected % num_states();
|
||||
set_is_dirty(true);
|
||||
|
||||
if(callback_state_change_) {
|
||||
// Check for get_window() is here to prevent the callback from
|
||||
// being called when the initial value is set.
|
||||
if(callback_state_change_ && get_window() != nullptr) {
|
||||
callback_state_change_(*this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue