From 437f60dbd4b12cd45ced391561d09cd5b0e780dc Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 Dec 2019 11:50:02 +0100 Subject: [PATCH] NDK/Console: Fix crash on empty history --- ChangeLog.md | 1 + SDK/src/NDK/Console.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 00f8b937a..60301df41 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -304,6 +304,7 @@ Nazara Development Kit: - Fixed PhysicsComponent2D copy not copying physics attributes - Added Entity::DropComponent which detaches a component without necessarily destroying it - ⚠ ConstraintComponent2D has been reworked to handle entity destruction and remove constraints at will +- Fixed crash when pressing up/down key with no history in the console # 0.4: diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 67f3e69b2..20a004f25 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -81,6 +81,9 @@ namespace Ndk { *ignoreDefaultAction = true; + if (m_commandHistory.empty()) + return; + if (m_historyPosition > 0) m_historyPosition--; @@ -91,6 +94,9 @@ namespace Ndk { *ignoreDefaultAction = true; + if (m_commandHistory.empty()) + return; + if (++m_historyPosition >= m_commandHistory.size()) m_historyPosition = 0;