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. Debugging a Qt-library
Forum Updated to NodeBB v4.3 + New Features

Debugging a Qt-library

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 4 Posters 1.3k 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.
  • R Offline
    R Offline
    Rasmunis
    wrote on last edited by
    #1

    Hi!

    Tl;dr:
    How do I make changes to a qt-library's source-code for debugging purposes?


    I am currently using the Q3DScatter of the Data Visualization library to visualize a point-cloud, and it seems that every time I update the point-cloud with new data there is a memory leak. I have analyzed my method for loading the point-cloud data and the problem seems to be elsewhere, which has made me look to the library itself. I have attempted to edit and rebuild the library-code, but it doesn't seem to work. So my question is how to do this? I would prefer to avoid building from the open-source code until I know that the problem is in the library and that a change is necessary.

    jsulmJ 1 Reply Last reply
    0
    • R Rasmunis

      Hi!

      Tl;dr:
      How do I make changes to a qt-library's source-code for debugging purposes?


      I am currently using the Q3DScatter of the Data Visualization library to visualize a point-cloud, and it seems that every time I update the point-cloud with new data there is a memory leak. I have analyzed my method for loading the point-cloud data and the problem seems to be elsewhere, which has made me look to the library itself. I have attempted to edit and rebuild the library-code, but it doesn't seem to work. So my question is how to do this? I would prefer to avoid building from the open-source code until I know that the problem is in the library and that a change is necessary.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Rasmunis You don't need to build from sources to be able to debug Qt. Install Qt sources (same version of Qt you're using) and tell QtCreator where it is. Then you should be able to step into Qt code.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rasmunis
        wrote on last edited by
        #3

        Yes, I am able to step into it in debug-mode, but I want to make changes to it so I can test if there's an actual bug there. Sorry if I phrased myself a bit confusingly.

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

          Hi and welcome to devnet,

          Might be a silly question but after building the module, did you install it ?

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

          R 1 Reply Last reply
          1
          • SGaistS SGaist

            Hi and welcome to devnet,

            Might be a silly question but after building the module, did you install it ?

            R Offline
            R Offline
            Rasmunis
            wrote on last edited by
            #5

            @SGaist Thank you :)

            If I understand you correctly, yes. I have been using it for the past couple of months.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Rasmunis
              wrote on last edited by
              #6

              I'll be a bit more concrete. This is what I am attempting:

              Source-code: https://github.com/qt/qtdatavis3d/blob/dev/src/datavisualization/utils/scatterobjectbufferhelper.cpp

              The fullLoad-method is called on every update of the scatter-graph and seems to be handling the buffers. But m_meshDataLoaded is set to false, and is not changed until it is checked for true (which would delete the old buffers). I suspect this might be the cause of the memory leak.

              void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal dotScale)
              {
                  m_meshDataLoaded = false; <-- set to false
                  m_indexCount = 0;
              
                  ObjectHelper *dotObj = cache->object();
                  const ScatterRenderItemArray &renderArray = cache->renderArray();
                  const uint renderArraySize = renderArray.size();
              
                  if (renderArraySize == 0)
                      return;  // No use to go forward
              
                  uint itemCount = 0;
                  QQuaternion seriesRotation(cache->meshRotation());
              
                  if (m_meshDataLoaded) { <-- checked to be true
                      // Delete old data
                      glDeleteBuffers(1, &m_vertexbuffer);
                      glDeleteBuffers(1, &m_uvbuffer);
                      glDeleteBuffers(1, &m_normalbuffer);
                      glDeleteBuffers(1, &m_elementbuffer);
                      m_vertexbuffer = 0;
                      m_uvbuffer = 0;
                      m_normalbuffer = 0;
                      m_elementbuffer = 0;
                  }
                  .
                  .
                  .
              
              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Then I am a bit lost with your question.

                So you successfully built and used the custom version of the module yet it seems that your modifications are not taken into account ?

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

                R 1 Reply Last reply
                0
                • SGaistS SGaist

                  Then I am a bit lost with your question.

                  So you successfully built and used the custom version of the module yet it seems that your modifications are not taken into account ?

                  R Offline
                  R Offline
                  Rasmunis
                  wrote on last edited by
                  #8

                  @SGaist No. I've been using the standard module for two months and now I wanted to change it, so I made some changes and rebuilt it and then my changes are not taken into account.

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

                    Hence my question: did you install your custom built module ? Just building it is not enough.

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

                    R 2 Replies Last reply
                    0
                    • SGaistS SGaist

                      Hence my question: did you install your custom built module ? Just building it is not enough.

                      R Offline
                      R Offline
                      Rasmunis
                      wrote on last edited by
                      #10

                      @SGaist I see. I thought you meant if I had ever installed it. Then no, I did not install it.

                      1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Hence my question: did you install your custom built module ? Just building it is not enough.

                        R Offline
                        R Offline
                        Rasmunis
                        wrote on last edited by
                        #11

                        @SGaist So how do I install it? I have only changed a single line of code, so I just want to sort of "update" the standard module.

                        JonBJ jsulmJ 2 Replies Last reply
                        0
                        • R Rasmunis

                          @SGaist So how do I install it? I have only changed a single line of code, so I just want to sort of "update" the standard module.

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #12

                          @Rasmunis
                          So you have built it but not installed it anywhere that your application will pick up from. You either need to do a full build and go through the installation process for Qt for building from source, or if you are sure you have built exactly the same version of Qt as you presently have in all its shared libraries you could identify the single shared library (.so or .dll) this source file contributes to and just (temporarily) replace that with your newly compiled version. If you intend to debug-step into your new code, you will also have to ensure that your source file is found by the debugger.

                          1 Reply Last reply
                          2
                          • R Rasmunis

                            @SGaist So how do I install it? I have only changed a single line of code, so I just want to sort of "update" the standard module.

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @Rasmunis said in Debugging a Qt-library:

                            So how do I install it?

                            make install

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

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

                              @JonB you don't need a full Qt build to build one module for the Qt version you are currently using however you are right about making a backup of the files related to the module you are going to hack on if you don't have your own build.

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

                              JonBJ 1 Reply Last reply
                              0
                              • SGaistS SGaist

                                @JonB you don't need a full Qt build to build one module for the Qt version you are currently using however you are right about making a backup of the files related to the module you are going to hack on if you don't have your own build.

                                JonBJ Offline
                                JonBJ Offline
                                JonB
                                wrote on last edited by JonB
                                #15

                                @SGaist said in Debugging a Qt-library:

                                @JonB you don't need a full Qt build to build one module for the Qt version you are currently using

                                Indeed not, but do you wish to guarantee that the user is rebuilding one library against an existing build/system-supplied which is deffo, deffo the same version, compiled in the same way etc.? :) Because I can hear "version mis-match" in the distance... ;)

                                1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @Rasmunis said in Debugging a Qt-library:

                                  So how do I install it?

                                  make install

                                  R Offline
                                  R Offline
                                  Rasmunis
                                  wrote on last edited by Rasmunis
                                  #16

                                  I tried @JonB 's approach and it worked for me. And I did manage to remove the memory-leak, which makes me think that this is a bug in the library. How do you suggest to move forward with this?

                                  @jsulm Where do you execute the make-commands? I have yet to find any makefiles.

                                  Edit: I found the makefile in the build-folder.

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • R Rasmunis

                                    I tried @JonB 's approach and it worked for me. And I did manage to remove the memory-leak, which makes me think that this is a bug in the library. How do you suggest to move forward with this?

                                    @jsulm Where do you execute the make-commands? I have yet to find any makefiles.

                                    Edit: I found the makefile in the build-folder.

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by jsulm
                                    #17

                                    @Rasmunis said in Debugging a Qt-library:

                                    How do you suggest to move forward with this?

                                    File a bug in Qt bug tracker: https://bugreports.qt.io/projects/QTBUG/issues

                                    "Where do you execute the make-commands?" - where you build Qt.

                                    configure ...
                                    make
                                    make install
                                    

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

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

                                      After the bug report, since you have a fix, you can submit a patch for inclusion :-)

                                      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
                                      2

                                      • Login

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