Commit 076c9460 authored by Jeremy Whiting's avatar Jeremy Whiting
Browse files

Fix remaining cppcheck issues.

Use initializer list in KHMTheme and add proper 0 size check to
KHangMan::nextWord
parent 0be2d48c
Pipeline #165871 passed with stage
in 1 minute and 42 seconds
......@@ -168,23 +168,26 @@ void KHangMan::readFile()
void KHangMan::nextWord()
{
// If there are no words, there's nothing we can do, trying will crash
if (m_randomList.count() == 0) {
m_originalWord = m_randomList[0].first;
m_hint = m_randomList[0].second;
return;
} else {
m_originalWord = m_randomList[m_randomInt%m_randomList.count()].first;
m_originalWord = m_originalWord.toUpper();
m_hint = m_randomList[m_randomInt%m_randomList.count()].second;
Q_EMIT currentHintChanged();
}
// Not sure why we are doing mod count here, may simplify later to just use m_randomInt
// since the list is already shuffled.
int whichWord = m_randomInt % m_randomList.count();
m_originalWord = m_randomList[whichWord].first;
m_originalWord = m_originalWord.toUpper();
m_hint = m_randomList[whichWord].second;
if (m_originalWord.isEmpty()) {
++m_randomInt;
nextWord();
}
Q_EMIT currentHintChanged();
m_currentWord.clear();
int originalWordSize = m_originalWord.size();
......
......@@ -27,21 +27,21 @@ KHMTheme::KHMTheme( const QString &name, const QString &uiName, const QString &s
QRect wordRect, QRect hintRect, QRect kRect,
QColor letterColor, QColor guessButtonTextColor, QColor guessButtonColor, QColor guessButtonHoverColor, QColor letterInputTextColor,
QPoint goodWordPos)
:KHMname(name),
KHMuiName(uiName),
KHMsvgFileName(svgFileName),
KHMauthor(author),
KHMthemeVersion(themeVersion),
KHMwordRect(wordRect),
KHMhintRect(hintRect),
KHMkRect(kRect),
KHMletterColor(letterColor),
KHMguessButtonTextColor(guessButtonTextColor),
KHMguessButtonColor(guessButtonColor),
KHMguessButtonHoverColor(guessButtonHoverColor),
KHMletterInputTextColor(letterInputTextColor),
KHMgoodWordPos(goodWordPos)
{
KHMname=name;
KHMuiName=uiName;
KHMsvgFileName=svgFileName;
KHMauthor=author;
KHMthemeVersion=themeVersion;
KHMwordRect=wordRect;
KHMhintRect=hintRect;
KHMkRect=kRect;
KHMletterColor=letterColor;
KHMguessButtonTextColor=guessButtonTextColor;
KHMguessButtonColor=guessButtonColor;
KHMguessButtonHoverColor=guessButtonHoverColor;
KHMletterInputTextColor=letterInputTextColor;
KHMgoodWordPos=goodWordPos;
}
QString KHMTheme::name()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment