From 0c2aa40bbc37c7e8b236e6db7c2f07b90f619e16 Mon Sep 17 00:00:00 2001
From: Albrecht Schlosser <albrechts.fltk@online.de>
Date: Wed, 22 Jan 2025 21:11:06 +0100
Subject: [PATCH] Fix Fl_Table_Row inconsistencies, final part (#1187)

Adjust internal vector sizes before and after changing the rows() in
the base class to avoid inconsisten sizes.

Note that the crash reported by the OP of PR #1187 was caused by
more than one issue, not only the one fixed here. Thanks for the
original patch to the author, GitHub user 'basiliscos'.
---
 src/Fl_Table_Row.cxx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Fl_Table_Row.cxx b/src/Fl_Table_Row.cxx
index dca5c10b7..6c7e457f9 100644
--- a/src/Fl_Table_Row.cxx
+++ b/src/Fl_Table_Row.cxx
@@ -203,8 +203,8 @@ void Fl_Table_Row::select_all_rows(int flag) {
 
 // Set number of rows
 void Fl_Table_Row::rows(int val) {
-  Fl_Table::rows(val);
   while ( val > (int)_rowselect.size() ) { _rowselect.push_back(0); }   // enlarge
+  Fl_Table::rows(val);
   while ( val < (int)_rowselect.size() ) { _rowselect.pop_back(); }     // shrink
 }
 
-- 
GitLab