Results 1 to 3 of 3

Thread: qInitResources_mimetypes() crashes

  1. #1
    Join Date
    Apr 2009
    Location
    www.JaminGrey.com
    Posts
    71
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default qInitResources_mimetypes() crashes

    For several months and several versions of Qt, I've been on-and-off crashing in qInitResources_mimetypes() before the code even reaches main().

    Here's the callstack:
    Qt Code:
    1. 0 (anonymous namespace)::qInitResources_mimetypes_ctor_class_::qInitResources_mimetypes_ctor_class_ qrc_mimetypes.cpp 15851 0x6b9ea223
    2. 1 __static_initialization_and_destruction_0 qrc_mimetypes.cpp 15851 0x6b9ea2a9
    3. 2 _GLOBAL__sub_I__Z24qInitResources_mimetypesv qrc_mimetypes.cpp 15860 0x6b9ea2db
    4. 3 __do_global_ctors C:\Qt\Qt5.0.1\5.0.1\mingw47_32\lib\Qt5Cored.dll 0x6b9f2bfa
    5. 4 ?? 0x2
    6. 5 ?? 0x22fd24
    7. 6 ??
    To copy to clipboard, switch view to plain text mode 

    Why does this occur and how can I work around it?

    Currently I'm using Qt 5.0.1, but have had the same problem with 5.0.0 and 4.8. Any ideas?

  2. #2
    Join Date
    May 2014
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qInitResources_mimetypes() crashes

    I am having the same problem, I dont know what I should do to fix it, did you manage to find a solution or workaround?

  3. #3
    Join Date
    Apr 2009
    Location
    www.JaminGrey.com
    Posts
    71
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qInitResources_mimetypes() crashes

    I don't remember if this was the same problem or not, but if so, the problem occurs because your resources are attached to a static library, and C++'s order of static initialization is undefined, so weird crashes can occur on occasion.

    The solution is that, for static libraries, you manually initialize your resource packs. See [here].

    I do it by explicitly calling:
    Qt Code:
    1. Q_INIT_RESOURCE(EditorResources); //EditorResources.qrc is the name of the resource package, but you drop the '.qrc'
    To copy to clipboard, switch view to plain text mode 

    However, I also ran into another problem: You can't call Q_INIT_RESOURCE() from inside a namespace (I guess it messes up some macro or something).

    So I had to do it like this:
    Qt Code:
    1. //This function is because Q_INIT_RESOURCE() is required to be called from a plain function not in any namespace.
    2. //That macro needs to be called to initialize Qt Resource archives when in dynamic or static libraries.
    3. void InitializeQtResources()
    4. {
    5. Q_INIT_RESOURCE(EditorResources);
    6. }
    7.  
    8. namespace Platform
    9. {
    10. MainWindow::MainWindow(int argc, char *argv[])
    11. : ui(new Ui::MainWindow)
    12. {
    13. //Initialize all the images we have baked into the static library in Qt resource packages.
    14. InitializeQtResources();
    15.  
    16. //Initialize the widgets that are children of this widget.
    17. ui->setupUi(this);
    18.  
    19. this->initializeMyWidgets();
    20. }
    21.  
    22. } //End of namespace.
    To copy to clipboard, switch view to plain text mode 

    That was quite a while ago, so I don't know if the problem I was having in this thread is the same or a different problem.

Similar Threads

  1. What's This crashes on Mac OS X?
    By ypeels in forum Qt Programming
    Replies: 1
    Last Post: 31st October 2012, 15:33
  2. It works once, but crashes if I do it again
    By Astrognome in forum Newbie
    Replies: 3
    Last Post: 28th March 2012, 00:06
  3. My QTCPServer crashes
    By Mr_Burns in forum Newbie
    Replies: 6
    Last Post: 23rd May 2011, 20:17
  4. app crashes again
    By sophister in forum Qt Programming
    Replies: 7
    Last Post: 15th June 2009, 10:01
  5. Uic3 crashes...
    By amcdaniel in forum Qt Programming
    Replies: 2
    Last Post: 8th May 2007, 22:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.