Plot Picker Cuases Application to Crash
I have a simple application that uses a qwt_plot containing a qwt_plot_picker.
I am using the plot picker to select a polygon from the plot.
Moving the mouse arround on the plot cause's a large number of page faults.
After a length of time the application ASSERTS in qpaintengine_raster.cpp 4106, this seems to be caused by not enough memory (the HDC that is being passed is NULL).
An interesting observation is that this ONLY crashes under qt 4.4.0 even though under both qt version's (there is no crash under 4.3.1) the qwt_plot_picker causes an equal number of page faults.
Bellow is the code that i am using
Regards,
Ben
Code:
///GraphWidget.cpp
#include "GraphWidget.hpp"
#include <qwt_legend.h>
#include <qwt_plot_layout.h>
GraphWidget
::GraphWidget(QWidget *parent
): dataPicker_(canvas())
{
//Setup data picker (polygon data filter)
dataPicker_.
setTrackerMode(QwtPicker::ActiveOnly);
dataPicker_.
setSelectionFlags(QwtPicker::PolygonSelection|QwtPicker
::CornerToCorner);
//| QwtPicker::DragSelection);//ClickSelection); dataPicker_.
setRubberBand(QwtPicker::PolygonRubberBand);
dataPicker_.
setRubberBandPen(QPen(QColor(255,
0,
0),
1, Qt
::DashLine));
}
GraphWidget::~GraphWidget()
{
}
///GraphWidget.hpp
#ifndef __GRAPHWIDGET_H__
#define __GRAPHWIDGET_H__
#include <qwt_plot.h>
#include <qwt_plot_grid.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_magnifier.h>
#include <qwt_plot_panner.h>
#include <qwt_symbol.h>
#include <qwt_plot_zoomer.h>
#include <qwt_plot_picker.h>
#include <qwt_polygon.h>
{
Q_OBJECT
public:
~GraphWidget();
private:
static const int penWidth = 0.5;
private:
};
#endif // GRAPHWIDGET_H
//MainWindow.cpp
#include "MainWindow.hpp"
#include <QFileDialog>
MainWindow
::MainWindow(QWidget *parent
):{
ui_.setupUi(this);
setWindowState(Qt::WindowMaximized);
setCentralWidget(&graph_);
}
MainWindow::~MainWindow()
{
}
//MainWindow.hpp
#ifndef __MAINWINDOW_HPP__
#define __MAINWINDOW_HPP__
#include "GraphWidget.hpp"
#include <QMainWindow>
#include <QButtonGroup>
#include <QVector>
#include <QPointF>
#include <QSettings>
#include "ui_MainWindow.h"
{
Q_OBJECT
public:
~MainWindow();
private:
Ui::MainWindowClass ui_;
GraphWidget graph_;
};
#endif // __MAINWINDOW_HPP__
//Main.cpp
#include <QMainWindow>
#include <QApplication>
#include <QSettings>
#include "windows.h"
#include "MainWindow.hpp"
void MessageHandler(QtMsgType type, const char *msg) {
DWORD dw;
LPVOID lpMsgBuf;
switch (type)
{
case QtFatalMsg:
fprintf(stderr, "Fatal: %s\n", msg);
dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
break;
}
}
int main(int argc, char** argv)
{
qInstallMsgHandler(MessageHandler);
MainWindow mainWindow;
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
mainWindow.show();
return app.exec();
}