On Tue, 4 Apr 2023 19:52:25 -0700 (PDT), 'Matt Harbison' via TortoiseHg Developers wrote:
> I noticed the UI acting sluggish all of a sudden, did some poking around,
> and the TortoiseHgQt.ini file was 32MB, the vast majority of it
> \xc3\x83\2c\x83... in the middle of one of the revset queries. I cleared
> that part out of the config file, entered `author('Raphaël Gomès')` using
> PyQt6 on Windows in the filterbar, exited, and it was properly saved in the
> file. However, if I launched workbench with PyQt5 (from a venv, so I can't
> blame p2exe), it displays in the revset filter properly, prints to cmd.exe
> properly in RepoFilterBar.saveSettings(), but when I diff the ini file
> against what PyQt6 saved, it's encoded in ANSI (vs UTF-8 for PyQt6), and
> the content is `author('Rapha\xebl Gom\xe8s')`. Launching again and again
> seems to grow the length of the string (I assume by ~doubling).
AFAIK, the encoding is changed to UTF-8 at Qt 6, and there's no config knob.
https://doc.qt.io/qt-6/qsettings.html#compatibility-with-older-qt-versions
> So the question is, how can the encoding be set? I don't see the filename
> anywhere, and it seems to come from the application name. I saw a
> reference to .setIniCodec() [1], which I tried on PyQt5 in
> RepoWidget.closeRepoWidget(), since that's where the object is created that
> is passed to the filterbar for saving. But that didn't seem to help, so
> maybe there's a more root settings object? IDK how all of these separate
> objects build one file.
I don't know what's going on, but QSettings is read/written back at various
places, so all of them might have to be set to use UTF-8. I believe QSettings
data would be implicitly cached globally, but I don't know if the iniCodec is
retained.