Fixed crash on Windows when dragging and dropping a non gcode file into gcode viewer exe file

This commit is contained in:
enricoturri1966 2020-10-22 13:54:31 +02:00
parent 8d59abfdf8
commit 4222d80afe
2 changed files with 4 additions and 2 deletions

View file

@ -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;

View file

@ -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;