Ormond, Randy | 18 Sep 21:54

QwtPlotCurve deleted with clear() ?

Hello,

It appears that clear() is deleting my QwtPlotCurve pointers, leading to
a segfault when I try to reuse them.  autoDelete() is turned off,
although it's not clear if should matter, because the QwtPlot itself is
not being deleted.

The documentation seems to be telling me that the curves should not be
deleted, just removed from the plot.  But I guess I'm misreading
something.

Should clear() delete the curves?

Thanks,
Randy Ormond

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Uwe Rathmann | 19 Sep 09:25
Picon

Re: QwtPlotCurve deleted with clear() ?

On Thursday 18 September 2008 21:55, Ormond, Randy wrote:

> It appears that clear() is deleting my QwtPlotCurve pointers, leading to
> a segfault when I try to reuse them.  autoDelete() is turned off,
> although it's not clear if should matter, because the QwtPlot itself is
> not being deleted.

Qwt is open source and you are in the comfortable situation to look into the 
code:

void QwtPlot::clear()
{
    detachItems(QwtPlotItem::Rtti_PlotCurve);
    detachItems(QwtPlotItem::Rtti_PlotMarker);
}

void QwtPlotDict::detachItems(int rtti, bool autoDelete)
{
    PrivateData::ItemList list = d_data->itemList;
    QwtPlotItemIterator it = list.begin();
    while ( it != list.end() )
    {
        QwtPlotItem *item = *it;

        ++it; // increment before removing item from the list

        if ( rtti == QwtPlotItem::Rtti_PlotItem || item->rtti() == rtti )
        {
            item->attach(NULL);
            if ( autoDelete )
(Continue reading)

Ormond, Randy | 22 Sep 21:19

RE: QwtPlotCurve deleted with clear() ?

Dear Uwe,

I apologize for my ignorance but I really am trying to understand.

QwtPLot::clear calls QwtPlotDict::detachItems with only the first
argument.  Tha means inside detachItems, autoDelete defaults to true and
the items are deleted.  So the curve will be deleted.  Am I misreading
something.

I would be extremely grateful for any help you can give me.

Sincerely,
Randy

-----Original Message-----
From: qwt-interest-bounces <at> lists.sourceforge.net
[mailto:qwt-interest-bounces <at> lists.sourceforge.net] On Behalf Of Uwe
Rathmann
Sent: Friday, September 19, 2008 2:26 AM
To: List for both Qwt users and developers
Subject: Re: QwtPlotCurve deleted with clear() ?

On Thursday 18 September 2008 21:55, Ormond, Randy wrote:

> It appears that clear() is deleting my QwtPlotCurve pointers, leading
to
> a segfault when I try to reuse them.  autoDelete() is turned off,
> although it's not clear if should matter, because the QwtPlot itself
is
> not being deleted.
(Continue reading)

Uwe Rathmann | 22 Sep 22:56
Picon

Re: QwtPlotCurve deleted with clear() ?

On Monday 22 September 2008 21:19, Ormond, Randy wrote:

> QwtPLot::clear calls QwtPlotDict::detachItems with only the first
> argument.  Tha means inside detachItems, autoDelete defaults to true and
> the items are deleted.  So the curve will be deleted.  

Yes, of course.

> I would be extremely grateful for any help you can give me.

If you want to detach your curves without deleting them use 
QwtPlotDict::detachItems(QwtPlotItem::Rtti_PlotCurve, false). 

QwtPlot::clear is left from Qwt 0.0.1 where only curves and markers were 
available. The only reason why it is still there is because of compatibility. 
QwtPlotDict::detachItems() is the recommended API since Qwt 5.x.

Uwe

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Ormond, Randy | 23 Sep 14:42

RE: QwtPlotCurve deleted with clear() ?

Dear Uwe,

Perfect solution!  Thank you very much!  And thanks for Qwt.

Randy

-----Original Message-----
From: Uwe Rathmann [mailto:Uwe.Rathmann <at> tigertal.de] 
Sent: Monday, September 22, 2008 3:56 PM
To: List for both Qwt users and developers
Subject: Re: QwtPlotCurve deleted with clear() ?

On Monday 22 September 2008 21:19, Ormond, Randy wrote:

> QwtPLot::clear calls QwtPlotDict::detachItems with only the first
> argument.  Tha means inside detachItems, autoDelete defaults to true
and
> the items are deleted.  So the curve will be deleted.  

Yes, of course.

> I would be extremely grateful for any help you can give me.

If you want to detach your curves without deleting them use 
QwtPlotDict::detachItems(QwtPlotItem::Rtti_PlotCurve, false). 

QwtPlot::clear is left from Qwt 0.0.1 where only curves and markers were

available. The only reason why it is still there is because of
compatibility. 
(Continue reading)


Gmane