Commit 8393c22f authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Fixes BUG #15645.

The reported issue was arising because of the fact the pqSpinBox would
fire editingFinished() event when it is disabled while it had the focus.
Since disabling a widget makes it loose the focus, it would fire the
editingFinished() signal. pqAnimationTimeWidget was observing that
signal and then trying to change the time on a non-existant TimeKeeper
proxy and hence the segfault.

The fix extends pqSpinBox to add new signal
valueChangedAndEditingFinished (similar in spirit to what we do with
pqLineEdit) to limit the overzealous firing of editingFinished() signal.
That addresses the reported segfault.
parent ba5a4bbe
......@@ -105,7 +105,7 @@ pqAnimationTimeWidget::pqAnimationTimeWidget(QWidget* parentObject)
this->connect(ui.timeValue, SIGNAL(textChangedAndEditingFinished()), SIGNAL(timeValueChanged()));
this->connect(ui.radioButtonValue, SIGNAL(toggled(bool)), SIGNAL(playModeChanged()));
this->connect(ui.radioButtonValue, SIGNAL(toggled(bool)), SLOT(updateTimestepCountLabelVisibility()));
this->connect(ui.timestepValue, SIGNAL(editingFinished()),
this->connect(ui.timestepValue, SIGNAL(valueChangedAndEditingFinished()),
SLOT(timestepValueChanged()));
}
......
/*=========================================================================
Program: ParaView
Module: pqSpinBox.cxx
Module: pqSpinBox.cxx
Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
......@@ -32,8 +32,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqSpinBox.h"
//-----------------------------------------------------------------------------
pqSpinBox::pqSpinBox(QWidget* _parent) : QSpinBox(_parent)
pqSpinBox::pqSpinBox(QWidget* _parent) : Superclass(_parent),
EditingFinishedPending(false)
{
this->connect(this, SIGNAL(editingFinished()), SLOT(onEditingFinished()));
this->connect(this, SIGNAL(valueChanged(int)), SLOT(onValueEdited()));
}
//-----------------------------------------------------------------------------
......@@ -47,3 +50,19 @@ void pqSpinBox::stepBy(int steps)
emit this->editingFinished();
}
}
//-----------------------------------------------------------------------------
void pqSpinBox::onValueEdited()
{
this->EditingFinishedPending = true;
}
//-----------------------------------------------------------------------------
void pqSpinBox::onEditingFinished()
{
if (this->EditingFinishedPending)
{
emit this->valueChangedAndEditingFinished();
this->EditingFinishedPending = false;
}
}
/*=========================================================================
Program: ParaView
Module: pqSpinBox.h
Module: pqSpinBox.h
Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
......@@ -29,14 +29,17 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef __pqSpinBox_h
#define __pqSpinBox_h
#ifndef pqSpinBox_h
#define pqSpinBox_h
#include <QSpinBox>
#include "pqWidgetsModule.h"
/// QSpinBox which fires editingFinished() signal when the value is changed
/// by steps (increments).
/// Also, this adds a new signal valueChangedAndEditingFinished() which is fired
/// after editingFinished() signal is fired and the value in the spin box indeed
/// changed.
class PQWIDGETS_EXPORT pqSpinBox : public QSpinBox
{
Q_OBJECT
......@@ -48,11 +51,21 @@ public:
/// overridding this so that we can emit editingFinished() signal
virtual void stepBy(int steps);
signals:
/// Unlike QSpinBox::editingFinished() which gets fired whenever the widget
/// looses focus irrespective of if the value was indeed edited,
/// valueChangedAndEditingFinished() is fired only when the value was changed
/// as well.
void valueChangedAndEditingFinished();
private slots:
void onValueEdited();
void onEditingFinished();
private:
pqSpinBox(const pqSpinBox&); // Not implemented.
void operator=(const pqSpinBox&); // Not implemented.
bool EditingFinishedPending;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment