Browse Source

Prevent lcd_update stack overflow on SD Card change

Scott Lahteine 7 years ago
parent
commit
fbdc5ad962
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      Marlin/src/lcd/ultralcd.cpp

+ 5
- 3
Marlin/src/lcd/ultralcd.cpp View File

5035
     const bool sd_status = IS_SD_INSERTED;
5035
     const bool sd_status = IS_SD_INSERTED;
5036
     if (sd_status != lcd_sd_status && lcd_detected()) {
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
       if (sd_status) {
5041
       if (sd_status) {
5039
         safe_delay(1000); // some boards need a delay or the LCD won't show the new status
5042
         safe_delay(1000); // some boards need a delay or the LCD won't show the new status
5040
         card.initsd();
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
       else {
5046
       else {
5044
         card.release();
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
       lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
5051
       lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
5050
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
5052
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
5051
         #if ENABLED(LCD_PROGRESS_BAR)
5053
         #if ENABLED(LCD_PROGRESS_BAR)

Loading…
Cancel
Save