Solved Windows: some QRC resources are inaccessible when using Qt 5.8, works fine with 5.7
-
Iv'e got a Windows executable that uses a bunch of resources through the QRC system. Up to (and including) Qt 5.7 there was no problem, but with 5.8 some resources fail to load. Investigation shows that they are present in the generated qrc_resources.cpp file.
Note 1: only some of the resources from this qrc file fail to load, not all of them.
Note 2: all the missing resources are plain text. When inspecting the Qt 5.7-generated binary with a plain text viewer I can see my text resources as plain text in the .exe. When inspecting the Qt 5.8 binary I do not see them. However, if, say, Qt 5.8 started compressing resources - naturally, I won't see them.Is it a known problem? What could be going on?
-
Hi
This is hard to guess at.
Sounds like regression but we need minimal sample that can reproduce this.I would fool around ith the tool in a shell to see if something being shown.
http://doc.qt.io/qt-5/rcc.html
Maybe try with -no-compress and look in the exe to see what could possible happen.
-
Here's the minimal example.. Fails to load the resource file "123.txt" when built with Qt 5.8, works with 5.7.1.
Windows 10 x64, building with 32-bit msvc2015 Qt 5.7.1 or 32-bit msvc2015 Qt 5.8.
-
Super!
Maybe the alias thing broke
<RCC>
<qresource prefix="/">
<file alias="123">123.txt</file>
<file>mytest.txt</file>
</qresource>
</RCC>Can you try in 5.8 with no alias ?
I need to install 5.8 to test :)
-
Yes, I've actually started without an alias and only added it later. it makes no difference.
-
@Violet-Giraffe
Super.
This does smell a bit like bug
I would go look at
https://bugreports.qt.io/secure/Dashboard.jspa
to see if already reported. -
@Violet-Giraffe
Hmm.
Installed 5.8 (just for u ;)
and funny enough it works?
-
@mrjj
Meh. That feeling when you're disappointed the bug doesn't occur :)
Works on my home PC, too. But not the office one. Guess I'll use debugger to dive into Qt sources tomorrow. Fun! -
@Violet-Giraffe
Yes Its a ambivalent moment.
I also wish it was just a normal bug as that's easier to explain that what
on earth could be a difference.Maybe virus scanner locks the file the moment it tried to compile it :)
I was wondering. If you compile on Home machine and run on work.
Can it load it then? -
Good idea.
There's no AV scanner on either of the PCs (I know you didn't mean it literally, but still).
Also, I've inspected the generated qrc_*.cpp files obtained by Qt 5.7 and 5.8. There are no differences in the data chunks. Both cpp files do include all the files as expected. -
@Violet-Giraffe
Well my old version of avast would silently block the exe so from that i learned that
its not to be ruled out completely ;)So if we assume that the resource is indeed compiled in, then it seems impossible
it can fall off, so i wonder if QString QIODevice::errorString() const could tell something (when it fails) -
Found the reason for this behavior. If the program was built using Qt 5.8 toolset, it must run with Qt 5.8 DLLs. So happened that I was running my Qt 5.8-built binary against Qt 5.7 (due to PATH settings), and that is the situation in which resource loading fails at runtime. Otherwise the application behaves perfectly normal so it was hard to spot I'm doing something wrong.
-
@Violet-Giraffe
Wow
Good found.
Did not think of that scenario.
Would expect it to blow up a bit more - but it makes sense when you say it
Besides the QApplication, the QFile is one the first Qt class to be used at start up. -
Well, Qt is (usually) binary-compatible between versions, so while normal operation in this case is not guaranteed, it is probable.
-
On that note: is it possible to query the version of Qt library at runtime? I. e. the version of the Qt DLLs, not the headers I used during compilation? I want to add an assert() to my programs :)
-
Hi, you can use qVersion(), like this:
qDebug() << qVersion();
-
@hskoglund said in Windows: some QRC resources are inaccessible when using Qt 5.8, works fine with 5.7:
Hi, you can use qVersion(), like this:
qDebug() << qVersion();
Very nice, thank you, that does exactly what I need!