diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index d840754ac2..41d4811664 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -420,7 +420,10 @@ void GLGizmosManager::refresh_on_off_state() void GLGizmosManager::reset_all_states() { - if (! m_enabled || m_serializing) + // The restore/new-project event can run before deferred OpenGL resource + // loading has populated the gizmo list. There is nothing to reset until + // initialization completes. + if (! m_enabled || m_serializing || m_gizmos.empty()) return; const EType current = get_current_type(); @@ -435,6 +438,9 @@ void GLGizmosManager::reset_all_states() bool GLGizmosManager::open_gizmo(EType type) { + if (m_gizmos.empty()) + return false; + int idx = static_cast(type); // re-open same type cause closing @@ -522,7 +528,7 @@ bool GLGizmosManager::is_running() const bool GLGizmosManager::open_gizmo_by_shortcut(Shortcut shortcut) { - if (!m_enabled) + if (!m_enabled || m_gizmos.empty()) return false; // The text tool opens without a selection because it creates its own object. @@ -1427,10 +1433,12 @@ void GLGizmosManager::update_hover_state(const EType &type) bool GLGizmosManager::activate_gizmo(EType type) { - assert(!m_gizmos.empty()); - // already activated - if (m_current == type) return true; + if (m_current == type) + return true; + + if (m_gizmos.empty()) + return false; if (m_current != Undefined) { // clean up previous gizmo