cui/source/dialogs/widgettestdlg.cxx |   20 ++++++++++++++++----
 cui/uiconfig/ui/widgettestdialog.ui  |   21 +++++++++++++++++++--
 2 files changed, 35 insertions(+), 6 deletions(-)

New commits:
commit 2e0381693bce6a2ed16e72984edcb587174939fb
Author:     Szymon Kłos <[email protected]>
AuthorDate: Fri Jul 4 08:11:19 2025 +0000
Commit:     Szymon Kłos <[email protected]>
CommitDate: Fri Nov 14 10:33:23 2025 +0100

    Fix out-of-bound crash in test dialog 2
    
    It is visible in LOK case (only some backends).
    TreeView requires width declaration for columns to not
    fail on "you have only 2 columns" in GetTabs() call
    we introduced recently.
    
    Change-Id: Iae07f0813e962e413054794afc0228933af00dec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187373
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194001
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <[email protected]>

diff --git a/cui/source/dialogs/widgettestdlg.cxx 
b/cui/source/dialogs/widgettestdlg.cxx
index 0d9eca2bd73a..690e474ded09 100644
--- a/cui/source/dialogs/widgettestdlg.cxx
+++ b/cui/source/dialogs/widgettestdlg.cxx
@@ -38,6 +38,17 @@ void WidgetTestDialog::FillTreeView()
     OUString aImage1(RID_SVXBMP_CELL_LR);
     OUString aImage2(RID_SVXBMP_SHADOW_BOT_LEFT);
 
+    // some backends might crash without proper widths set
+    std::vector<int> aWidths;
+    aWidths.push_back(m_xTreeView2->get_checkbox_column_width());
+    for (int i = 0; i < 3 - 1; ++i)
+    {
+        int nWidth = m_xTreeView2->get_column_width(i);
+        assert(nWidth > 0 && "suspicious to get a value like this");
+        aWidths.push_back(nWidth);
+    }
+    m_xTreeView2->set_column_fixed_widths(aWidths);
+
     for (size_t nCount = 0; nCount < 4; nCount++)
     {
         OUString sText = OUString::Concat("Test ") + 
OUString::Concat(OUString::number(nCount));
@@ -45,13 +56,13 @@ void WidgetTestDialog::FillTreeView()
         m_xTreeView->insert(nullptr, -1, &sText, &sText, nullptr, nullptr, 
false, xEntry.get());
         m_xTreeView->set_image(*xEntry, (nCount % 2 == 0) ? aImage1 : aImage2);
 
+        int nRow = m_xTreeView2->n_children();
         m_xTreeView2->append();
-        m_xTreeView2->set_image(nCount, (nCount % 2 == 0) ? aImage1 : aImage2);
-        m_xTreeView2->set_text(nCount, u"First Column"_ustr, 0);
-        // FIXME: crash out-of-bound
-        //m_xTreeView2->set_text(
-        //    nCount, OUString::Concat("Row ") + 
OUString::Concat(OUString::number(nCount)), 1);
-        m_xTreeView2->set_id(nCount, OUString::number(nCount));
+        m_xTreeView2->set_image(nRow, (nCount % 2 == 0) ? aImage1 : aImage2);
+        m_xTreeView2->set_text(nRow, u"First Column"_ustr, 0);
+        m_xTreeView2->set_text(
+            nRow, OUString::Concat("Row ") + 
OUString::Concat(OUString::number(nCount)), 1);
+        m_xTreeView2->set_id(nRow, OUString::number(nCount));
     }
 }
 
diff --git a/cui/uiconfig/ui/widgettestdialog.ui 
b/cui/uiconfig/ui/widgettestdialog.ui
index b2f33fce84bc..d13ae9c5a473 100644
--- a/cui/uiconfig/ui/widgettestdialog.ui
+++ b/cui/uiconfig/ui/widgettestdialog.ui
@@ -45,6 +45,8 @@
   </object>
   <object class="GtkTreeStore" id="liststore3">
     <columns>
+      <!-- column-name icon -->
+      <column type="GdkPixbuf"/>
       <!-- column-name text -->
       <column type="gchararray"/>
       <!-- column-name text1 -->
@@ -642,6 +644,21 @@
                         <child internal-child="selection">
                           <object class="GtkTreeSelection"/>
                         </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" 
id="treeviewcolumn0">
+                            <property name="resizable">True</property>
+                            <property name="spacing">6</property>
+                            <property name="sort-indicator">True</property>
+                            <property name="clickable">True</property>
+                            <property name="title" 
translatable="no">.</property>
+                            <child>
+                              <object class="GtkCellRendererPixbuf" 
id="cellrenderer0"/>
+                              <attributes>
+                                <attribute name="pixbuf">0</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
                         <child>
                           <object class="GtkTreeViewColumn" 
id="treeviewcolumn1">
                             <property name="resizable">True</property>
@@ -652,7 +669,7 @@
                             <child>
                               <object class="GtkCellRendererText" 
id="cellrenderer1"/>
                               <attributes>
-                                <attribute name="text">0</attribute>
+                                <attribute name="text">1</attribute>
                               </attributes>
                             </child>
                           </object>
@@ -667,7 +684,7 @@
                             <child>
                               <object class="GtkCellRendererText" 
id="cellrenderer2"/>
                               <attributes>
-                                <attribute name="text">1</attribute>
+                                <attribute name="text">2</attribute>
                               </attributes>
                             </child>
                           </object>
commit 443c1ca018571cb352fd51c79f3702200356af41
Author:     Szymon Kłos <[email protected]>
AuthorDate: Thu Jul 3 10:44:37 2025 +0000
Commit:     Szymon Kłos <[email protected]>
CommitDate: Fri Nov 14 10:33:15 2025 +0100

    Fix out-of-bound crash in test dialog
    
    It is visible in LOK case
    I think issue is with the model in widgettestdialog.ui
    but merge it to keep CI green first.
    
    Change-Id: Ife12e7b9e067aae65ca38b66f353aad49e869eec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187308
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194000
    Reviewed-by: Szymon Kłos <[email protected]>
    Tested-by: Jenkins

diff --git a/cui/source/dialogs/widgettestdlg.cxx 
b/cui/source/dialogs/widgettestdlg.cxx
index 0de81751d35d..0d9eca2bd73a 100644
--- a/cui/source/dialogs/widgettestdlg.cxx
+++ b/cui/source/dialogs/widgettestdlg.cxx
@@ -48,8 +48,9 @@ void WidgetTestDialog::FillTreeView()
         m_xTreeView2->append();
         m_xTreeView2->set_image(nCount, (nCount % 2 == 0) ? aImage1 : aImage2);
         m_xTreeView2->set_text(nCount, u"First Column"_ustr, 0);
-        m_xTreeView2->set_text(
-            nCount, OUString::Concat("Row ") + 
OUString::Concat(OUString::number(nCount)), 1);
+        // FIXME: crash out-of-bound
+        //m_xTreeView2->set_text(
+        //    nCount, OUString::Concat("Row ") + 
OUString::Concat(OUString::number(nCount)), 1);
         m_xTreeView2->set_id(nCount, OUString::number(nCount));
     }
 }

Reply via email to