From 4222d80afe51148121e0531c2a554b56d0a5013c Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 22 Oct 2020 13:54:31 +0200 Subject: [PATCH] Fixed crash on Windows when dragging and dropping a non gcode file into gcode viewer exe file --- src/PrusaSlicer.cpp | 2 +- src/slic3r/GUI/Plater.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index be432d487..1bd981a5d 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -156,7 +156,7 @@ int CLI::run(int argc, char **argv) #if ENABLE_GCODE_VIEWER for (const std::string& file : m_input_files) { std::string ext = boost::filesystem::path(file).extension().string(); - if (boost::filesystem::path(file).extension().string() == ".gcode") { + if (ext == ".gcode" || ext == ".g") { if (boost::filesystem::exists(file)) { start_as_gcodeviewer = true; break; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index b3cd1ef00..b62ff4dcc 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -4702,7 +4702,9 @@ void Plater::load_gcode() void Plater::load_gcode(const wxString& filename) { - if (filename.empty() || m_last_loaded_gcode == filename) + if (filename.empty() || + (!filename.Lower().EndsWith(".gcode") && !filename.Lower().EndsWith(".g")) || + m_last_loaded_gcode == filename) return; m_last_loaded_gcode = filename;