mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Fix duplicate signals emitted by QgsDateTimeEdit when changed
This commit is contained in:
parent
0a5ddb3cea
commit
983a3d8655
@ -149,6 +149,7 @@ Signal emitted whenever the value changes.
|
||||
QgsDateTimeEdit( const QVariant &var, QVariant::Type parserType, QWidget *parent );
|
||||
|
||||
|
||||
|
||||
void displayNull( bool updateCalendar = false );
|
||||
%Docstring
|
||||
write the null value representation to the line edit without changing the value
|
||||
|
@ -220,7 +220,8 @@ void QgsDateTimeEdit::changed( const QVariant &dateTime )
|
||||
}
|
||||
|
||||
mClearAction->setVisible( mAllowNull && !mIsNull );
|
||||
emitValueChanged( dateTime );
|
||||
if ( !mBlockChangedSignal )
|
||||
emitValueChanged( dateTime );
|
||||
}
|
||||
|
||||
QString QgsDateTimeEdit::nullRepresentation() const
|
||||
@ -309,7 +310,10 @@ void QgsDateTimeEdit::setDateTime( const QDateTime &dateTime )
|
||||
// Check if it's really changed or crash, see GH #29937
|
||||
else if ( dateTime != QgsDateTimeEdit::dateTime() )
|
||||
{
|
||||
// changed emits a signal, so don't allow it to be emitted from setDateTime
|
||||
mBlockChangedSignal++;
|
||||
QDateTimeEdit::setDateTime( dateTime );
|
||||
mBlockChangedSignal--;
|
||||
changed( dateTime );
|
||||
}
|
||||
}
|
||||
@ -374,7 +378,10 @@ void QgsTimeEdit::setTime( const QTime &time )
|
||||
// Check if it's really changed or crash, see GH #29937
|
||||
else if ( time != QgsTimeEdit::time() )
|
||||
{
|
||||
// changed emits a signal, so don't allow it to be emitted from setTime
|
||||
mBlockChangedSignal++;
|
||||
QDateTimeEdit::setTime( time );
|
||||
mBlockChangedSignal--;
|
||||
changed( time );
|
||||
}
|
||||
}
|
||||
@ -408,7 +415,10 @@ void QgsDateEdit::setDate( const QDate &date )
|
||||
// Check if it's really changed or crash, see GH #29937
|
||||
else if ( date != QgsDateEdit::date() )
|
||||
{
|
||||
// changed emits a signal, so don't allow it to be emitted from setDate
|
||||
mBlockChangedSignal++;
|
||||
QDateTimeEdit::setDate( date );
|
||||
mBlockChangedSignal--;
|
||||
changed( date );
|
||||
}
|
||||
}
|
||||
|
@ -135,6 +135,9 @@ class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit
|
||||
//! TRUE if the widget is empty
|
||||
bool mIsEmpty = false;
|
||||
|
||||
//! Block change signals if TRUE
|
||||
int mBlockChangedSignal = 0;
|
||||
|
||||
/**
|
||||
* write the null value representation to the line edit without changing the value
|
||||
* \param updateCalendar Flag if calendar is open and minimum date needs to be set
|
||||
|
Loading…
x
Reference in New Issue
Block a user