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. [SOLVED] Crash right at instancing QMainWindow inheriting class
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Crash right at instancing QMainWindow inheriting class

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 2.9k Views 1 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.
  • L Offline
    L Offline
    LReiter
    wrote on last edited by
    #1

    Hey guys,
    so I've written a program with Qt, c++ and openGL and wanted to add support for my Oculus Rift DK. To get an overview, I used "this code":http://pastebin.com/2VEasjbu, rewrote parts of it and tried to get my application to run.
    Since I did that, it just crashes on startup. For debugging purposes, I'm calling qDebug() everytime I enter and leave any function and between steps.
    My main.cpp file looks like this:

    @#include "mainwindow.h"
    #include <QApplication>

    int main(int argc, char *argv[])
    {
    qDebug() << "main.cpp Start!";
    QApplication a(argc, argv);
    qDebug() << "vor MainWindow w";
    MainWindow w;
    qDebug() << "vor w.show()";
    w.show();

    return a.exec&#40;&#41;;
    qDebug(&#41; << "main.cpp Ende";
    

    }@

    It just runs up to the "vor MainWindow w" message before crashing (with an access violation).
    My question is: where might that violation be? In the MainWindow constructor? Because that one also has qDebug() messages in it which are never even reached. Could it still be responsible or has it got to be something in my header file (mainwindow.h) or something?
    Thanks a lot in advance!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Could you show MainWindow constructor.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        Xander84
        wrote on last edited by
        #3

        what about starting your app in debug mode, if it crashes your should see a full backtrace where exactly the crash happens!?

        If your have some member variables that are created on the stack in your main window it might also crash there, so hard to say without the code.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          LReiter
          wrote on last edited by
          #4

          Unfortunately, my code is a huge mess (and at work, had to leave early today). I will get back to that on monday.
          Starting in debug mode means having a debugger set up? I couldn't do that so far since I have no rights on my work computer. I'll see to get one though.
          Thanks so far!

          1 Reply Last reply
          0
          • X Offline
            X Offline
            Xander84
            wrote on last edited by
            #5

            yeah of course you need a c++ debugger to start in debug mode, but that depends on the platform and compiler your are using.. usually you can use the default debugger unless you are using the MSVC compiler, I never figured out how to install a debugger for that. In that case I just switched to MinGW on windows there is a debugger included.

            1 Reply Last reply
            0
            • JeroentjehomeJ Offline
              JeroentjehomeJ Offline
              Jeroentjehome
              wrote on last edited by
              #6

              It's the constructor or the call to the constructor.
              Because the MainWindow is also a QObject subclass and when using Designer it also includes some ui derived classes.
              You might want to show the constructor?

              Greetz, Jeroen

              1 Reply Last reply
              0
              • X Offline
                X Offline
                Xander84
                wrote on last edited by
                #7

                Jeroentje: As far I know the crash can also happen in the class' member initialization.
                e.g.
                @
                class ABC {
                public:
                ABC() {} // may crash here
                private:
                XYZ xyz; // or constructor call of XYZ here may also crash
                }
                @
                if the constructor of a member variables crashes the body of the own constructor is never called. OP said he had debug messages in his constructor and if they never get printed that might be the issue!?

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  LReiter
                  wrote on last edited by
                  #8

                  Xander84: Yes I'm using the MSVC compiler. Couldn't get a debugger to work with it too.
                  Anyway, solution to my problem was an error in the Oculus SDK - if you try to instanciate a sensorfusion object without calling system::init first or instanciate a system object, you're gonna have a bad time. :)

                  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