Fix of a Linux / GTK specific crash on deleting of Layers from the side panel: wxWidgets / GTK internally delays the EnsureVisible() call to Idle processing. If the item is deleted after EnsureVisible() is planned and before the Idle processed, the Idle processing routine works with deleted data

This commit is contained in:
Vojtech Bubnik 2019-08-06 19:53:20 +02:00
parent 4dd9817176
commit d36c64873d

View file

@ -186,7 +186,18 @@ ObjectList::ObjectList(wxWindow* parent) :
Bind(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, [this](wxCommandEvent& e) { last_volume_is_deleted(e.GetInt()); });
Bind(wxEVT_SIZE, ([this](wxSizeEvent &e) { this->EnsureVisible(this->GetCurrentItem()); e.Skip(); }));
Bind(wxEVT_SIZE, ([this](wxSizeEvent &e) {
#ifdef __WXGTK__
// On GTK, the EnsureVisible call is postponed to Idle processing (see wxDataViewCtrl::m_ensureVisibleDefered).
// So the postponed EnsureVisible() call is planned for an item, which may not exist at the Idle processing time, if this wxEVT_SIZE
// event is succeeded by a delete of the currently active item. We are trying our luck by postponing the wxEVT_SIZE triggered EnsureVisible(),
// which seems to be working as of now.
this->CallAfter([this](){ this->EnsureVisible(this->GetCurrentItem()); });
#else
this->EnsureVisible(this->GetCurrentItem());
#endif
e.Skip();
}));
}
ObjectList::~ObjectList()
@ -3601,4 +3612,4 @@ ModelObject* ObjectList::object(const int obj_idx) const
}
} //namespace GUI
} //namespace Slic3r
} //namespace Slic3r