From 004c1504953eca8b109c7eda8b8c817604470d3b Mon Sep 17 00:00:00 2001 From: Noah Brecht Date: Thu, 11 Apr 2019 21:46:27 -0400 Subject: [PATCH 1/4] Don't try to connect to controllers that don't exist --- src/core/ControllerConnection.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/ControllerConnection.cpp b/src/core/ControllerConnection.cpp index 45e36e12fc0..32f70e84566 100644 --- a/src/core/ControllerConnection.cpp +++ b/src/core/ControllerConnection.cpp @@ -211,10 +211,12 @@ void ControllerConnection::loadSettings( const QDomElement & _this ) m_controllerId = -1; } - if (!Engine::getSong()->isLoadingProject() && m_controllerId != -1) + if (!Engine::getSong()->isLoadingProject() + && m_controllerId != -1 + && m_controllerId < Engine::getSong()->controllers().size()) { setController( Engine::getSong()-> - controllers().at( m_controllerId ) ); + controllers().at( m_controllerId ) ); } else { @@ -228,7 +230,3 @@ void ControllerConnection::deleteConnection() { delete this; } - - - - From 0c1c4e1c8b7ae8aa12ef0efd8dbd254c91ae72df Mon Sep 17 00:00:00 2001 From: Noah Brecht Date: Thu, 11 Apr 2019 22:21:28 -0400 Subject: [PATCH 2/4] Code formatting fixes --- src/core/ControllerConnection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ControllerConnection.cpp b/src/core/ControllerConnection.cpp index 32f70e84566..9211449aa79 100644 --- a/src/core/ControllerConnection.cpp +++ b/src/core/ControllerConnection.cpp @@ -211,9 +211,9 @@ void ControllerConnection::loadSettings( const QDomElement & _this ) m_controllerId = -1; } - if (!Engine::getSong()->isLoadingProject() + if ( !Engine::getSong()->isLoadingProject() && m_controllerId != -1 - && m_controllerId < Engine::getSong()->controllers().size()) + && m_controllerId < Engine::getSong()->controllers().size() ) { setController( Engine::getSong()-> controllers().at( m_controllerId ) ); From 842a566d859fa1d37eb2eb48aa4370e20e0fe7a7 Mon Sep 17 00:00:00 2001 From: noahb01 Date: Fri, 12 Apr 2019 22:42:24 -0400 Subject: [PATCH 3/4] Move out-of-range check to earlier if-statement --- src/core/ControllerConnection.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/ControllerConnection.cpp b/src/core/ControllerConnection.cpp index 9211449aa79..a8ea38a7ca4 100644 --- a/src/core/ControllerConnection.cpp +++ b/src/core/ControllerConnection.cpp @@ -205,15 +205,13 @@ void ControllerConnection::loadSettings( const QDomElement & _this ) else { m_controllerId = _this.attribute( "id", "-1" ).toInt(); - if( m_controllerId < 0 ) + if( m_controllerId < 0 || m_controllerId >= Engine::getSong()->controllers().size() ) { qWarning( "controller index invalid\n" ); m_controllerId = -1; } - if ( !Engine::getSong()->isLoadingProject() - && m_controllerId != -1 - && m_controllerId < Engine::getSong()->controllers().size() ) + if ( !Engine::getSong()->isLoadingProject() && m_controllerId != -1 ) { setController( Engine::getSong()-> controllers().at( m_controllerId ) ); From c9845092d6bf86d27e891191388e378aa6e33bb7 Mon Sep 17 00:00:00 2001 From: Hyunjin Song Date: Sun, 14 Apr 2019 18:46:14 +0900 Subject: [PATCH 4/4] Revert formatting changes --- src/core/ControllerConnection.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/ControllerConnection.cpp b/src/core/ControllerConnection.cpp index a8ea38a7ca4..4d43a4366c3 100644 --- a/src/core/ControllerConnection.cpp +++ b/src/core/ControllerConnection.cpp @@ -211,10 +211,10 @@ void ControllerConnection::loadSettings( const QDomElement & _this ) m_controllerId = -1; } - if ( !Engine::getSong()->isLoadingProject() && m_controllerId != -1 ) + if (!Engine::getSong()->isLoadingProject() && m_controllerId != -1) { setController( Engine::getSong()-> - controllers().at( m_controllerId ) ); + controllers().at( m_controllerId ) ); } else { @@ -228,3 +228,7 @@ void ControllerConnection::deleteConnection() { delete this; } + + + +