PDA

View Full Version : What to explicitely delete in qwt



hkhauke
27th November 2013, 19:44
Hi,
I use qwt to draw some plots. The widget in which I use qwt is loaded as a DLL. Everything works fine until I unload and reload the DLL.
My feeling is that some of the allocated classes used in qwt are not propperly deleted by my code when i unload the DLL but nevertheless
registered somewhere else in QT. This leads to a problem if the internal data structures in QT are refreshed (this is my guess..).

So, which classes require explicit deallocation and which do not? In QT, I understood that widgets are deleted if they have a parent the moment the parent is deleted.
In Qwt, I allocate QwtPlotCurve and attach it to the QwtPlot by using attach - does this means that QwtPlotCurve is deleted if I delete QwtPlot?
Maybe there is a general rule which I have missed?

Thank you and best regards

Hauke

Maximus2
28th November 2013, 14:29
I was going to post the same question.

Right now I use std::unique_ptr because I don't know if the memory is managed when you use .attach()

Example:

QwtPlotGrid *grid = new QwtPlotGrid();
grid->setPen( Qt::gray, 0.0, Qt::DotLine );
grid->enableX( true );
grid->enableXMin( true );
grid->enableY( true );
grid->enableYMin( false );
grid->attach( this ); //will grid pointer be deleted also?

In the qwt examples, it seems .attach does the memory management, because I see no delete whatsoever in the code.
let see if we can get a confirm, it's not in the .attach documentation

Uwe
28th November 2013, 15:35
See: http://qwt.sourceforge.net/class_qwt_plot_dict.html. QwtPlot is derived from QwtPlotDict.

Uwe

Maximus2
28th November 2013, 17:18
Thanks Uwe, I'll clean up my code and use raw pointers

By the way, I don't know why Qwt isn't part of Qt framework by default? I've been using it a lot recently and it's really good!
for example QwtSystemClock just saved my life as a reliable timer (on win and mac)

Uwe
28th November 2013, 19:32
By the way, I don't know why Qwt isn't part of Qt framework by default?
I was thinking about transfering Qwt into a Qt module, when Qt project has been started. But in the end I would end up in a development environment that is made for a large community project, that doesn't fit for my situation. Beside this I would have had to give the copyright to Nokia - today to Digia, that is trying to establish its commercial chart package.


QwtSystemClock just saved my life as a reliable timer (on win and mac)
Note that since Qt 4.8 QElapsedTimer is available and QwtSystemClock can be completely replaced ( internally it is using QElapsedTimer, when build for Qt >= 4.8 ).

Uwe

Maximus2
28th November 2013, 21:52
I didn't know about QElapsedTimer, does it also use the appropriate QWT_HIGH_RESOLUTION_CLOCK depending on the OS? Anyway i'll stick to QwtSystemClock it's easy to use and does the job

All I could say is thank you for Qwt and keeping it open! Good choice you made.
I will use Qwt in a free and commercial application and hopefully can give you guys back when it's up and running.
Cheers

hkhauke
2nd December 2013, 12:28
Hi,

thank you for your answers and the discussion. In the meantime, I found out that my problem is caused by another issue.
I will give the forum another post addressing that new problem.

Best regards

Hauke