[QMS-1139] Fix: Endless loop with non-ASCII characters in VRT path(s)#1148
[QMS-1139] Fix: Endless loop with non-ASCII characters in VRT path(s)#1148kiozen wants to merge 2 commits into
Conversation
|
@JFritzle please test |
|
Not fixed. Last debug lines ... ... before entering endless loop. |
|
Ok, in that case I am out of ideas. This has to be fixed on the system it breaks. |
Last debug output: |
|
Can you add a debug message right after GDALAllRegister() in IAppSetup |
|
Sorry, my fault. When trying to check behavior of non-ASCII characters in VRT files, I have put German umlauts
... even if contents is the same as file N27W016.hgt. |
|
Does that mean everything ok. Ready to merge? |
|
Please wait, I am still testing. |
|
There are still ANSI encoding problems: File D:\Höhendaten\Höhendaten Schweiz.ANSI.vrt is an ANSI encoded file referencing relative file Höhendaten Schweiz/Höhendaten Schweiz.tif.
Checking filelist for validity in QMS using method before this PR but armed with additional output, shows In contrast to gdalinfo, neither old method nor current PR's method recognizes VRT as valid. |
|
Can you please fix it. I can't test and guessing fixes won't lead us to anywhere good. |
|
I will do my best. |
|
Skipping function CGdalVrtUtil::allReferencedFilesExist at all: |
|
My guess is that it is a GDAL problem. The VRT driver has to handle the sub-files and their overview files or it's own overview file. I would expect the GDAL API to be UTF8 only. But I can't tell if that holds true for Windows. A key might be the variable GDAL_FILENAME_IS_UTF8. From the docs: GDAL_FILENAME_IS_UTF8=[YES/NO]: Defaults to YES. This option only has an effect on Windows systems (using cpl_vsil_win32.cpp). If set to "NO" then filenames passed to functions like VSIFOpenL() will be passed on directly to CreateFile() instead of being converted from UTF-8 to wchar_t and passed to CreateFileW(). This effectively restores the pre-GDAL1.8 behavior for handling filenames on Windows and might be appropriate for applications that treat filenames as being in the local encoding. |
-> GDAL_FILENAME_IS_UTF8=NO makes it even worse. The problem seems indeed to be a GDAL internal one: One possible solution could be: What do you think about? One risk remains: if ANSI encoded VRT files are nested, only toplevel VRT is UTF-8 encoded. This does not matter, as long as referenced files are not checked recursively which currently does neither CGdalVrtUtil::allReferencedFilesExist nor CGdalVrtUtil::buildOverviewAdvice. |
|
Tested above. It is no solution, because referenced relative filenames are no longer relative to temporary file. Other possible solution 1: Before passing VRT filename to GDALOpen, file is read and checked for UTF-8 contents. Other possible solution 2: Before passing VRT filename to GDALOpen, file is read and checked for UTF-8 contents. |
|
Sounds both like foot fungus or scabies. As far as I understood, the key is to have a VRT that is 100% utf8, Right? Imho a case for the new VRT advisory dialog, File is checked and flagged with the exclamation mark badge if not 100% UTF8. User can click badge and gets informed about the defect with button to fix. But really, it's 2026 and I never would have thought that this is still such a problem. Just because Microsoft can't get their shit fixed. UFT8 is today's standard and there is nor real reason why every software has to bitch around Microsoft's defect. In other words: My preferred fix is still switching Windows to UTF8 instead of adding peculiar features with quite a maintenance burden. |
|
Another question: If the VRT is 100% UTF8, does it still need all the Lex Microsoft patches in this PR? I guess not, right? |
|
If VRTs are 100% UTF8, they do not need any special treatment nor patches from this PR. We had already discussions about Windows and UTF-8, at least in #1061 and #1067. Until now I believed, general UTF-8 compliance can only be enabled as a system wide option. Reading Wiki I have learned, that since May 2019, it can be set per program. How to do is by compiler option I will give it a try, add option to CMakeLists.txt, re-build QMS, keep general UTF-8 switch off, and see what happens. |
|
It turns out, that setting ... to application executable's embedded manifest makes QMS behave same as if system wide UTF-8 had been enabled, even if system wide UTF-8 is not enabled. Have to find out how to modify CMakeList.txt. Having a manifest file codepage.UTF8.manifest, in order to merge code page UTF-8 settings, command |
4ed6622 to
d14890f
Compare
|
Can you test the following with the latest patches:
|
|
This PR fails to compile in my case! Should |
|
Please check if in CMakeLists.txt the above mentioned if statement is correct or if it should be Copilot explanation: |
|
I rebased the branch. Should work now. If not @JFritzle has to explain. This is because of the new min version check. |
|
Routino routing using data from directory |
With QMapShack now running as a UTF-8 process on Windows (activeCodePage manifest, QMS-1153), GDAL and Qt handle non-ASCII filenames natively. The per-call encoding workarounds are therefore no longer needed and are removed: the VRT path handling, the Routino path define, and the qmt_map2jnx argv decoding.
|
That multiple message box is only happening because there are multiple canvas. The file is activated on multiple canvas and stored in the config. Now, with the patch this triggers the message box multiple time. However if a message box is confirmed the file should not activate, this is saved in the config and next start should be ok. Is that right? |
GDAL passes a VRT's <SourceFilename> bytes to the OS verbatim and ignores the XML encoding declaration, so a non-UTF-8 (e.g. legacy Latin-1) VRT resolves to broken paths and fails obscurely. Check UTF-8 validity when opening a .vrt in CMapVRT/CDemVRT and reject it up front with a clear message instead. Also reconcile the map/DEM list indicator with the real activation outcome so a rejected (or otherwise failed) file no longer leaves a stuck grey load indicator in the tree.
-> Not right. Same message boxes after restart, Btw: |
How? I need more information. No guess work. When activated the first time the message box pops up and activation is aborted. Closing QMS will save these VRTs as not active in the config. So a second restart should never activate them. If they are still active I need to know why. This Windows bullshit ping pong is tiresome. I will never ever implement any Windows workaround in the future for sure. If it's broken on Windows it stays broken. toLocal8Bit() should deflate to nothing on UTF8 systems. So it's more cosmetics. |




GetFileList()/GetDescription() return filenames in the platform encoding (ANSI or UTF-8 on Windows). allReferencedFilesExist() decoded both ways, but buildOverviewAdvice() used QString::fromUtf8() unconditionally, so on ANSI Windows a non-ASCII path passed validation and then failed source probing/comparison. Centralize the decode in decodeGdalPath() and use it for the file list and ownPath; open probed sources trying UTF-8 (and local-8-bit as a fallback).
What is the linked issue for this pull request:
QMS-#1139
What you have done:
Steps to perform a simple smoke test:
saee ticket
Does the code comply to the coding rules and naming conventions Coding Guidelines:
Is every user facing string in a tr() macro?
Did you add the ticket number and title into the changelog? Keep the numeric order in each release block.