@@ -88,9 +88,11 @@ void KsGLWidget::paintGL()
glClear(GL_COLOR_BUFFER_BIT);
+ if (isEmpty())
+ return;
+
/* Draw the time axis. */
- if(_data)
- _drawAxisX(size);
+ _drawAxisX(size);
/* Process and draw all graphs by using the built-in logic. */
_makeGraphs(_cpuList, _taskList);
@@ -127,6 +129,13 @@ void KsGLWidget::reset()
_model.reset();
}
+/** Check if the widget is empty (not showing anything). */
+bool KsGLWidget::isEmpty() const {
+ return !_data ||
+ !_data->size() ||
+ (!_cpuList.size() && !_taskList.size());
+}
+
/** Reimplemented event handler used to receive mouse press events. */
void KsGLWidget::mousePressEvent(QMouseEvent *event)
{
@@ -198,6 +207,9 @@ void KsGLWidget::mouseMoveEvent(QMouseEvent *event)
size_t row;
bool ret;
+ if (isEmpty())
+ return;
+
if (_rubberBand.isVisible())
_rangeBoundStretched(_posInRange(event->pos().x()));
@@ -224,6 +236,9 @@ void KsGLWidget::mouseMoveEvent(QMouseEvent *event)
/** Reimplemented event handler used to receive mouse release events. */
void KsGLWidget::mouseReleaseEvent(QMouseEvent *event)
{
+ if (isEmpty())
+ return;
+
if (event->button() == Qt::LeftButton) {
size_t posMouseRel = _posInRange(event->pos().x());
int min, max;
@@ -251,6 +266,9 @@ void KsGLWidget::wheelEvent(QWheelEvent * event)
{
int zoomFocus;
+ if (isEmpty())
+ return;
+
if (_mState->activeMarker()._isSet &&
_mState->activeMarker().isVisible()) {
/*
@@ -41,6 +41,8 @@ public:
void reset();
+ bool isEmpty() const;
+
/** Reprocess all graphs. */
void update() {resizeGL(width(), height());}
@@ -234,6 +234,9 @@ void KsTraceGraph::_zoomOut()
void KsTraceGraph::_quickZoomIn()
{
+ if (_glWindow.isEmpty())
+ return;
+
/* Bin size will be 100 ns. */
_glWindow.model()->quickZoomIn(100);
if (_mState->activeMarker()._isSet &&
@@ -249,6 +252,9 @@ void KsTraceGraph::_quickZoomIn()
void KsTraceGraph::_quickZoomOut()
{
+ if (_glWindow.isEmpty())
+ return;
+
_glWindow.model()->quickZoomOut();
}
@@ -646,6 +652,9 @@ void KsTraceGraph::_updateGraphs(GraphActions action)
double k;
int bin;
+ if (_glWindow.isEmpty())
+ return;
+
/*
* Set the "Key Pressed" flag. The flag will stay set as long as the user
* keeps the corresponding action button pressed.
We want all operations over the graphs (like Zoom or Scroll) to be protected for the case when no data is loaded or no graphs are plotted. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> --- kernel-shark/src/KsGLWidget.cpp | 22 ++++++++++++++++++++-- kernel-shark/src/KsGLWidget.hpp | 2 ++ kernel-shark/src/KsTraceGraph.cpp | 9 +++++++++ 3 files changed, 31 insertions(+), 2 deletions(-)