only call QList::constFirst when history list isn't empty

This commit is contained in:
humbletim 2017-07-23 14:11:59 -04:00
parent 9c610f52ec
commit 300b926464

View file

@ -122,7 +122,7 @@ void JSConsole::setScriptEngine(ScriptEngine* scriptEngine) {
}
void JSConsole::executeCommand(const QString& command) {
if (_commandHistory.constFirst() != command) {
if (_commandHistory.isEmpty() || _commandHistory.constFirst() != command) {
_commandHistory.prepend(command);
if (_commandHistory.length() > MAX_HISTORY_SIZE) {
_commandHistory.removeLast();