xmlsecurity/source/dialogs/certificatechooser.cxx |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit 7068c92257a05b3937c8a137d2d9048a881d0dc0
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Dec 14 18:27:24 2023 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Dec 15 11:51:09 2023 +0100

    xmlsecurity: fix assert in CertificateChooser::ImplInitialize()
    
    gtk3/gtkinst.cxx:15371: virtual void (anonymous 
namespace)::GtkInstanceTreeView::select(int): Assertion 
`gtk_tree_view_get_model(m_pTreeView) && "don't select when frozen, select 
after thaw. Note selection doesn't survive a freeze"' failed.
    
    (regression from commit ad6f23d2a3842c40f7c812003af4031150ea8183)
    
    Change-Id: I8c0639e755188731bdd211f9d71a830d7afeeaa6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160786
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 53c64cce13863861aabc4b1056cc3a1a66bf64a7)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160802

diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx 
b/xmlsecurity/source/dialogs/certificatechooser.cxx
index a7ff02f1a583..9dba3e9e9066 100644
--- a/xmlsecurity/source/dialogs/certificatechooser.cxx
+++ b/xmlsecurity/source/dialogs/certificatechooser.cxx
@@ -169,6 +169,7 @@ void CertificateChooser::ImplInitialize(bool mbSearch)
 
     }
 
+    ::std::optional<int> oSelectRow;
     uno::Sequence<uno::Reference< security::XCertificate>> xCerts;
     for (auto& secContext : mxSecurityContexts)
     {
@@ -242,7 +243,9 @@ void CertificateChooser::ImplInitialize(bool mbSearch)
                 if ( sIssuer == msPreferredKey )
                 {
                     if ( meAction == UserAction::Sign || meAction == 
UserAction::SelectSign )
-                        m_xCertLB->select(nRow);
+                    {
+                        oSelectRow.emplace(nRow);
+                    }
                     else if ( meAction == UserAction::Encrypt &&
                               aUserOpts.GetEncryptToSelf() )
                         mxEncryptToSelf = xCert;
@@ -255,6 +258,11 @@ void CertificateChooser::ImplInitialize(bool mbSearch)
     m_xCertLB->thaw();
     m_xCertLB->unselect_all();
 
+    if (oSelectRow)
+    {
+        m_xCertLB->select(*oSelectRow);
+    }
+
     CertificateHighlightHdl(*m_xCertLB);
     mbInitialized = true;
 }

Reply via email to