Преглед изворни кода

Prevent lcd_update stack overflow on SD Card change

Scott Lahteine пре 7 година
родитељ
комит
fbdc5ad962
1 измењених фајлова са 5 додато и 3 уклоњено
  1. 5
    3
      Marlin/src/lcd/ultralcd.cpp

+ 5
- 3
Marlin/src/lcd/ultralcd.cpp Прегледај датотеку

@@ -5035,17 +5035,19 @@ void lcd_update() {
5035 5035
     const bool sd_status = IS_SD_INSERTED;
5036 5036
     if (sd_status != lcd_sd_status && lcd_detected()) {
5037 5037
 
5038
+      bool old_sd_status = lcd_sd_status; // prevent re-entry to this block!
5039
+      lcd_sd_status = sd_status;
5040
+
5038 5041
       if (sd_status) {
5039 5042
         safe_delay(1000); // some boards need a delay or the LCD won't show the new status
5040 5043
         card.initsd();
5041
-        if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_INSERTED);
5044
+        if (old_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_INSERTED);
5042 5045
       }
5043 5046
       else {
5044 5047
         card.release();
5045
-        if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_REMOVED);
5048
+        if (old_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_REMOVED);
5046 5049
       }
5047 5050
 
5048
-      lcd_sd_status = sd_status;
5049 5051
       lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
5050 5052
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
5051 5053
         #if ENABLED(LCD_PROGRESS_BAR)

Loading…
Откажи
Сачувај