diff --git a/lib/macro/macro-segment-list.cpp b/lib/macro/macro-segment-list.cpp index 99d16ead..03320590 100644 --- a/lib/macro/macro-segment-list.cpp +++ b/lib/macro/macro-segment-list.cpp @@ -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(), diff --git a/lib/macro/macro-segment-list.hpp b/lib/macro/macro-segment-list.hpp index f14922fc..95988c71 100644 --- a/lib/macro/macro-segment-list.hpp +++ b/lib/macro/macro-segment-list.hpp @@ -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;