Results 1 to 2 of 2

Thread: Heap corruption in QwtPolarGrid::updateScaleDiv

  1. #1
    Join Date
    Apr 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Heap corruption in QwtPolarGrid::updateScaleDiv

    This post is aimed at Uwe, I hope this may sound familiar or flag up something I have set up incorrectly:

    I have an issue (Invalid address specified to RtlFreeHeap) that only seems to show up in release builds (on windows). I am seeing very repeatable heap corruption whenever I enable more than a single axis in my subclass of QwtPolarPlot.

    edit: in fact this is an issue whenever I use even a single axis which is not AxisAzimuth

    e.g. here is my constructor for my subclass. As you can see below it is a slightly modified version of one of the polardemo example, removing some of the setup. I have my own member interval classes instead of having them declared outside the class as in the example, but otherwise it is pretty similar.

    The last readable code I have in my stack trace is axis.scaleDraw->setScaleDiv( sd ); in qwt_polar_grid.cpp.

    Does this ring a bell at all regarding double frees or mismatch between delete and free, for example? Obviously I am not adding curves until after I initialise the plot, unlike the example this was taken from, but if I turn on the axes after adding the curve I still have the same problem.

    Any thoughts would be very well received - this gets through Dr Memory (-light) OK on debug and release. I am using qwtpolar 1.1.1, qt 4.7.1 and Qwt 6.1.0. Qt and Qwt are both shared libraries; I have tried qwtpolar as both shared and static library and get the same error.

    Qt Code:
    1. class PolarPlot: public QwtPolarPlot
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. PolarPlot( QString name, QWidget * = NULL );
    7. void add_curve(QString name, PolarCurve * curve);
    8. //void update_curve(QString name, double * r, double *t);
    9. virtual void replot();
    10. private:
    11.  
    12. QwtPolarGrid *d_grid;
    13. QwtInterval _radialInterval;
    14. QwtInterval _azimuthInterval;
    15.  
    16. };
    17.  
    18. PolarPlot::PolarPlot( QString name, QWidget *parent ):
    19. QwtPolarPlot( QwtText( name ), parent )
    20. {
    21. setAutoReplot( false );
    22.  
    23. setPlotBackground( QColor("#ffffb3"));
    24.  
    25. _radialInterval.setMinValue(0);
    26. _radialInterval.setMaxValue(360.0);
    27. _azimuthInterval.setMinValue(0);
    28. _azimuthInterval.setMaxValue(360.0);
    29.  
    30. setScale( QwtPolar::ScaleRadius,
    31. _azimuthInterval.minValue(), _azimuthInterval.maxValue(),
    32. _azimuthInterval.width());
    33.  
    34. setScaleMaxMinor( QwtPolar::Azimuth, 2 );
    35. setScale( QwtPolar::ScaleRadius,
    36. _radialInterval.minValue(), _radialInterval.maxValue() );
    37.  
    38. // grids, axes
    39.  
    40. d_grid = new QwtPolarGrid();
    41. d_grid->setPen( QPen(Qt::darkGray) );
    42. for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
    43. {
    44. d_grid->showGrid( scaleId );
    45. d_grid->showMinorGrid( scaleId );
    46.  
    47. QPen minorPen( Qt::gray );
    48. d_grid->setMinorGridPen( scaleId, minorPen );
    49. }
    50. d_grid->setAxisPen( QwtPolar::AxisAzimuth, QPen( Qt::black ) );
    51. d_grid->setAxisPen( QwtPolar::AxisTop, QPen( Qt::red ) );
    52. d_grid->setAxisPen( QwtPolar::AxisRight, QPen( Qt::black ) );
    53. d_grid->setAxisPen( QwtPolar::AxisLeft, QPen( Qt::black ) );
    54. d_grid->setAxisPen( QwtPolar::AxisBottom, QPen( Qt::black ) );
    55.  
    56.  
    57. d_grid->showAxis( QwtPolar::AxisAzimuth, true);
    58. d_grid->showAxis( QwtPolar::AxisTop, true); // <-unless this and all non azimuth axes are false, I get heap corruption
    59. d_grid->showAxis( QwtPolar::AxisRight, false);
    60. d_grid->showAxis( QwtPolar::AxisLeft, false );
    61. d_grid->showAxis( QwtPolar::AxisBottom, false );
    62.  
    63. d_grid->showGrid( QwtPolar::Azimuth, true);
    64. d_grid->showGrid( QwtPolar::Radius, true );
    65. d_grid->attach( this );
    66.  
    67. // curves
    68.  
    69. /*for ( int curveId = 0; curveId < PlotSettings::NumCurves; curveId++ )
    70.   {
    71.   d_curve[curveId] = createCurve( curveId );
    72.   d_curve[curveId]->attach( this );
    73.   }*/
    74.  
    75. // markers
    76. /*QwtPolarMarker *marker = new QwtPolarMarker();
    77.   marker->setPosition( QwtPointPolar( 57.3, 4.72 ) );
    78.   marker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,
    79.   QBrush( Qt::white ), QPen( Qt::green ), QSize( 9, 9 ) ) );
    80.   marker->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop );
    81.  
    82.   QwtText text( "Marker" );
    83.   text.setColor( Qt::black );
    84.   QColor bg( Qt::white );
    85.   bg.setAlpha( 200 );
    86.   text.setBackgroundBrush( QBrush( bg ) );
    87.  
    88.   marker->setLabel( text );
    89.   marker->attach( this );
    90.  
    91.   QwtLegend *legend = new QwtLegend;
    92.   insertLegend( legend, QwtPolarPlot::BottomLegend );*/
    93. }
    To copy to clipboard, switch view to plain text mode 


    Added after 42 minutes:


    In addition, I also see the same problem if I build the polardemo example myself in visual studio. I am doing this by hand, i.e. adding the source and headers to a new project and setting up as per my other qt projects. I have checked with a dependency walker that the dlls I am using are consistent with what I expect, i.e. the dlls built on this machine from source.
    Last edited by kreyszig; 15th August 2017 at 16:16.

  2. #2
    Join Date
    Apr 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Heap corruption in QwtPolarGrid::updateScaleDiv

    Nevermind. I had rebuilt qwt while trying to sort this out and hadn't moved the new qwt.dll into my path. With this in place it is fine.

Similar Threads

  1. Move QwtPolarGrid to left of screen
    By sampad1370 in forum Qwt
    Replies: 6
    Last Post: 28th March 2016, 08:55
  2. Heap corruption detected
    By yaseminyilmaz in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2012, 12:53
  3. Replies: 1
    Last Post: 30th March 2011, 11:51
  4. Crash: Heap corruption due to selectedRows()
    By Ankitha Varsha in forum Qt Programming
    Replies: 16
    Last Post: 1st October 2010, 00:55
  5. Heap Corruption when calling availablePrinters
    By andyp in forum Qt Programming
    Replies: 0
    Last Post: 20th November 2009, 15:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.