Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Windows: some QRC resources are inaccessible when using Qt 5.8, works fine with 5.7
Qt 6.11 is out! See what's new in the release blog

Windows: some QRC resources are inaccessible when using Qt 5.8, works fine with 5.7

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 3 Posters 3.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Violet Giraffe
        wrote on last edited by Violet Giraffe
        #3

        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.

        1 Reply Last reply
        1
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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 :)

          1 Reply Last reply
          0
          • V Offline
            V Offline
            Violet Giraffe
            wrote on last edited by
            #5

            Yes, I've actually started without an alias and only added it later. it makes no difference.

            mrjjM 2 Replies Last reply
            0
            • V Violet Giraffe

              Yes, I've actually started without an alias and only added it later. it makes no difference.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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.

              1 Reply Last reply
              0
              • V Violet Giraffe

                Yes, I've actually started without an alias and only added it later. it makes no difference.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Violet-Giraffe
                Hmm.
                Installed 5.8 (just for u ;)
                and funny enough it works?
                alt text

                V 1 Reply Last reply
                0
                • mrjjM mrjj

                  @Violet-Giraffe
                  Hmm.
                  Installed 5.8 (just for u ;)
                  and funny enough it works?
                  alt text

                  V Offline
                  V Offline
                  Violet Giraffe
                  wrote on last edited by
                  #8

                  @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!

                  mrjjM 1 Reply Last reply
                  0
                  • V Violet Giraffe

                    @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!

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @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?

                    1 Reply Last reply
                    1
                    • V Offline
                      V Offline
                      Violet Giraffe
                      wrote on last edited by
                      #10

                      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.

                      mrjjM 1 Reply Last reply
                      0
                      • V Violet Giraffe

                        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.

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @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)

                        1 Reply Last reply
                        1
                        • V Offline
                          V Offline
                          Violet Giraffe
                          wrote on last edited by
                          #12

                          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.

                          mrjjM 1 Reply Last reply
                          0
                          • V Violet Giraffe

                            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.

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @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.

                            1 Reply Last reply
                            0
                            • V Offline
                              V Offline
                              Violet Giraffe
                              wrote on last edited by
                              #14

                              Well, Qt is (usually) binary-compatible between versions, so while normal operation in this case is not guaranteed, it is probable.

                              1 Reply Last reply
                              0
                              • V Offline
                                V Offline
                                Violet Giraffe
                                wrote on last edited by
                                #15

                                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 :)

                                1 Reply Last reply
                                0
                                • hskoglundH Offline
                                  hskoglundH Offline
                                  hskoglund
                                  wrote on last edited by
                                  #16

                                  Hi, you can use qVersion(), like this:

                                  qDebug() << qVersion();
                                  
                                  V 1 Reply Last reply
                                  3
                                  • hskoglundH hskoglund

                                    Hi, you can use qVersion(), like this:

                                    qDebug() << qVersion();
                                    
                                    V Offline
                                    V Offline
                                    Violet Giraffe
                                    wrote on last edited by
                                    #17

                                    @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!

                                    1 Reply Last reply
                                    0

                                    • Login

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • Users
                                    • Groups
                                    • Search
                                    • Get Qt Extensions
                                    • Unsolved