diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-11-26 09:18:41 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-11-26 16:48:57 +0100 |
commit | ae6e7be84ed377ac63f01fdea323c0d6ee909514 (patch) | |
tree | de78323bfdbb0745baec4410d4d1dc2d4ebf0eb2 /vcl | |
parent | a1e458c8957e5e27a5fb8087da37b2472e4a804b (diff) |
keep toolitem ids unique
which is a problem when we swap item ids under SAL_RTL_ENABLED=1
in sidebars
Change-Id: Ib949f7836893b2f06b748fc3a2546788555782ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106662
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index af7653b71e57..1863076ddfcf 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -8577,11 +8577,22 @@ public: virtual void set_item_ident(int nIndex, const OString& rIdent) override { - m_aMap.erase(m_aMap.find(get_item_ident(nIndex))); + OString sOldIdent(get_item_ident(nIndex)); + m_aMap.erase(m_aMap.find(sOldIdent)); GtkToolItem* pItem = gtk_toolbar_get_nth_item(m_pToolbar, nIndex); gtk_buildable_set_name(GTK_BUILDABLE(pItem), rIdent.getStr()); + // to keep the ids unique, if the new id is already in use by an item, + // change the id of that item to the now unused old ident of this item + auto aFind = m_aMap.find(rIdent); + if (aFind != m_aMap.end()) + { + GtkToolItem* pDupIdItem = aFind->second; + gtk_buildable_set_name(GTK_BUILDABLE(pDupIdItem), sOldIdent.getStr()); + m_aMap[sOldIdent] = pDupIdItem; + } + m_aMap[rIdent] = pItem; } |