From d9d7c4fbb37e1e233cb47b1b43c70c4fcb76301c Mon Sep 17 00:00:00 2001 From: Don Ho Date: Wed, 8 Jan 2025 17:22:44 +0100 Subject: [PATCH] Fix vertical tab crashes on enabling/disabling pin tab feature Fix #16033, close #16034 --- PowerEditor/src/ScintillaComponent/DocTabView.cpp | 3 +++ PowerEditor/src/WinControls/TabBar/TabBar.cpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/ScintillaComponent/DocTabView.cpp b/PowerEditor/src/ScintillaComponent/DocTabView.cpp index 4aff0d42a..1d615dc80 100644 --- a/PowerEditor/src/ScintillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScintillaComponent/DocTabView.cpp @@ -99,6 +99,9 @@ void DocTabView::setIndividualTabColour(BufferID bufferId, int colorId) int DocTabView::getIndividualTabColourId(int tabIndex) { BufferID bufferId = getBufferByIndex(tabIndex); + if (!bufferId) + return -1; + return bufferId->getDocColorId(); } diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 0a769ae51..6607736e0 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -1522,16 +1522,16 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) } // draw pin button - if (_drawTabPinButton && _hPinBtnImgLst != nullptr) + Buffer* buf = reinterpret_cast(tci.lParam); + if (_drawTabPinButton && _hPinBtnImgLst != nullptr && buf) { // Each tab combined with the following stats : // (active / inactive) | (pinned / unpinned) | (hover / not hover / pushed) - bool isPinned = reinterpret_cast(tci.lParam)->isPinned(); + bool isPinned = buf->isPinned(); int idxPinImg = _unpinnedIdx; // current: upinned as default - if (isPinned) { if (!isSelected) // inactive