From d7613c2e90cc518b44e3bea3349b5834af896fa2 Mon Sep 17 00:00:00 2001 From: D-AIRY <admin@ds-servers.com> Date: Thu, 28 Nov 2024 16:08:54 +0300 Subject: [PATCH] Fixed UITree crash on resize --- source/xUI/UITree.cpp | 31 +++++++++++++++++++++++-------- source/xUI/UITree.h | 3 +++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/source/xUI/UITree.cpp b/source/xUI/UITree.cpp index e3f3ae178..4992ed0c7 100644 --- a/source/xUI/UITree.cpp +++ b/source/xUI/UITree.cpp @@ -294,13 +294,10 @@ void CUITree::dispatchEvent(gui::IEvent *ev) if(m_pAdapter) { - UINT uCols = m_pAdapter->getColumnCount(); - for(UINT i = 0; i < uCols; ++i) - { - setColumnWidth(i, m_pAdapter->getColumnHeaderWidth(i, m_uWidth)); - } + abortEdit(); - updateVisibleNodes(); + m_bScheduledResize = true; + m_pUIWindow->registerForUpdate(this); } } } @@ -427,7 +424,21 @@ void CUITree::dispatchEvent(gui::IEvent *ev) } else if(ev->type == gui::GUI_EVENT_TYPE_UPDATE) { - updateDataset(); + if(m_bScheduledDatasetChange) + { + m_bScheduledDatasetChange = false; + updateDataset(); + } + if(m_bScheduledResize) + { + m_bScheduledResize = false; + UINT uCols = m_pAdapter->getColumnCount(); + for(UINT i = 0; i < uCols; ++i) + { + setColumnWidth(i, m_pAdapter->getColumnHeaderWidth(i, m_uWidth)); + } + updateVisibleNodes(); + } } } @@ -455,7 +466,11 @@ void XMETHODCALLTYPE CUITree::notifyDatasetChanged() abortEdit(); - m_pUIWindow->registerForUpdate(this); + if(!m_bScheduledDatasetChange) + { + m_bScheduledDatasetChange = true; + m_pUIWindow->registerForUpdate(this); + } } void XMETHODCALLTYPE CUITree::notifySelectionChanged() diff --git a/source/xUI/UITree.h b/source/xUI/UITree.h index aed8ea050..cb5b83750 100644 --- a/source/xUI/UITree.h +++ b/source/xUI/UITree.h @@ -104,6 +104,9 @@ private: UITreeNodeHandle m_hFocusNode = NULL; + bool m_bScheduledResize = false; + bool m_bScheduledDatasetChange = false; + private: void setColumnCount(UINT uCount); UINT getColumnCount(); -- GitLab