Skip to content

Commit 160575d

Browse files
authored
Merge pull request #477 from stklcode/fix/render-folder-regression
partially revert static outputString in RenderCurrentFolder
2 parents e169b0e + f10f396 commit 160575d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -874,21 +874,23 @@ void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) {
874874
SERIAL_ECHOLN(currentFileList.filename());
875875
#endif
876876

877-
const char* fileName = currentFileList.filename();
877+
const char* fileName = currentFileList.filename();
878878
unsigned int fileNameLen = strlen(fileName);
879879

880-
// Cut off too long filenames.
881-
// They don't fit on the screen anyway.
882-
#if ENABLED(KNUTWURST_DGUS2_TFT)
883-
bool fileNameWasCut = false;
884-
if (fileNameLen >= MAX_PRINTABLE_FILENAME_LEN) {
885-
fileNameWasCut = true;
886-
fileNameLen = MAX_PRINTABLE_FILENAME_LEN;
887-
}
888-
#endif
880+
// Cut off too long filenames.
881+
// They don't fit on the screen anyway.
882+
#if ENABLED(KNUTWURST_DGUS2_TFT)
883+
bool fileNameWasCut = false;
884+
if (fileNameLen >= MAX_PRINTABLE_FILENAME_LEN) {
885+
fileNameWasCut = true;
886+
fileNameLen = MAX_PRINTABLE_FILENAME_LEN;
887+
}
888+
static char outputString[MAX_PRINTABLE_FILENAME_LEN];
889+
#else
890+
char outputString[fileNameLen];
891+
#endif
889892

890893
// Bugfix for non-printable special characters which are now replaced by underscores.
891-
static char outputString[MAX_PRINTABLE_FILENAME_LEN] = {'\0'};
892894
for (unsigned int i = 0; i <= fileNameLen; i++) {
893895
if (isPrintable(fileName[i])) {
894896
outputString[i] = fileName[i];
@@ -929,7 +931,7 @@ void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) {
929931
outputString[MAX_PRINTABLE_FILENAME_LEN] = '\0';
930932
}
931933
#else
932-
outputString[fileNameLen] = '\0';
934+
outputString[fileNameLen] = '\0';
933935
#endif
934936

935937

0 commit comments

Comments
 (0)