Use the advice in the S-Lang docs: perform a SLtt_get_screen_size(),
and then SLsmg_reinit_smg().  SLtt_get_screen_size() does more than
just update SLtt_Screen_Rows/Cols, it also resizes internal buffers.

I believe this is why the reset/init were crashing, because the
reset/init (now subsumed by the call to reinit) were assuming the data
structures were already resized.

The docs also suggest calling SLsmg_reinit_smg() instead of separate
SLsmg_reset_smg()  SLsmg_init_smg() calls, so also change that.
---
This is based on top of the reformatting fixes and Rene's queued
patches.  See branch kevin/slang-debugging on gitlab.

If you are willing, please help test to make sure the crash is really
gone.  The only way to trigger was to sit there jiggling resize on a
window for a random amount of time (sometimes seconds, but sometimes for
minutes!).  So I'm not absolutely positive it's fixed, but I haven't
been able to trigger it after trying this afternoon.

 resize.c | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/resize.c b/resize.c
index f6a3407f..cdc2225a 100644
--- a/resize.c
+++ b/resize.c
@@ -39,46 +39,46 @@
 /* this routine should be called after receiving SIGWINCH */
 void mutt_resize_screen(void)
 {
+#ifndef USE_SLANG_CURSES
   char *cp;
   int fd;
   struct winsize w;
-#ifdef HAVE_RESIZETERM
-  int SLtt_Screen_Rows, SLtt_Screen_Cols;
-#endif
+  int screen_rows, screen_cols;
 
-  SLtt_Screen_Rows = -1;
-  SLtt_Screen_Cols = -1;
+  screen_rows = -1;
+  screen_cols = -1;
   if ((fd = open("/dev/tty", O_RDONLY)) != -1)
   {
     if (ioctl(fd, TIOCGWINSZ, &w) != -1)
     {
-      SLtt_Screen_Rows = w.ws_row;
-      SLtt_Screen_Cols = w.ws_col;
+      screen_rows = w.ws_row;
+      screen_cols = w.ws_col;
     }
     close(fd);
   }
-  if (SLtt_Screen_Rows <= 0)
+  if (screen_rows <= 0)
   {
     if ((cp = getenv("LINES")) != NULL)
-      mutt_atoi(cp, &SLtt_Screen_Rows, 0);
-    if (SLtt_Screen_Rows <= 0)
-      SLtt_Screen_Rows = 24;
+      mutt_atoi(cp, &screen_rows, 0);
+    if (screen_rows <= 0)
+      screen_rows = 24;
   }
-  if (SLtt_Screen_Cols <= 0)
+  if (screen_cols <= 0)
   {
     if ((cp = getenv("COLUMNS")) != NULL)
-      mutt_atoi(cp, &SLtt_Screen_Cols, 0);
-    if (SLtt_Screen_Cols <= 0)
-      SLtt_Screen_Cols = 80;
+      mutt_atoi(cp, &screen_cols, 0);
+    if (screen_cols <= 0)
+      screen_cols = 80;
   }
-#ifdef USE_SLANG_CURSES
+
+  resizeterm(screen_rows, screen_cols);
+#else
+  SLtt_get_screen_size();
+  SLsmg_reinit_smg();
   delwin(stdscr);
-  SLsmg_reset_smg();
-  SLsmg_init_smg();
   stdscr = newwin(0, 0, 0, 0);
   keypad(stdscr, TRUE);
-#else
-  resizeterm(SLtt_Screen_Rows, SLtt_Screen_Cols);
 #endif
+
   mutt_reflow_windows();
 }
-- 
2.53.0

Reply via email to