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. Error Debugging with OpenGL
QtWS25 Last Chance

Error Debugging with OpenGL

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 1.8k Views
  • 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.
  • H Offline
    H Offline
    Hozarberto
    wrote on last edited by Hozarberto
    #1

    Well, I have this error debugging in QtCreator, I show screenviews:

    0_1504514487225_01.JPG

    It just break in this line:

    tool_list[i] = new QLabel();

    with tool_list initialized as

    QList <QLabel*> tool_list;
    tool_list.reserve(NUM_TOOL_MAX);

    The program rules good in release, but not in debug.

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

      Hi and welcome to devnet,

      Are you sure you intialized every variable properly ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hozarberto
        wrote on last edited by
        #3

        Yes, the program rules well in release, only fails in debug.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Please show the backtrace of the crash.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • H Offline
            H Offline
            Hozarberto
            wrote on last edited by
            #5

            0_1504605353861_02.jpg

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Did you check the size of tool_list ?

              And by the way, why not use append rather than a fixed sized that might never been reached thus consuming memory for nothing ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • H Offline
                H Offline
                Hozarberto
                wrote on last edited by
                #7

                @SGaist said in Error Debugging with OpenGL:

                And by the way, why not use append rather than a fixed sized that might never been reached thus consuming memory for nothing ?

                Yes, it's 0 at this point (in release and debug).

                But I don't understand because it work in release and the program run, but not in debug

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  So basically you are trying to access element 0 of a vector of size 0 ?

                  That won't work.

                  In release mode you will be getting a vector of unknown size if NUM_TOOL_MAX is not properly initialised. It will contain garbage as you have to explicitly initialise variables.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    Hozarberto
                    wrote on last edited by
                    #9

                    I'm completly sure that NUM_TOOL_MAX is initialised, even I tried

                    tool_list.reserve(3);
                    tool_list[i] = new QLabel();

                    And doesn't work.

                    The code isn't mine, so I don't know why is like this, any suggestion for initalize the array?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Well... Unless you have very good reasons for that, just don't and use append so your tool_list vector will grow as much as you add QLabels.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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