From 415ab22fa20ca271bbd23ef8e7e708bf94a281e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 21 Apr 2017 16:13:01 +0200 Subject: [PATCH] [apps/hardware_test] Fix bug: overwriting wrong memory space Change-Id: Ie29e657d91ddef78ecf7c0d75f1eac937bb8213f --- apps/empty_battery_window.cpp | 2 +- apps/hardware_test/keyboard_view.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/empty_battery_window.cpp b/apps/empty_battery_window.cpp index 645c81566..ec35f54dd 100644 --- a/apps/empty_battery_window.cpp +++ b/apps/empty_battery_window.cpp @@ -1,6 +1,6 @@ #include "empty_battery_window.h" -#include "i18n.h" #include "global_preferences.h" +#include "i18n.h" extern "C" { #include } diff --git a/apps/hardware_test/keyboard_view.cpp b/apps/hardware_test/keyboard_view.cpp index a502e030f..e1d597dc7 100644 --- a/apps/hardware_test/keyboard_view.cpp +++ b/apps/hardware_test/keyboard_view.cpp @@ -21,13 +21,17 @@ Ion::Keyboard::Key KeyboardView::testedKey() const { } void KeyboardView::setDefectiveKey(Ion::Keyboard::Key key) { - m_defectiveKey[(int)key] = 1; + int keyIndex = (int)key; + if (keyIndex < Ion::Keyboard::NumberOfKeys && keyIndex >= 0) { + m_defectiveKey[(int)key] = 1; + } } bool KeyboardView::setNextKey() { m_testedKey = (Ion::Keyboard::Key)((int)m_testedKey+1); int keyIndex = (int)m_testedKey; - if (keyIndex >= 54) { + if (keyIndex == 55) { + resetTestedKey(); return false; } if ((keyIndex > 7 && keyIndex < 12) || keyIndex == 35 || keyIndex == 41 || keyIndex == 47 || keyIndex == 53) {