From 8509e4b5f5ca87b5408b878d524051f7324c6908 Mon Sep 17 00:00:00 2001
From: bubnikv <bubnikv@gmail.com>
Date: Sat, 9 Dec 2017 16:39:49 +0100
Subject: [PATCH] Fixes regression error introduced in Slic3r 1.38.2: Slic3r
 1.38.3 gcodes not building up bed temperature
 https://github.com/prusa3d/Slic3r/issues/614

---
 xs/src/libslic3r/GCode.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp
index 528d7132b..b297ddab0 100644
--- a/xs/src/libslic3r/GCode.cpp
+++ b/xs/src/libslic3r/GCode.cpp
@@ -888,12 +888,12 @@ void GCode::_print_first_layer_bed_temperature(FILE *file, Print &print, const s
     // Is the bed temperature set by the provided custom G-code?
     int  temp_by_gcode     = -1;
     bool temp_set_by_gcode = custom_gcode_sets_temperature(gcode, 140, 190, temp_by_gcode);
-    if (temp_by_gcode >= 0 && temp_by_gcode < 1000)
+    if (temp_set_by_gcode && temp_by_gcode >= 0 && temp_by_gcode < 1000)
         temp = temp_by_gcode;
     // Always call m_writer.set_bed_temperature() so it will set the internal "current" state of the bed temp as if
     // the custom start G-code emited these.
     std::string set_temp_gcode = m_writer.set_bed_temperature(temp, wait);
-    if (! temp_by_gcode)
+    if (! temp_set_by_gcode)
         write(file, set_temp_gcode);
 }