From f3bfd94bbf97ce5890f969a8acb898fb222a38cf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 5 Nov 2023 23:50:51 +0100 Subject: [PATCH] Fix crash in wxAuiNotebook after dragging a page Fix using outdated click position in wxAuiTabCtrl mouse handlers, which resulted in an invalid wxEVT_AUINOTEBOOK_DRAG_MOTION event being generated and a crash while handling it. Ensure that we reset m_clickPt when resetting m_isDragging too so that we don't decide that we're dragging if the mouse enters the window with the left button already pressed after a previous drag. See #24027, #24039. (cherry picked from commit f1a3816cd9da0c3c7ceebe9735d37fb2d3158388) --- docs/changes.txt | 1 + src/aui/auibook.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 063f96d75e..d3f9a5e592 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -242,6 +242,7 @@ All: All (GUI): +- Fix possible crash when dragging pages in wxAuiNotebook (#24027). - Fix refreshing multiple selection items in generic wxListCtrl. wxGTK: diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index fb39238409..0068c62f9f 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -1099,6 +1099,7 @@ void wxAuiTabCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event)) { if (m_isDragging) { + m_clickPt = wxDefaultPosition; m_isDragging = false; wxAuiNotebookEvent evt(wxEVT_AUINOTEBOOK_CANCEL_DRAG, m_windowId); @@ -1116,6 +1117,7 @@ void wxAuiTabCtrl::OnLeftUp(wxMouseEvent& evt) if (m_isDragging) { + m_clickPt = wxDefaultPosition; m_isDragging = false; wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_END_DRAG, m_windowId);