[Scummvm-git-logs] scummvm master -> ea560b5dabd361b3988818e4f72e52858c331963

lephilousophe noreply at scummvm.org
Thu Aug 25 15:59:22 UTC 2022


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:
cecd5b3385 SDL: OPENGL: Remove useless #if guard
def0624ee9 GUI: Fix memory leak when resizing grid widget
d21b42950a GUI: Avoid useless surface copy before scaling
ea560b5dab GUI: Redraw editable widget and move its caret when text is set by code


Commit: cecd5b3385abecf25a43a76771c3b61208520571
    https://github.com/scummvm/scummvm/commit/cecd5b3385abecf25a43a76771c3b61208520571
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-08-25T17:57:38+02:00

Commit Message:
SDL: OPENGL: Remove useless #if guard

The code was already guarded by the same condition

Changed paths:
    backends/graphics/openglsdl/openglsdl-graphics.cpp


diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 9aae1c69c1f..57754aaee67 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -536,12 +536,10 @@ bool OpenGLSdlGraphicsManager::setupMode(uint width, uint height) {
 		return false;
 	}
 
-#if SDL_VERSION_ATLEAST(2, 0, 0)
 	_vsync = ConfMan.getBool("vsync");
 	if (SDL_GL_SetSwapInterval(_vsync ? 1 : 0)) {
 		warning("Unable to %s VSync: %s", _vsync ? "enable" : "disable", SDL_GetError());
 	}
-#endif
 
 	notifyContextCreate(_glContextType, rgba8888, rgba8888);
 	int actualWidth, actualHeight;


Commit: def0624ee9dc877175f4564f3e93e6f08a7d6c4a
    https://github.com/scummvm/scummvm/commit/def0624ee9dc877175f4564f3e93e6f08a7d6c4a
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-08-25T17:57:38+02:00

Commit Message:
GUI: Fix memory leak when resizing grid widget

Changed paths:
    gui/widgets/grid.cpp


diff --git a/gui/widgets/grid.cpp b/gui/widgets/grid.cpp
index c22849275b9..db5b8acc92e 100644
--- a/gui/widgets/grid.cpp
+++ b/gui/widgets/grid.cpp
@@ -891,6 +891,8 @@ void GridWidget::reflowLayout() {
 	_platformIconHeight = _platformIconWidth = _thumbnailWidth / 6;
 
 	if ((oldThumbnailHeight != _thumbnailHeight) || (oldThumbnailWidth != _thumbnailWidth)) {
+		unloadSurfaces(_platformIcons);
+		unloadSurfaces(_languageIcons);
 		unloadSurfaces(_loadedSurfaces);
 		reloadThumbnails();
 		loadFlagIcons();


Commit: d21b42950a11db33be0952f3fe28bdc58ce9b9d2
    https://github.com/scummvm/scummvm/commit/d21b42950a11db33be0952f3fe28bdc58ce9b9d2
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-08-25T17:57:38+02:00

Commit Message:
GUI: Avoid useless surface copy before scaling

By using the const rawSurface function instead of the surfacePtr one,
there is no need to create a copy of the const argument.

Changed paths:
    gui/widget.cpp


diff --git a/gui/widget.cpp b/gui/widget.cpp
index d7ac4fdacb3..0b39e7df519 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -594,12 +594,7 @@ const Graphics::ManagedSurface *scaleGfx(const Graphics::ManagedSurface *gfx, in
 	w = nw;
 	h = nh;
 
-	Graphics::ManagedSurface tmp(*gfx);
-
-	const Graphics::ManagedSurface *tmp2 = new Graphics::ManagedSurface(tmp.surfacePtr()->scale(w, h, filtering));
-	tmp.free();
-
-	return tmp2;
+	return new Graphics::ManagedSurface(gfx->rawSurface().scale(w, h, filtering));
 }
 
 PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &tooltip, uint32 cmd, uint8 hotkey)


Commit: ea560b5dabd361b3988818e4f72e52858c331963
    https://github.com/scummvm/scummvm/commit/ea560b5dabd361b3988818e4f72e52858c331963
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-08-25T17:57:38+02:00

Commit Message:
GUI: Redraw editable widget and move its caret when text is set by code

Changed paths:
    gui/widgets/editable.cpp
    gui/widgets/edittext.cpp


diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp
index 7c0f384a505..82ae73040bd 100644
--- a/gui/widgets/editable.cpp
+++ b/gui/widgets/editable.cpp
@@ -73,7 +73,8 @@ void EditableWidget::setEditString(const Common::U32String &str) {
 	// TODO: We probably should filter the input string here,
 	// e.g. using tryInsertChar.
 	_editString = str;
-	_caretPos = 0;
+	setCaretPos(caretVisualPos(str.size()));
+	markAsDirty();
 }
 
 bool EditableWidget::tryInsertChar(Common::u32char_type_t c, int pos) {
diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp
index 7af1d4225d4..6097d42e813 100644
--- a/gui/widgets/edittext.cpp
+++ b/gui/widgets/edittext.cpp
@@ -33,10 +33,10 @@ EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, cons
 	_type = kEditTextWidget;
 	_finishCmd = finishCmd;
 
+	_leftPadding = _rightPadding = 0;
+
 	setEditString(text);
 	setFontStyle(font);
-
-	_leftPadding = _rightPadding = 0;
 }
 
 EditTextWidget::EditTextWidget(GuiObject *boss, const Common::String &name, const Common::U32String &text, const Common::U32String &tooltip, uint32 cmd, uint32 finishCmd, ThemeEngine::FontStyle font)
@@ -45,10 +45,10 @@ EditTextWidget::EditTextWidget(GuiObject *boss, const Common::String &name, cons
 	_type = kEditTextWidget;
 	_finishCmd = finishCmd;
 
+	_leftPadding = _rightPadding = 0;
+
 	setEditString(text);
 	setFontStyle(font);
-
-	_leftPadding = _rightPadding = 0;
 }
 
 void EditTextWidget::setEditString(const Common::U32String &str) {
@@ -115,11 +115,15 @@ Common::Rect EditTextWidget::getEditRect() const {
 	// Calculate (right - left) difference for editRect's X-axis coordinates:
 	// (_w - 1 - _rightPadding) - (2 + _leftPadding)
 	int editWidth = _w - _rightPadding - _leftPadding - 3;
+	int editHeight = _h - 2;
 	// Ensure r will always be a valid rect
 	if (editWidth < 0) {
 		editWidth = 0;
 	}
-	Common::Rect r(2 + _leftPadding, 1, 2 + _leftPadding + editWidth, _h);
+	if (editHeight < 0) {
+		editHeight = 0;
+	}
+	Common::Rect r(2 + _leftPadding, 1, 2 + _leftPadding + editWidth, 1 + editHeight);
 
 	return r;
 }




More information about the Scummvm-git-logs mailing list