From 77c309f4cb43b4993d96879e7759588a14e02910 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 22 Feb 2019 14:52:32 +0100 Subject: [PATCH] imgui: Fix assert in new_frame() --- src/slic3r/GUI/ImGuiWrapper.cpp | 14 ++++++++++++++ src/slic3r/GUI/ImGuiWrapper.hpp | 1 + 2 files changed, 15 insertions(+) diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 0e437ef6d..61baf352b 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -101,6 +101,10 @@ void ImGuiWrapper::set_style_scaling(float scaling) bool ImGuiWrapper::update_mouse_data(wxMouseEvent& evt) { + if (! display_initialized()) { + return false; + } + ImGuiIO& io = ImGui::GetIO(); io.MousePos = ImVec2((float)evt.GetX(), (float)evt.GetY()); io.MouseDown[0] = evt.LeftDown(); @@ -116,6 +120,10 @@ bool ImGuiWrapper::update_mouse_data(wxMouseEvent& evt) bool ImGuiWrapper::update_key_data(wxKeyEvent &evt) { + if (! display_initialized()) { + return false; + } + ImGuiIO& io = ImGui::GetIO(); if (evt.GetEventType() == wxEVT_CHAR) { @@ -521,6 +529,12 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data) glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]); } +bool ImGuiWrapper::display_initialized() const +{ + const ImGuiIO& io = ImGui::GetIO(); + return io.DisplaySize.x >= 0.0f && io.DisplaySize.y >= 0.0f; +} + void ImGuiWrapper::destroy_device_objects() { destroy_fonts_texture(); diff --git a/src/slic3r/GUI/ImGuiWrapper.hpp b/src/slic3r/GUI/ImGuiWrapper.hpp index e8755718b..2cadc773c 100644 --- a/src/slic3r/GUI/ImGuiWrapper.hpp +++ b/src/slic3r/GUI/ImGuiWrapper.hpp @@ -75,6 +75,7 @@ private: void init_input(); void init_style(); void render_draw_data(ImDrawData *draw_data); + bool display_initialized() const; void destroy_device_objects(); void destroy_fonts_texture();