Merge pull request #3256 from jolavillette/fix/shared-files-popular-files-crash

fix(SharedFiles): stop SIGSEGV when toggling "Popular files" after a search
This commit is contained in:
csoler 2026-07-03 18:25:26 +02:00 committed by GitHub
commit 348c9e7e94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -120,7 +120,19 @@ public:
void setUploadedOnly(bool val) {
if (m_uploadedOnly != val) {
m_uploadedOnly = val;
invalidateFilter();
// Use invalidate() rather than invalidateFilter(). invalidateFilter()
// triggers Qt's *incremental* row-removal path (filter_changed), which
// emits rowsAboutToBeRemoved while walking the currently-mapped tree.
// With an active text filter and an expanded tree there are live
// persistent proxy indexes, and removing an interior directory node
// frees child mapping structs those indexes still point to -> the
// removal bookkeeping then dereferences freed memory inside
// QSortFilterProxyModel::parent() and crashes (SIGSEGV). This is the
// "search a keyword, then click Popular files" crash.
// invalidate() rebuilds the whole proxy mapping via the layoutChanged
// protocol, which remaps persistent indexes safely, and it does NOT
// re-crawl the source model, so it stays near-instant.
invalidate();
}
}