From 0e7e8bb7ed30cdb1dee7ca72748c742657b19dab Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Mon, 17 Jan 2022 20:20:18 -0900 Subject: 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 --- sw/source/uibase/utlui/content.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 9f8cfca2e0a2..650c9cdb2686 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 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) -- cgit