dbaccess/source/ui/tabledesign/TEditControl.cxx |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 5b49cf64482ca8246dbcf5b5f12a11d7f9ed081b
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Fri Sep 15 14:48:52 2023 +0200
Commit:     Julien Nabet <serval2...@yahoo.fr>
CommitDate: Fri Sep 15 16:40:47 2023 +0200

    Fix assertion 'GTK_IS_CHECK_MENU_ITEM (check_menu_item)' in dbaccess
    
    Retrieve odb file 
https://bugs.documentfoundation.org/attachment.cgi?id=102977
    Open the file and edit the only table
    Right click at left on a field (except first one)
    
    (soffice:271527): Gtk-CRITICAL **: 14:35:42.787: 
gtk_check_menu_item_set_active: assertion 'GTK_IS_CHECK_MENU_ITEM 
(check_menu_item)' failed
    
    (soffice:271527): GLib-GObject-CRITICAL **: 14:35:42.787: invalid (NULL) 
pointer instance
    
    (soffice:271527): GLib-GObject-CRITICAL **: 14:35:42.787: 
g_signal_handlers_unblock_matched: assertion 'G_TYPE_CHECK_INSTANCE (instance)' 
failed
    
    If primary key entry is removed, don't try to call xContextMenu->set_active 
on it
    
    Change-Id: Ice57d840d12e986eb60514326806782e40f249fb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156946
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins

diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx 
b/dbaccess/source/ui/tabledesign/TEditControl.cxx
index 241efe597ef4..b3f5dbbe33c8 100644
--- a/dbaccess/source/ui/tabledesign/TEditControl.cxx
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -1412,11 +1412,16 @@ void OTableEditorCtrl::Command(const CommandEvent& rEvt)
                         xContextMenu->remove("paste");
                     if (!IsDeleteAllowed())
                         xContextMenu->remove("delete");
-                    if (!IsPrimaryKeyAllowed())
-                        xContextMenu->remove("primarykey");
                     if (!IsInsertNewAllowed(nRow))
                         xContextMenu->remove("insert");
-                    xContextMenu->set_active("primarykey", 
IsRowSelected(GetCurRow()) && IsPrimaryKey());
+                    if (IsPrimaryKeyAllowed())
+                    {
+                        xContextMenu->set_active("primarykey", 
IsRowSelected(GetCurRow()) && IsPrimaryKey());
+                    }
+                    else
+                    {
+                        xContextMenu->remove("primarykey");
+                    }
 
                     if( SetDataPtr(m_nDataPos) )
                         pDescrWin->SaveData( pActRow->GetActFieldDescr() );

Reply via email to