[Scummvm-cvs-logs] scummvm master -> 023fedef48dd3c1fa40ddf2247900bc65ad91671
lordhoto
lordhoto at gmail.com
Wed Oct 2 00:18:29 CEST 2013
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
45e7ba130e GUI: Fix compilation with clang and C++11.
6ace85a84d GUI: Clean up calloc use in PredictiveDialog.
225a823555 GUI: Initialize PredictiveDialog::_predictiveResult.
023fedef48 GUI: Do not return current input on cancel in PredictiveDialog.
Commit: 45e7ba130e8dff1dc4545af8bce89d05baf79f96
https://github.com/scummvm/scummvm/commit/45e7ba130e8dff1dc4545af8bce89d05baf79f96
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-10-01T15:16:59-07:00
Commit Message:
GUI: Fix compilation with clang and C++11.
newDictLine is allocated with calloc in line 856 thus there is no need to
initialize any entry.
Changed paths:
gui/predictivedialog.cpp
diff --git a/gui/predictivedialog.cpp b/gui/predictivedialog.cpp
index 5ce093e..c7d04e4 100644
--- a/gui/predictivedialog.cpp
+++ b/gui/predictivedialog.cpp
@@ -861,7 +861,6 @@ void PredictiveDialog::addWord(Dict &dict, const Common::String &word, const Com
return;
}
- newDictLine[dict.dictLineCount] = '\0';
int k = 0;
bool inserted = false;
Commit: 6ace85a84daca6c15aba1d788348ce8f86692501
https://github.com/scummvm/scummvm/commit/6ace85a84daca6c15aba1d788348ce8f86692501
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-10-01T15:16:59-07:00
Commit Message:
GUI: Clean up calloc use in PredictiveDialog.
Instead of manually multiplying the entry count with the entry size we simply
use both parameters of calloc as intended now.
Changed paths:
gui/predictivedialog.cpp
diff --git a/gui/predictivedialog.cpp b/gui/predictivedialog.cpp
index c7d04e4..c7d2946 100644
--- a/gui/predictivedialog.cpp
+++ b/gui/predictivedialog.cpp
@@ -69,7 +69,7 @@ enum {
PredictiveDialog::PredictiveDialog() : Dialog("Predictive") {
new StaticTextWidget(this, "Predictive.Headline", "Enter Text");
- _btns = (ButtonWidget **)calloc(1, sizeof(ButtonWidget *) * 16);
+ _btns = (ButtonWidget **)calloc(16, sizeof(ButtonWidget *));
_btns[kCancelAct] = new ButtonWidget(this, "Predictive.Cancel", _("Cancel") , 0, kCancelCmd);
_btns[kOkAct] = new ButtonWidget(this, "Predictive.OK", _("Ok") , 0, kOkCmd);
@@ -614,7 +614,7 @@ void PredictiveDialog::handleTickle() {
void PredictiveDialog::mergeDicts() {
_unitedDict.dictLineCount = _predictiveDict.dictLineCount + _userDict.dictLineCount;
- _unitedDict.dictLine = (char **)calloc(1, sizeof(char *) * _unitedDict.dictLineCount);
+ _unitedDict.dictLine = (char **)calloc(_unitedDict.dictLineCount, sizeof(char *));
if (!_unitedDict.dictLine) {
debug("Predictive Dialog: cannot allocate memory for united dic");
@@ -853,7 +853,7 @@ void PredictiveDialog::addWord(Dict &dict, const Common::String &word, const Com
}
// start from here are INSERTING new line to dictionaty ( dict )
- char **newDictLine = (char **)calloc(1, sizeof(char *) * (dict.dictLineCount + 1));
+ char **newDictLine = (char **)calloc(dict.dictLineCount + 1, sizeof(char *));
if (!newDictLine) {
warning("Predictive Dialog: cannot allocate memory for index buffer");
@@ -882,7 +882,7 @@ void PredictiveDialog::addWord(Dict &dict, const Common::String &word, const Com
free(dict.dictLine);
dict.dictLineCount += 1;
- dict.dictLine = (char **)calloc(1, sizeof(char *) * dict.dictLineCount);
+ dict.dictLine = (char **)calloc(dict.dictLineCount, sizeof(char *));
if (!dict.dictLine) {
warning("Predictive Dialog: cannot allocate memory for index buffer");
free(newDictLine);
@@ -934,7 +934,7 @@ void PredictiveDialog::loadDictionary(Common::SeekableReadStream *in, Dict &dict
ptr++;
}
- dict.dictLine = (char **)calloc(1, sizeof(char *) * lines);
+ dict.dictLine = (char **)calloc(lines, sizeof(char *));
if (dict.dictLine == NULL) {
warning("Predictive Dialog: Cannot allocate memory for line index buffer");
return;
Commit: 225a82355504d2c04d1a6b88b6627c445b12e329
https://github.com/scummvm/scummvm/commit/225a82355504d2c04d1a6b88b6627c445b12e329
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-10-01T15:16:59-07:00
Commit Message:
GUI: Initialize PredictiveDialog::_predictiveResult.
This fixes garbage output when canceling the predictive dialog in AGI when
nothing was entered.
Changed paths:
gui/predictivedialog.cpp
diff --git a/gui/predictivedialog.cpp b/gui/predictivedialog.cpp
index c7d2946..41f6b10 100644
--- a/gui/predictivedialog.cpp
+++ b/gui/predictivedialog.cpp
@@ -144,6 +144,7 @@ PredictiveDialog::PredictiveDialog() : Dialog("Predictive") {
_currentWord.clear();
_wordNumber = 0;
_numMatchingWords = 0;
+ memset(_predictiveResult, 0, sizeof(_predictiveResult));
_lastbutton = kNoAct;
_mode = kModePre;
Commit: 023fedef48dd3c1fa40ddf2247900bc65ad91671
https://github.com/scummvm/scummvm/commit/023fedef48dd3c1fa40ddf2247900bc65ad91671
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-10-01T15:16:59-07:00
Commit Message:
GUI: Do not return current input on cancel in PredictiveDialog.
Returning the currently displayed input when you click cancel is confusing
behavior in my eyes.
Changed paths:
gui/predictivedialog.cpp
diff --git a/gui/predictivedialog.cpp b/gui/predictivedialog.cpp
index 41f6b10..ef94ec6 100644
--- a/gui/predictivedialog.cpp
+++ b/gui/predictivedialog.cpp
@@ -421,6 +421,9 @@ void PredictiveDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 d
case kCancelCmd:
saveUserDictToFile();
close();
+ // When we cancel the dialog no result should be returned. Thus, we
+ // will invalidate any result here.
+ _predictiveResult[0] = 0;
return;
case kOkCmd:
_currBtn = kOkAct;
More information about the Scummvm-git-logs
mailing list