Debugging a Qt-library
-
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. -
Hi and welcome to devnet,
Might be a silly question but after building the module, did you install it ?
-
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; } . . .
-
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 ?
-
Hence my question: did you install your custom built module ? Just building it is not enough.
-
@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. -
-
@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.
-
@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... ;)
-
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.
-
@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
-
After the bug report, since you have a fix, you can submit a patch for inclusion :-)