Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74443

QResource gives wrong data for embedded binary file

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.6.3, 5.9.7, 5.12.1
    • Core: Resource System
    • None
    • Gentoo Linux AMD64.
    • Linux/X11

    Description

      I am unable to get to the data of an embedded binary file. The binary file is 43116 bytes, but when opening it using QResource, size() reports a size of 818 bytes, and data() points to garbage (or perhaps compressed data?)

      This happens with all Qt versions I tried: 5.6.3, 5.9.7 and 5.12.1. (Using the official Linux 64-bit binary installer.)

      resources.qrc file:

       

      <RCC>
       <qresource prefix="/">
       <file>data.bin</file>
       </qresource>
      </RCC>
      

      qmake project:

       

      QT -= gui
      CONFIG += c++11 console
      CONFIG -= app_bundle
      SOURCES += main.cpp
      RESOURCES += resources.qrc
      

      main.cpp:

       

      #include <QCoreApplication>
      #include <QResource>
      #include <iostream>
      int main(int argc, char* argv[])
      {
          QCoreApplication a(argc, argv);
          QResource res(":/data.bin");
          std::cout << res.size() << '\n';
      }
      

      This prints "818" and res.data() points to garbage.

      "data.bin" is attached.

      Attachments

        Activity

          People

            hjk hjk
            realnc Nikos Chantziaras
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: