From a264030526b5d8c029084a410b465c9bce783f64 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 29 Jun 2018 16:38:24 -0500 Subject: [PATCH] Fix "G29" G29_MAX_RETRIES handling --- Marlin/src/gcode/gcode.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 7e8d33a38f..7ece602705 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -138,9 +138,9 @@ void GcodeSuite::dwell(millis_t time) { void GcodeSuite::G29_with_retry() { set_bed_leveling_enabled(false); - for (uint8_t i = G29_MAX_RETRIES; i--;) { + for (uint8_t retries_left = G29_MAX_RETRIES;;) { G29(); - if (planner.leveling_active) break; + if (planner.leveling_active || !retries_left--) break; #ifdef G29_ACTION_ON_RECOVER SERIAL_ECHOLNPGM("//action:" G29_ACTION_ON_RECOVER); #endif