From 0bf28b0b94aa030e5ccf421cdbc709b30abf4216 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 28 Oct 2020 16:47:52 +0100 Subject: [PATCH] [keyboard] Sanity in setCurrentIndex() parameters --- src/modules/keyboard/KeyboardLayoutModel.cpp | 9 ++++++--- src/modules/keyboard/KeyboardLayoutModel.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/keyboard/KeyboardLayoutModel.cpp b/src/modules/keyboard/KeyboardLayoutModel.cpp index 5ecc4ccb1..b8cb892f4 100644 --- a/src/modules/keyboard/KeyboardLayoutModel.cpp +++ b/src/modules/keyboard/KeyboardLayoutModel.cpp @@ -183,15 +183,18 @@ KeyboardLayoutModel::roleNames() const } void -KeyboardLayoutModel::setCurrentIndex( const int& index ) +KeyboardLayoutModel::setCurrentIndex( int index ) { if ( index >= m_layouts.count() || index < 0 ) { return; } - m_currentIndex = index; - emit currentIndexChanged( m_currentIndex ); + if ( m_currentIndex != index ) + { + m_currentIndex = index; + emit currentIndexChanged( m_currentIndex ); + } } int diff --git a/src/modules/keyboard/KeyboardLayoutModel.h b/src/modules/keyboard/KeyboardLayoutModel.h index 3eef595c3..60747da55 100644 --- a/src/modules/keyboard/KeyboardLayoutModel.h +++ b/src/modules/keyboard/KeyboardLayoutModel.h @@ -114,7 +114,7 @@ public: QVariant data( const QModelIndex& index, int role ) const override; - void setCurrentIndex( const int& index ); + void setCurrentIndex( int index ); int currentIndex() const; const QPair< QString, KeyboardGlobal::KeyboardInfo > item( const int& index ) const;