sw/source/uibase/utlui/content.cxx |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 3b7f42c033478a4faec15baf92f6fa61cd09eba6
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Mon Jan 17 20:20:18 2022 -0900
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Jan 24 20:40:14 2022 +0100

    SwNavigator: disallow tracking update when content tree has focus
    
    When document layout has not finished and there is no content to track
    at the cursor position, e.g. the cursor position is at the start of a
    document having text before the first heading paragraph, a selection
    made in the Navigator content tree can automatically unselect. This is
    not only annoying but causes a crash when action of a choice from
    the Navigator context menu is dependent on entry selection, e.g.
    'Delete', 'Edit', 'Rename'. This patch prevents this annoyance and
    crash by disallowing content tracking when the content tree or the
    content tree context menu has focus.
    
    Change-Id: I2b0fd1ac4f53571e30ce1efa2934a70de2aad819
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128520
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>
    (cherry picked from commit 0e7e8bb7ed30cdb1dee7ca72748c742657b19dab)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128531
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 093a502da84f..01c0b005f8ff 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -3682,6 +3682,10 @@ void SwContentTree::UpdateTracking()
     if (State::HIDDEN == m_eState || !m_pActiveShell)
         return;
 
+    // only when treeview or treeview context menu does not have focus
+    if (m_xTreeView->has_focus() || m_xTreeView->has_child_focus())
+        return;
+
     // m_bIgnoreDocChange is set on delete and outline visibility toggle
     if (m_bIgnoreDocChange)
     {
@@ -4491,7 +4495,7 @@ void SwContentTree::ExecuteContextMenuAction(const 
OString& rSelectedPopupEntry)
 
     std::unique_ptr<weld::TreeIter> xFirst(m_xTreeView->make_iterator());
     if (!m_xTreeView->get_selected(xFirst.get()))
-        xFirst.reset();
+        return; // this shouldn't happen, but better to be safe than ...
 
     auto nSelectedPopupEntry = rSelectedPopupEntry.toUInt32();
     switch (nSelectedPopupEntry)

Reply via email to