Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/library/basetrackcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ void BaseTrackCache::filterAndSort(const QSet<TrackId>& trackIds,
.arg(m_idColumn, idStrings.join(","));
}

// Note(ronso0) SearchQueryParser::parseQuery(searchQuery, extraFilter) wraps
// extraFilter in an SqlNode, and SqlNode::match() always returns true.
// Unwanted sideeffect is described where we check if dirty tracks may be added.
const std::unique_ptr<QueryNode> pQuery =
m_pQueryParser->parseQuery(
searchQuery,
Expand Down Expand Up @@ -549,8 +552,15 @@ void BaseTrackCache::filterAndSort(const QSet<TrackId>& trackIds,

// The track should be in the result set if the search is empty or the
// track matches the search.
bool shouldBeInResultSet = searchQuery.isEmpty() ||
pQuery->match(pTrack);
// FIXME Above we create a QueryNode from the searchQuery and extraFilter.
// SearchQueryParser::parseQuery(searchQuery, extraFilter) wraps
// extraFilter in an SqlNode, and SqlNode::match() always returns true.
// Hence, if extraFilter is not empty, pQuery->match(pTrack) always returns
// true and will add all dirty tracks to the set where they not necessarily
// belong.
// So the TODO is: find a better way to handle extraFilter.
bool shouldBeInResultSet = extraFilter.isEmpty() &&
(searchQuery.isEmpty() || pQuery->match(pTrack));

// If the track is in this result set.
bool isInResultSet = trackToIndex->contains(trackId);
Expand Down