Skip to content

Commit

Permalink
Fix crash in GUI caused by recursive event calls. slic3r#2613
Browse files Browse the repository at this point in the history
  • Loading branch information
alranel authored and born2b committed Jun 10, 2015
1 parent ba28413 commit e3129c4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Slic3r/GUI/Tab.pm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ sub new {
$self->{treectrl}->AddRoot("root");
$self->{pages} = [];
$self->{treectrl}->SetIndent(0);
$self->{disable_tree_sel_changed_event} = 0;
EVT_TREE_SEL_CHANGED($parent, $self->{treectrl}, sub {
return if $self->{disable_tree_sel_changed_event};
my $page = first { $_->{title} eq $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection) } @{$self->{pages}}
or return;
$_->Hide for @{$self->{pages}};
Expand Down Expand Up @@ -303,12 +305,15 @@ sub update_tree {
foreach my $page (@{$self->{pages}}) {
my $itemId = $self->{treectrl}->AppendItem($rootItem, $page->{title}, $page->{iconID});
if ($page->{title} eq $selected) {
$self->{disable_tree_sel_changed_event} = 1;
$self->{treectrl}->SelectItem($itemId);
$self->{disable_tree_sel_changed_event} = 0;
$have_selection = 1;
}
}

if (!$have_selection) {
# this is triggered on first load, so we don't disable the sel change event
$self->{treectrl}->SelectItem($self->{treectrl}->GetFirstChild($rootItem));
}
}
Expand Down

0 comments on commit e3129c4

Please sign in to comment.