[Scummvm-git-logs] scummvm master -> 3199a5e107d3ba6c89df412669e09253556c7903

sev- sev at scummvm.org
Mon Apr 27 11:57:58 UTC 2020


This automated email contains information about 14 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
81c443c973 GRAPHICS: Add sanity check
742ec2ccaf GRAPHICS: MACGUI: Simplified font management in EdtiableText
430915ce00 GRAPHICS: MACGUI: Const'ness
d9a11fdf76 GRAPHICS: MACGUI: Fix searching for next bigger font in MacFontManager
a968cb9b2b GRAPHICS: MACGUI: More const'ness
06e4a85181 GRPAHICS: Enforced sanity check in 9-patch blitting
2785bdd8c1 GRAPHICS: Fixed potential memory leak in BDF
1ed98269ff GRAPHICS: Use correct data types
47cde2bae5 GRAPHICS: Fixe memory override (!)
dd21ddbe15 GRAPHICS: MACGUI: Plug potential memory leak
b90cf5db81 GRAPHICS: Added sanity check to BDF font scaler
b9a6b99575 GRAPHICS: Added more sanity checks to BDF font loading
c403182353 GRAPHICS: Initialize class variables in VectorRenderer
3199a5e107 GRAPHICS: Properly initialize struct members


Commit: 81c443c97357fbea1e3a9060108c095a45b00560
    https://github.com/scummvm/scummvm/commit/81c443c97357fbea1e3a9060108c095a45b00560
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: Add sanity check

Changed paths:
    graphics/managed_surface.cpp


diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 2075632145..93c0c0312b 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -406,6 +406,8 @@ void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, c
 			} else {
 				// Otherwise we have to manually decode and re-encode each pixel
 				if (srcFormat.bytesPerPixel == 1) {
+					assert(palette != nullptr);	// Catch the cases when palette is missing
+
 					// Get the palette color
 					const uint32 col = palette[srcVal];
 					rSrc = col & 0xff;


Commit: 742ec2ccaf00e5f05d4ca39e2420df6643072817
    https://github.com/scummvm/scummvm/commit/742ec2ccaf00e5f05d4ca39e2420df6643072817
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: MACGUI: Simplified font management in EdtiableText

Changed paths:
    graphics/macgui/maceditabletext.cpp
    graphics/macgui/maceditabletext.h
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/graphics/macgui/maceditabletext.cpp b/graphics/macgui/maceditabletext.cpp
index 0d8a6b0bc5..0e24fbf824 100644
--- a/graphics/macgui/maceditabletext.cpp
+++ b/graphics/macgui/maceditabletext.cpp
@@ -52,7 +52,7 @@ MacEditableText::MacEditableText(MacWidget *parent, int x, int y, int w, int h,
 
 	init();
 
-	_font = macFont;
+	setDefaultFormatting(macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
 }
 
 MacEditableText::MacEditableText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
@@ -62,7 +62,7 @@ MacEditableText::MacEditableText(MacWidget *parent, int x, int y, int w, int h,
 
 	init();
 
-	_font = macFont;
+	setDefaultFormatting(macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
 }
 
 void MacEditableText::init() {
@@ -127,7 +127,7 @@ void MacEditableText::resize(int w, int h) {
 }
 
 void MacEditableText::appendText(Common::U32String str, const MacFont *macFont, bool skipAdd) {
-	MacText::appendText(str, macFont->getId(), macFont->getSize(), macFont->getSlant(), skipAdd);
+	MacText::appendTextDefault(str, skipAdd);
 
 	_contentIsDirty = true;
 
@@ -151,18 +151,6 @@ void MacEditableText::clearText() {
 	updateCursorPos();
 }
 
-void MacEditableText::setTextFont(const MacFont *font) {
-	_font = font;
-
-	_fontRef = _wm->_fontMan->getFont(*font);
-
-	MacText::setDefaultFormatting(font->getId(), font->getSlant(), font->getSize(), 0, 0, 0);
-}
-
-const MacFont *MacEditableText::getTextFont() {
-	return _font;
-}
-
 bool MacEditableText::draw(bool forceRedraw) {
 	if (!_scrollbarIsDirty && !_contentIsDirty && !_cursorDirty && !_inputIsDirty && !forceRedraw)
 		return false;
@@ -463,14 +451,20 @@ void MacEditableText::drawInput() {
 
 	Common::Array<Common::U32String> text;
 
+	const Font *fontRef = getDefaultFormatting().font;
+
+	if (fontRef == nullptr) {
+		error("MacEditableText::drawInput(): default font is not set");
+	}
+
 	// Now recalc new text height
-	_fontRef->wordWrapText(_inputText, _maxWidth, text);
+	fontRef->wordWrapText(_inputText, _maxWidth, text);
 	_inputTextHeight = MAX((uint)1, text.size()); // We always have line to clean
 
 	// And add new input line to the text
-	appendText(_inputText, _font, true);
+	appendTextDefault(_inputText, true);
 
-	_cursorX = _inputText.empty() ? 0 : _fontRef->getStringWidth(text[_inputTextHeight - 1]);
+	_cursorX = _inputText.empty() ? 0 : fontRef->getStringWidth(text[_inputTextHeight - 1]);
 
 	updateCursorPos();
 
diff --git a/graphics/macgui/maceditabletext.h b/graphics/macgui/maceditabletext.h
index 88573f2813..35e5d11091 100644
--- a/graphics/macgui/maceditabletext.h
+++ b/graphics/macgui/maceditabletext.h
@@ -68,9 +68,6 @@ public:
 	virtual bool draw(bool forceRedraw = false) override;
 	virtual void blit(ManagedSurface *g, Common::Rect &dest) override;
 
-	void setTextFont(const MacFont *macFont);
-	const MacFont *getTextFont();
-
 	virtual void setActive(bool active) override;
 
 	void appendText(Common::U32String str, const MacFont *macFont, bool skipAdd = false);
@@ -122,9 +119,6 @@ public:
 	int _scrollPos;
 
 private:
-	const MacFont *_font;
-	const Font *_fontRef;
-
 	ManagedSurface *_cursorSurface;
 
 	bool _inTextSelection;
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 2d03c1bda6..fce9507878 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -101,7 +101,7 @@ MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *m
 		_defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
 		_defaultFormatting.font = wm->_fontMan->getFont(*macFont);
 	} else {
-		_defaultFormatting.font = NULL;
+		_defaultFormatting.font = nullptr;
 	}
 
 	_defaultFormatting.wm = wm;
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 4d46a7adc1..f190d58ee7 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -106,6 +106,8 @@ public:
 				_defaultFormatting.setValues(_defaultFormatting.wm, fontId_, textSlant_, fontSize_, palinfo1_, palinfo2_, palinfo3_);
 			}
 
+	const MacFontRun &getDefaultFormatting() { return _defaultFormatting; }
+
 	void draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff);
 	void drawToPoint(ManagedSurface *g, Common::Rect srcRect, Common::Point dstPoint);
 	void drawToPoint(ManagedSurface *g, Common::Point dstPoint);


Commit: 430915ce00f98915b8c8d3e12bae90025139806a
    https://github.com/scummvm/scummvm/commit/430915ce00f98915b8c8d3e12bae90025139806a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: MACGUI: Const'ness

Changed paths:
    graphics/macgui/maceditabletext.cpp
    graphics/macgui/maceditabletext.h
    graphics/macgui/mactextwindow.cpp
    graphics/macgui/mactextwindow.h


diff --git a/graphics/macgui/maceditabletext.cpp b/graphics/macgui/maceditabletext.cpp
index 0e24fbf824..1ae6ba0782 100644
--- a/graphics/macgui/maceditabletext.cpp
+++ b/graphics/macgui/maceditabletext.cpp
@@ -45,7 +45,7 @@ enum {
 
 static void cursorTimerHandler(void *refCon);
 
-MacEditableText::MacEditableText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, Common::U32String s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
+MacEditableText::MacEditableText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
 		MacWidget(parent, x, y, w, h, true), MacText(s, wm, macFont, fgcolor, bgcolor, maxWidth, textAlignment, interlinear) {
 
 	_maxWidth = maxWidth;
@@ -126,7 +126,7 @@ void MacEditableText::resize(int w, int h) {
 	MacText::setMaxWidth(_maxWidth);
 }
 
-void MacEditableText::appendText(Common::U32String str, const MacFont *macFont, bool skipAdd) {
+void MacEditableText::appendText(const Common::U32String &str, const MacFont *macFont, bool skipAdd) {
 	MacText::appendTextDefault(str, skipAdd);
 
 	_contentIsDirty = true;
@@ -478,7 +478,7 @@ void MacEditableText::clearInput() {
 	_inputText.clear();
 }
 
-void MacEditableText::appendInput(Common::U32String str) {
+void MacEditableText::appendInput(const Common::U32String &str) {
 	_inputText += str;
 
 	drawInput();
diff --git a/graphics/macgui/maceditabletext.h b/graphics/macgui/maceditabletext.h
index 35e5d11091..93a4fa56e5 100644
--- a/graphics/macgui/maceditabletext.h
+++ b/graphics/macgui/maceditabletext.h
@@ -53,7 +53,7 @@ struct SelectedText {
 
 class MacEditableText : public MacText, public MacWidget {
 public:
-	MacEditableText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, Common::U32String s, const MacFont *font, int fgcolor, int bgcolor,
+	MacEditableText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *font, int fgcolor, int bgcolor,
 			int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0);
 	MacEditableText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *font, int fgcolor, int bgcolor,
 			int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0);
@@ -70,7 +70,7 @@ public:
 
 	virtual void setActive(bool active) override;
 
-	void appendText(Common::U32String str, const MacFont *macFont, bool skipAdd = false);
+	void appendText(const Common::U32String &str, const MacFont *macFont, bool skipAdd = false);
 	void appendText(const Common::String &str, const MacFont *macFont, bool skipAdd = false);
 	void clearText();
 
@@ -79,9 +79,9 @@ public:
 
 	void undrawCursor();
 
-	const Common::U32String getInput() { return _inputText; }
+	const Common::U32String &getInput() { return _inputText; }
 	void clearInput();
-	void appendInput(Common::U32String str);
+	void appendInput(const Common::U32String &str);
 	void appendInput(const Common::String &str);
 
 	Common::U32String getSelection(bool formatted = false, bool newlines = true);
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index d8f9902122..50d4befbe6 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -90,7 +90,7 @@ void MacTextWindow::resize(int w, int h) {
 	_mactext->setMaxWidth(_maxWidth);
 }
 
-void MacTextWindow::appendText(Common::U32String str, const MacFont *macFont, bool skipAdd) {
+void MacTextWindow::appendText(const Common::U32String &str, const MacFont *macFont, bool skipAdd) {
 	_mactext->appendText(str, macFont->getId(), macFont->getSize(), macFont->getSlant(), skipAdd);
 
 	_contentIsDirty = true;
@@ -497,7 +497,7 @@ void MacTextWindow::clearInput() {
 	_inputText.clear();
 }
 
-void MacTextWindow::appendInput(Common::U32String str) {
+void MacTextWindow::appendInput(const Common::U32String &str) {
 	_inputText += str;
 
 	drawInput();
diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h
index 592968e043..fb94d50181 100644
--- a/graphics/macgui/mactextwindow.h
+++ b/graphics/macgui/mactextwindow.h
@@ -62,7 +62,7 @@ public:
 	void setTextWindowFont(const MacFont *macFont);
 	const MacFont *getTextWindowFont();
 
-	void appendText(Common::U32String str, const MacFont *macFont, bool skipAdd = false);
+	void appendText(const Common::U32String &str, const MacFont *macFont, bool skipAdd = false);
 	void appendText(const Common::String &str, const MacFont *macFont, bool skipAdd = false);
 	void clearText();
 
@@ -71,9 +71,9 @@ public:
 
 	void undrawCursor();
 
-	const Common::U32String getInput() { return _inputText; }
+	const Common::U32String &getInput() { return _inputText; }
 	void clearInput();
-	void appendInput(Common::U32String str);
+	void appendInput(const Common::U32String &str);
 	void appendInput(const Common::String &str);
 
 	Common::U32String getSelection(bool formatted = false, bool newlines = true);


Commit: d9a11fdf762d467c30ed6bf9738650ba24f38715
    https://github.com/scummvm/scummvm/commit/d9a11fdf762d467c30ed6bf9738650ba24f38715
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: MACGUI: Fix searching for next bigger font in MacFontManager

Changed paths:
    graphics/macgui/macfontmanager.cpp


diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index 29c786b0a3..6e56849d66 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -461,7 +461,8 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
 			break;
 		}
 
-		if (sizes[i]->getSize() > macFont.getSize() && candidate && sizes[i]->getSize() < candidate->getSize())
+		if ((!candidate && sizes[i]->getSize() > macFont.getSize())
+				|| (candidate && sizes[i]->getSize() < candidate->getSize()))
 			candidate = sizes[i];
 
 		if (sizes[i]->getSize() > maxSize->getSize())


Commit: a968cb9b2b9efe79cafce69ce08fcf074bc407fc
    https://github.com/scummvm/scummvm/commit/a968cb9b2b9efe79cafce69ce08fcf074bc407fc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: MACGUI: More const'ness

Changed paths:
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index fce9507878..2c417e4a60 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -53,7 +53,7 @@ MacText::~MacText() {
 	delete _surface;
 }
 
-MacText::MacText(Common::U32String s, MacWindowManager *wm, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) {
+MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) {
 	_str = s;
 	_wm = wm;
 	_macFont = macFont;
@@ -146,7 +146,7 @@ static const Common::U32String::value_type *readHex(uint16 *res, const Common::U
 // Adds the given string to the end of the last line/chunk
 // while observing the _maxWidth and keeping this chunk's
 // formatting
-void MacText::chopChunk(Common::U32String &str) {
+void MacText::chopChunk(const Common::U32String &str) {
 	int curLine = _textLines.size() - 1;
 	int curChunk = _textLines[curLine].chunks.size() - 1;
 	MacFontRun *chunk = &_textLines[curLine].chunks[curChunk];
@@ -197,7 +197,7 @@ void MacText::chopChunk(Common::U32String &str) {
 	}
 }
 
-void MacText::splitString(Common::U32String &str) {
+void MacText::splitString(const Common::U32String &str) {
 	const Common::U32String::value_type *l = str.c_str();
 
 	D(9, "** splitString(\"%s\")", toPrintable(str.encode()).c_str());
@@ -545,7 +545,7 @@ uint getNewlinesInString(const Common::U32String &str) {
 	return newLines;
 }
 
-void MacText::appendText(Common::U32String str, int fontId, int fontSize, int fontSlant, bool skipAdd) {
+void MacText::appendText(const Common::U32String &str, int fontId, int fontSize, int fontSlant, bool skipAdd) {
 	uint oldLen = _textLines.size();
 
 	MacFontRun fontRun = MacFontRun(_wm, fontId, fontSlant, fontSize, 0, 0, 0);
@@ -567,7 +567,7 @@ void MacText::appendText(const Common::String &str, int fontId, int fontSize, in
 	appendText(Common::U32String(str), fontId, fontSize, fontSlant, skipAdd);
 }
 
-void MacText::appendTextDefault(Common::U32String str, bool skipAdd) {
+void MacText::appendTextDefault(const Common::U32String &str, bool skipAdd) {
 	uint oldLen = _textLines.size();
 
 	_currentFormatting = _defaultFormatting;
@@ -597,7 +597,7 @@ void MacText::clearText() {
 	recalcDims();
 }
 
-void MacText::replaceLastLine(Common::U32String str) {
+void MacText::replaceLastLine(const Common::U32String &str) {
 	int oldLen = MAX<int>(0, _textLines.size() - 1);
 
 	// TODO: Recalc length, adapt to _textLines
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index f190d58ee7..b47d19a2f5 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -91,7 +91,7 @@ class MacText {
 	friend class MacEditableText;
 
 public:
-	MacText(Common::U32String s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor,
+	MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor,
 			int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0);
 	MacText(const Common::String &s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor,
 			int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0);
@@ -111,12 +111,12 @@ public:
 	void draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff);
 	void drawToPoint(ManagedSurface *g, Common::Rect srcRect, Common::Point dstPoint);
 	void drawToPoint(ManagedSurface *g, Common::Point dstPoint);
-	void appendText(Common::U32String str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular, bool skipAdd = false);
+	void appendText(const Common::U32String &str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular, bool skipAdd = false);
 	void appendText(const Common::String &str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular, bool skipAdd = false);
-	void appendTextDefault(Common::U32String str, bool skipAdd = false);
+	void appendTextDefault(const Common::U32String &str, bool skipAdd = false);
 	void appendTextDefault(const Common::String &str, bool skipAdd = false);
 	void clearText();
-	void replaceLastLine(Common::U32String str);
+	void replaceLastLine(const Common::U32String &str);
 	void replaceLastLine(const Common::String &str);
 	void removeLastLine();
 	int getLineCount() { return _textLines.size(); }
@@ -131,8 +131,8 @@ public:
 	Common::U32String getTextChunk(int startRow, int startCol, int endRow, int endCol, bool formatted = false, bool newlines = true);
 
 private:
-	void chopChunk(Common::U32String &str);
-	void splitString(Common::U32String &s);
+	void chopChunk(const Common::U32String &str);
+	void splitString(const Common::U32String &s);
 	void render(int from, int to);
 	void recalcDims();
 	void reallocSurface();


Commit: 06e4a85181383d39a32ab4a97e449647cc6e7c26
    https://github.com/scummvm/scummvm/commit/06e4a85181383d39a32ab4a97e449647cc6e7c26
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRPAHICS: Enforced sanity check in 9-patch blitting

Changed paths:
    graphics/nine_patch.cpp


diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index 429247b4a4..155fc39ea9 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -232,7 +232,7 @@ void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, in
 	/* Handle CLUT8 */
 	if (target.format.bytesPerPixel == 1) {
 		if (!palette)
-			warning("Trying to blit into a surface with 1bpp, you need the palette.");
+			error("NinePatchBitmap::blit(): Trying to blit into a surface with 8bpp, you need a palette.");
 
 		Surface *srf = new Surface();
 		srf->create(target.w, target.h, _bmp->format);


Commit: 2785bdd8c19279565034dc65c6ae4f133fa03dc6
    https://github.com/scummvm/scummvm/commit/2785bdd8c19279565034dc65c6ae4f133fa03dc6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: Fixed potential memory leak in BDF

Changed paths:
    graphics/fonts/bdf.cpp


diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index d901d1bb8c..e73fc7680f 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -252,6 +252,12 @@ byte *loadCharacter(Common::SeekableReadStream &stream, int &encoding, int &adva
 			box.yOffset = yOffset;
 		} else if (line == "BITMAP") {
 			const uint bytesPerRow = (box.width + 7) / 8;
+
+			if (bitmap) {
+				warning("Bdf::loadCharacter(): Double BITMAP definitions");
+				delete[] bitmap;
+			}
+
 			byte *dst = bitmap = new byte[box.height * bytesPerRow];
 
 			for (int y = 0; y < box.height; ++y) {


Commit: 1ed98269ff86ed4edb9bead521cfd8524c55aa34
    https://github.com/scummvm/scummvm/commit/1ed98269ff86ed4edb9bead521cfd8524c55aa34
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: Use correct data types

Changed paths:
    graphics/primitives.cpp


diff --git a/graphics/primitives.cpp b/graphics/primitives.cpp
index fd6c8fb262..ba898ede15 100644
--- a/graphics/primitives.cpp
+++ b/graphics/primitives.cpp
@@ -125,7 +125,7 @@ void drawThickLine2(int x1, int y1, int x2, int y2, int thick, int color, void (
 		/* 2.0.12: Michael Schwartz: divide rather than multiply;
 			  TBB: but watch out for /0! */
 		if (dx != 0 && thick != 0) {
-			double ac_recip = 1/dx * sqrt((double)(dx * dx + dy * dy)); // 1 / cos(atan2((double)dy, (double)dx));
+			double ac_recip = 1.0/dx * sqrt((double)(dx * dx + dy * dy)); // 1 / cos(atan2((double)dy, (double)dx));
 			wid = thick * ac_recip;
 		} else {
 			wid = 1;
@@ -183,7 +183,7 @@ void drawThickLine2(int x1, int y1, int x2, int y2, int thick, int color, void (
 		/* 2.0.12: Michael Schwartz: divide rather than multiply;
 		   TBB: but watch out for /0! */
 		if (dy != 0 && thick != 0) {
-			double as_recip = 1/dy * sqrt((double)(dx * dx + dy * dy)); // 1 / sin(atan2((double)dy, (double)dx));
+			double as_recip = 1.0/dy * sqrt((double)(dx * dx + dy * dy)); // 1 / sin(atan2((double)dy, (double)dx));
 			wid = thick * as_recip;
 		} else {
 			wid = 1;


Commit: 47cde2bae59e402c6fc54fa175795de77520bfbc
    https://github.com/scummvm/scummvm/commit/47cde2bae59e402c6fc54fa175795de77520bfbc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: Fixe memory override (!)

Changed paths:
    graphics/thumbnail.cpp


diff --git a/graphics/thumbnail.cpp b/graphics/thumbnail.cpp
index c769591936..e59928d5cb 100644
--- a/graphics/thumbnail.cpp
+++ b/graphics/thumbnail.cpp
@@ -280,7 +280,7 @@ int *scaleLine(int size, int srcSize) {
 	int scale = 100 * size / srcSize;
 	assert(scale > 0);
 	int *v = new int[size];
-	Common::fill(v, &v[size], 0);
+	Common::fill(v, &v[size - 1], 0);
 
 	int distCtr = 0;
 	int *destP = v;


Commit: dd21ddbe15ec1fc5f4f3738788d7f08b18d70078
    https://github.com/scummvm/scummvm/commit/dd21ddbe15ec1fc5f4f3738788d7f08b18d70078
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: MACGUI: Plug potential memory leak

Changed paths:
    graphics/macgui/macfontmanager.cpp


diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index 6e56849d66..57979db3e3 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -246,6 +246,8 @@ void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
 
 			Common::Array<Graphics::MacFontFamily::AsscEntry> *assoc = fontFamily->getAssocTable();
 
+			bool fontFamilyUsed = false;
+
 			for (uint i = 0; i < assoc->size(); i++) {
 				debug(8, "size: %d style: %d id: %d", (*assoc)[i]._fontSize, (*assoc)[i]._fontStyle | familySlant,
 										(*assoc)[i]._fontID);
@@ -265,6 +267,8 @@ void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
 					continue;
 				}
 
+				fontFamilyUsed = true;
+
 				font = new Graphics::MacFONTFont;
 				font->loadFont(*fontstream, fontFamily, (*assoc)[i]._fontSize, (*assoc)[i]._fontStyle | familySlant);
 
@@ -282,6 +286,9 @@ void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
 			}
 
 			delete fond;
+
+			if (!fontFamilyUsed)
+				delete fontFamily;
 		}
 	}
 }


Commit: b90cf5db81019c6acb97084ae03d216fbcc32e15
    https://github.com/scummvm/scummvm/commit/b90cf5db81019c6acb97084ae03d216fbcc32e15
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: Added sanity check to BDF font scaler

Changed paths:
    graphics/fonts/bdf.cpp


diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index e73fc7680f..c5c62feaa5 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -633,11 +633,11 @@ bool BdfFont::cacheFontData(const BdfFont &font, const Common::String &filename)
 BdfFont *BdfFont::loadFromCache(Common::SeekableReadStream &stream) {
 	const uint32 magic = stream.readUint32BE();
 	if (magic != BDF_FONTCACHE_TAG)
-		return 0;
+		return nullptr;
 
 	const uint32 version = stream.readUint32BE();
 	if (version != BDF_FONTCACHE_VERSION)
-		return 0;
+		return nullptr;
 
 	BdfFontData data;
 
@@ -653,7 +653,12 @@ BdfFont *BdfFont::loadFromCache(Common::SeekableReadStream &stream) {
 	data.numCharacters = stream.readUint16BE();
 
 	if (stream.err() || stream.eos())
-		return 0;
+		return nullptr;
+
+	if (data.numCharacters == 0) {
+		warning("BdfFont::loadFromCache(): Requested to load 0 characters font");
+		return nullptr;
+	}
 
 	byte **bitmaps = new byte *[data.numCharacters];
 	byte *advances = 0;
@@ -665,7 +670,7 @@ BdfFont *BdfFont::loadFromCache(Common::SeekableReadStream &stream) {
 			for (int j = 0; j < i; ++j)
 				delete[] bitmaps[i];
 			delete[] bitmaps;
-			return 0;
+			return nullptr;
 		}
 
 		if (size) {
@@ -698,7 +703,7 @@ BdfFont *BdfFont::loadFromCache(Common::SeekableReadStream &stream) {
 		delete[] bitmaps;
 		delete[] advances;
 		delete[] boxes;
-		return 0;
+		return nullptr;
 	}
 
 	data.bitmaps = bitmaps;
@@ -711,13 +716,18 @@ BdfFont *BdfFont::loadFromCache(Common::SeekableReadStream &stream) {
 
 BdfFont *BdfFont::scaleFont(BdfFont *src, int newSize) {
 	if (!src) {
-		warning("Empty font reference in scale font");
-		return NULL;
+		warning("BdfFont::scaleFont(): Empty font reference in scale font");
+		return nullptr;
 	}
 
 	if (src->getFontSize() == 0) {
-		warning("Requested to scale 0 size font");
-		return NULL;
+		warning("BdfFont::scaleFont(): Requested to scale 0 size font");
+		return nullptr;
+	}
+
+	if (src->_data.numCharacters == 0) {
+		warning("BdfFont::scaleFont(): Requested to scale 0 characters font");
+		return nullptr;
 	}
 
 	float scale = (float)newSize / (float)src->getFontSize();


Commit: b9a6b9957553bfaec70ff313ac45b13fb35b4617
    https://github.com/scummvm/scummvm/commit/b9a6b9957553bfaec70ff313ac45b13fb35b4617
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: Added more sanity checks to BDF font loading

Changed paths:
    graphics/fonts/bdf.cpp


diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index c5c62feaa5..aa8d69fd4a 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -420,6 +420,10 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
 				boxes[encoding] = box;
 			}
 		} else if (line.hasPrefix("FAMILY_NAME \"")) {
+			if (familyName != nullptr) {
+				warning("BdfFont::loadFont: Duplicated FAMILY_NAME");
+				delete[] familyName;
+			}
 			familyName = new char[line.size()];
 			Common::strlcpy(familyName, line.c_str() + 13, line.size() - 12);	// strlcpy() copies at most size-1 characters and then add a '\0'
 			char *p = &familyName[strlen(familyName)];
@@ -437,6 +441,10 @@ BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
 			}
 			*p = '\0'; // Remove last quote
 		} else if (line.hasPrefix("SLANT \"")) {
+			if (slant != nullptr) {
+				warning("BdfFont::loadFont: Duplicated SLANT");
+				delete[] slant;
+			}
 			slant = new char[line.size()];
 			Common::strlcpy(slant, line.c_str() + 7, line.size() - 6);  // strlcpy() copies at most size-1 characters and then add a '\0'
 			char *p = &slant[strlen(slant)];


Commit: c403182353ca2078f57fa942aba6a448ade7bde0
    https://github.com/scummvm/scummvm/commit/c403182353ca2078f57fa942aba6a448ade7bde0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: Initialize class variables in VectorRenderer

Changed paths:
    graphics/VectorRenderer.h
    graphics/VectorRendererSpec.cpp


diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h
index 28a987a927..14d3532b0c 100644
--- a/graphics/VectorRenderer.h
+++ b/graphics/VectorRenderer.h
@@ -130,7 +130,7 @@ VectorRenderer *createRenderer(int mode);
 class VectorRenderer {
 public:
 	VectorRenderer() : _activeSurface(NULL), _fillMode(kFillDisabled), _shadowOffset(0), _shadowFillMode(kShadowExponential),
-		_disableShadows(false), _strokeWidth(1), _gradientFactor(1) {
+		_disableShadows(false), _strokeWidth(1), _gradientFactor(1), _bevel(0), _dynamicData(0) {
 
 	}
 
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index a1d8ba3599..cec3980ed4 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -543,6 +543,9 @@ VectorRendererSpec(PixelFormat format) :
 
 	_bitmapAlphaColor = _format.RGBToColor(255, 0, 255);
 	_clippingArea = Common::Rect(0, 0, 32767, 32767);
+
+	_fgColor = _bgColor = _bevelColor = 0;
+	_gradientStart = _gradientEnd = 0;
 }
 
 /****************************


Commit: 3199a5e107d3ba6c89df412669e09253556c7903
    https://github.com/scummvm/scummvm/commit/3199a5e107d3ba6c89df412669e09253556c7903
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T13:57:35+02:00

Commit Message:
GRAPHICS: Properly initialize struct members

Changed paths:
    graphics/fonts/winfont.h


diff --git a/graphics/fonts/winfont.h b/graphics/fonts/winfont.h
index f1c661f270..386a620508 100644
--- a/graphics/fonts/winfont.h
+++ b/graphics/fonts/winfont.h
@@ -34,7 +34,7 @@ class WinResources;
 namespace Graphics {
 
 struct WinFontDirEntry {
-	WinFontDirEntry() {}
+	WinFontDirEntry() : points(0) {}
 	WinFontDirEntry(const Common::String &name, uint16 p) : faceName(name), points(p) {}
 
 	// This is really just a simple identifier to match a directory entry with
@@ -83,7 +83,7 @@ private:
 
 	uint16 _glyphCount;
 	struct GlyphEntry {
-		GlyphEntry() { bitmap = 0; }
+		GlyphEntry() { bitmap = 0; charWidth = 0; offset = 0; }
 		~GlyphEntry() { delete[] bitmap; }
 
 		uint16 charWidth;




More information about the Scummvm-git-logs mailing list