Browse Source

[fix] ininity recursive call of HistoryRedraw on buffered console resize

Oleg Gerasimov 3 years ago
parent
commit
99e3a5e91d
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/gwin/gwin_console.c

+ 12 - 1
src/gwin/gwin_console.c

@@ -151,7 +151,7 @@
151 151
 
152 152
 		#undef gcw
153 153
 	}
154
-
154
+	static void scrollBuffer(GConsoleObject *gcw);
155 155
 	static void HistoryRedraw(GWindowObject *gh) {
156 156
 		#define gcw		((GConsoleObject *)gh)
157 157
 
@@ -159,6 +159,14 @@
159 159
 		if (!gcw->buffer)
160 160
 			return;
161 161
 
162
+		// Handle vertical size decrease:
163
+		// We have to scroll out first lines of log 
164
+		coord_t fy = gdispGetFontMetric(gh->font, fontHeight);
165
+		while (gcw->cy > gh->height) {
166
+			scrollBuffer (gcw);
167
+			gcw->cy -= fy;
168
+		}
169
+
162 170
 		// We are printing the buffer - don't store it again
163 171
 		gh->flags |= GCONSOLE_FLG_NOSTORE;
164 172
 
@@ -532,6 +540,9 @@ void gwinPutChar(GHandle gh, char c) {
532 540
 	if (gcw->cy + fy > gh->height) {
533 541
 		#if GWIN_CONSOLE_USE_HISTORY && GWIN_CONSOLE_BUFFER_SCROLLING
534 542
 			if (gcw->buffer) {
543
+				// If flag GCONSOLE_FLG_NOSTORE is set, then do not recursive call of HistoryRedraw - just drop buffer.
544
+				if (gh->flags & GCONSOLE_FLG_NOSTORE)
545
+					gcw->bufpos = 0;
535 546
 				// Scroll the buffer and then redraw using the buffer
536 547
 				scrollBuffer(gcw);
537 548
 				if (DrawStart(gh)) {