mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-21 05:37:52 -06:00
Fix Crash when delete model during simplification
This commit is contained in:
parent
25feacfd95
commit
f6f70f6fd4
3 changed files with 32 additions and 11 deletions
|
@ -55,6 +55,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||
create_gui_cfg();
|
||||
const Selection &selection = m_parent.get_selection();
|
||||
int object_idx = selection.get_object_idx();
|
||||
if (!is_selected_object(&object_idx)) return;
|
||||
ModelObject *obj = wxGetApp().plater()->model().objects[object_idx];
|
||||
ModelVolume *act_volume = obj->volumes.front();
|
||||
|
||||
|
@ -329,9 +330,9 @@ void GLGizmoSimplify::on_set_state()
|
|||
{
|
||||
// Closing gizmo. e.g. selecting another one
|
||||
if (GLGizmoBase::m_state == GLGizmoBase::Off) {
|
||||
|
||||
// refuse outgoing during simlification
|
||||
if (m_state != State::settings) {
|
||||
// object is not selected when it is deleted(cancel and close gizmo)
|
||||
if (m_state != State::settings && is_selected_object()) {
|
||||
GLGizmoBase::m_state = GLGizmoBase::On;
|
||||
auto notification_manager = wxGetApp().plater()->get_notification_manager();
|
||||
notification_manager->push_notification(
|
||||
|
@ -383,4 +384,20 @@ void GLGizmoSimplify::request_rerender() {
|
|||
});
|
||||
}
|
||||
|
||||
bool GLGizmoSimplify::is_selected_object(int *object_idx)
|
||||
{
|
||||
int index = (object_idx != nullptr) ? *object_idx :
|
||||
m_parent.get_selection().get_object_idx();
|
||||
// no selected object --> can appear after delete model
|
||||
if (index < 0) {
|
||||
switch (m_state) {
|
||||
case State::settings: close(); break;
|
||||
case State::canceling: break;
|
||||
default: m_state = State::canceling;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Slic3r::GUI
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue