Revision: 1467
http://sourceforge.net/p/scidavis/svn/1467
Author: hpcoder
Date: 2015-01-22 17:39:05 +0000 (Thu, 22 Jan 2015)
Log Message:
-----------
Added guards around emitting events from the Keypress filter. For
ticket #196
Modified Paths:
--------------
branches/development/libscidavis/src/DataPickerTool.cpp
Modified: branches/development/libscidavis/src/DataPickerTool.cpp
===================================================================
--- branches/development/libscidavis/src/DataPickerTool.cpp 2015-01-21 06:39:51 UTC (rev 1466)
+++ branches/development/libscidavis/src/DataPickerTool.cpp 2015-01-22 17:39:05 UTC (rev 1467)
@@ -189,56 +189,63 @@
switch(ke->key()) {
case Qt::Key_Enter:
case Qt::Key_Return:
- emit selected(d_selected_curve, d_selected_point);
- return true;
+ if (d_selected_curve)
+ emit selected(d_selected_curve, d_selected_point);
+ return true;
case Qt::Key_Up:
- {
- int n_curves = d_graph->curves();
- int start = d_graph->curveIndex(d_selected_curve) + 1;
- QwtPlotCurve *c;
- for (int i = start; i < start + n_curves; ++i)
- if ((c=d_graph->curve(i % n_curves))->dataSize() > 0) {
- setSelection(c, qMin(c->dataSize()-1, d_selected_point));
- break;
- }
- d_graph->plotWidget()->replot();
- return true;
- }
+ if (d_graph && d_selected_curve)
+ {
+ int n_curves = d_graph->curves();
+ int start = d_graph->curveIndex(d_selected_curve) + 1;
+ QwtPlotCurve *c;
+ for (int i = start; i < start + n_curves; ++i)
+ if ((c=d_graph->curve(i % n_curves))->dataSize() > 0) {
+ setSelection(c, qMin(c->dataSize()-1, d_selected_point));
+ break;
+ }
+ d_graph->plotWidget()->replot();
+ }
+ return true;
case Qt::Key_Down:
- {
- int n_curves = d_graph->curves();
- int start = d_graph->curveIndex(d_selected_curve) + n_curves - 1;
- QwtPlotCurve *c;
- for (int i = start; i > start - n_curves; --i)
- if ((c=d_graph->curve(i % n_curves))->dataSize() > 0) {
- setSelection(c, qMin(c->dataSize()-1, d_selected_point));
- break;
+ if (d_graph && d_selected_curve)
+ {
+ int n_curves = d_graph->curves();
+ int start = d_graph->curveIndex(d_selected_curve) + n_curves - 1;
+ QwtPlotCurve *c;
+ for (int i = start; i > start - n_curves; --i)
+ if ((c=d_graph->curve(i % n_curves))->dataSize() > 0) {
+ setSelection(c, qMin(c->dataSize()-1, d_selected_point));
+ break;
}
- d_graph->plotWidget()->replot();
- return true;
- }
+ d_graph->plotWidget()->replot();
+ }
+ return true;
case Qt::Key_Right:
case Qt::Key_Plus:
- if (d_selected_curve) {
- int n_points = d_selected_curve->dataSize();
- setSelection(d_selected_curve, (d_selected_point + 1) % n_points);
- d_graph->plotWidget()->replot();
- } else
- setSelection(d_graph->curve(0), 0);
- return true;
+ if (d_graph)
+ if (d_selected_curve) {
+ int n_points = d_selected_curve->dataSize();
+ setSelection(d_selected_curve, (d_selected_point + 1) % n_points);
+ d_graph->plotWidget()->replot();
+ }
+ else
+ setSelection(d_graph->curve(0), 0);
+ return true;
case Qt::Key_Left:
case Qt::Key_Minus:
- if (d_selected_curve) {
- int n_points = d_selected_curve->dataSize();
- setSelection(d_selected_curve, (d_selected_point - 1 + n_points) % n_points);
- d_graph->plotWidget()->replot();
- } else
- setSelection(d_graph->curve(d_graph->curves()-1), 0);
- return true;
+ if (d_graph)
+ if (d_selected_curve) {
+ int n_points = d_selected_curve->dataSize();
+ setSelection(d_selected_curve, (d_selected_point - 1 + n_points) % n_points);
+ d_graph->plotWidget()->replot();
+ }
+ else
+ setSelection(d_graph->curve(d_graph->curves()-1), 0);
+ return true;
// The following keys represent a direction, they are
// organized on the keyboard.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|