Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file index misdetection due to Unicode normalization issues #558

Merged
merged 1 commit into from
Jan 14, 2023

Conversation

jdpurcell
Copy link
Contributor

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 in updateLoadedIndexInFolder that does a QString::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 with FileInfo::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 some QString::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).

@jurplel jurplel merged commit f082a46 into jurplel:master Jan 14, 2023
@jdpurcell jdpurcell deleted the filenumberbug branch August 28, 2023 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants