Fix file index misdetection due to Unicode normalization issues #558
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue I noticed in the picture/video from @Andreas0602 in #531. The file number in the titlebar was showing as "0". I believe macOS is performing Unicode normalization when it passes the path to launch qView from Finder, whereas the files fetched from
QDir::entryInfoList
don't have the normalization. This confuses the optimization inupdateLoadedIndexInFolder
that does aQString::compare
. The filenames are considered different because it's comparing a single "ä" character versus one composed of "a" + U+0308 (Combining Diaeresis). Note that the optimization is very important because in a folder with ~15K files, if it has to check all of them withFileInfo::operator==
alone, it's taking ~1010ms on one of my test machines. The optimization allows it to run in ~1ms. I was able to fix this by adding someQString::normalize
calls, which doesn't add noticeable overhead if the string doesn't end up changing, or very minor overhead even if all of those files have characters that result in normalization changes (completes in ~9ms overall).