Fix crash when deleting cached macro widgets

This commit is contained in:
WarmUpTill 2025-06-12 20:31:11 +02:00 committed by WarmUpTill
parent 0736d673e1
commit d9d387ad47
2 changed files with 9 additions and 5 deletions

View File

@ -56,9 +56,7 @@ MacroSegmentList::~MacroSegmentList()
_autoScrollThread.join();
}
for (const auto &[_, widgets] : _widgetCache) {
clearWidgetVector(widgets);
}
ClearWidgetCache();
}
static bool posIsInScrollbar(const QScrollBar *scrollbar, const QPoint &pos)
@ -146,7 +144,6 @@ void MacroSegmentList::SetCachingEnabled(bool enable)
void MacroSegmentList::CacheCurrentWidgetsFor(const Macro *macro)
{
if (!_useCache) {
_widgetCache.clear();
return;
}
@ -168,7 +165,6 @@ void MacroSegmentList::CacheCurrentWidgetsFor(const Macro *macro)
bool MacroSegmentList::PopulateWidgetsFromCache(const Macro *macro)
{
if (!_useCache) {
_widgetCache.clear();
return false;
}
@ -340,6 +336,13 @@ void MacroSegmentList::HideLastDropLine()
_dropLineIdx = -1;
}
void MacroSegmentList::ClearWidgetCache()
{
for (const auto &[_, widgets] : _widgetCache) {
clearWidgetVector(widgets);
}
}
static bool isInUpperHalfOf(const QPoint &pos, const QRect &rect)
{
return QRect(rect.topLeft(),

View File

@ -61,6 +61,7 @@ private:
bool IsInListArea(const QPoint &) const;
QRect GetContentItemRectWithPadding(int idx) const;
void HideLastDropLine();
void ClearWidgetCache();
int _dragPosition = -1;
int _dropLineIdx = -1;