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

sev- sev at scummvm.org
Fri Sep 2 23:39:38 CEST 2016


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

Summary:
2b6f1719e7 GRAPHICS: Fix window closing
9444a1864b GRAPHICS: Fix leak in macgui border loading
5bba089724 GRAPHICS: Fix big leak when blitting macgui borders
ec6bb1431e GRAPHICS: Fix leak in ninepatch destructor
b1657f4748 Merge pull request #816 from blorente/macgui-fix


Commit: 2b6f1719e72d0140b74270e04d6a106e6adc5b30
    https://github.com/scummvm/scummvm/commit/2b6f1719e72d0140b74270e04d6a106e6adc5b30
Author: Borja Lorente (blorente at ucm.es)
Date: 2016-08-10T19:45:48+02:00

Commit Message:
GRAPHICS: Fix window closing

Changed paths:
    graphics/macgui/macwindowmanager.cpp



diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index d19e407..413d9b2 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -322,6 +322,7 @@ void MacWindowManager::removeMarked() {
 	}
 	_windowsToRemove.clear();
 	_needsRemoval = false;
+	_lastId = _windows.size();
 }
 
 void MacWindowManager::removeFromStack(BaseMacWindow *target) {


Commit: 9444a1864b8a12b1f0c0495e7a948db250870137
    https://github.com/scummvm/scummvm/commit/9444a1864b8a12b1f0c0495e7a948db250870137
Author: Borja Lorente (blorente at ucm.es)
Date: 2016-08-25T13:26:02+02:00

Commit Message:
GRAPHICS: Fix leak in macgui border loading

Changed paths:
    graphics/macgui/macwindow.cpp
    graphics/macgui/macwindowborder.cpp
    graphics/macgui/macwindowborder.h



diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index dbb600b..6405d37 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -324,19 +324,19 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo
 	source = *(bmpDecoder.getSurface());
 
 	source.convertToInPlace(surface->getSupportedPixelFormat(), bmpDecoder.getPalette());
-	surface->create(source.w, source.h, source.format);
 	surface->copyFrom(source);
 	surface->applyColorKey(255, 0, 255, false);
 
 	if (active)
-		_macBorder.addActiveBorder(*surface);
+		_macBorder.addActiveBorder(surface);
 	else
-		_macBorder.addInactiveBorder(*surface);
+		_macBorder.addInactiveBorder(surface);
 
 	if (!_macBorder.hasOffsets())
 		_macBorder.setOffsets(lo, ro, to, bo);
 
 	updateInnerDims();
+	source.free();
 }
 
 void MacWindow::setCloseable(bool closeable) {
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index b77fa35..2583244 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -71,15 +71,15 @@ bool MacWindowBorder::hasBorder(bool active) {
 	return active ? _activeInitialized : _inactiveInitialized;
 }
 
-void MacWindowBorder::addActiveBorder(TransparentSurface &source) {
+void MacWindowBorder::addActiveBorder(TransparentSurface *source) {
 	assert(!_activeBorder);
-	_activeBorder = new NinePatchBitmap(&source, false);
+	_activeBorder = new NinePatchBitmap(source, true);
 	_activeInitialized = true;
 }
 
-void MacWindowBorder::addInactiveBorder(TransparentSurface &source) {
+void MacWindowBorder::addInactiveBorder(TransparentSurface *source) {
 	assert(!_inactiveBorder);
-	_inactiveBorder = new NinePatchBitmap(&source, false);
+	_inactiveBorder = new NinePatchBitmap(source, true);
 	_inactiveInitialized = true;
 }
 
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index 54938e5..6a1b55c 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -86,14 +86,14 @@ public:
 	 * Will fail if there is already an active border.
 	 * @param The surface that will be displayed.
 	 */
-	void addActiveBorder(TransparentSurface &source);
+	void addActiveBorder(TransparentSurface *source);
 
 	/**
 	 * Add the given surface as the display of the border in the inactive state.
 	 * Will fail if there is already an inactive border.
 	 * @param The surface that will be displayed.
 	 */
-	void addInactiveBorder(TransparentSurface &source);
+	void addInactiveBorder(TransparentSurface *source);
 
 	/**
 	 * Accessor function for the custom offsets.


Commit: 5bba0897246de34318ac6049402b9d5f58722aa4
    https://github.com/scummvm/scummvm/commit/5bba0897246de34318ac6049402b9d5f58722aa4
Author: Borja Lorente (blorente at ucm.es)
Date: 2016-08-25T13:26:02+02:00

Commit Message:
GRAPHICS: Fix big leak when blitting macgui borders

Changed paths:
    graphics/macgui/macwindow.cpp
    graphics/macgui/macwindowborder.cpp
    graphics/nine_patch.cpp



diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 6405d37..abb91f1 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -336,7 +336,6 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo
 		_macBorder.setOffsets(lo, ro, to, bo);
 
 	updateInnerDims();
-	source.free();
 }
 
 void MacWindow::setCloseable(bool closeable) {
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index 2583244..f47f8a3 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -112,6 +112,7 @@ void MacWindowBorder::blitBorderInto(ManagedSurface &destination, bool active) {
 
 	src->blit(srf, 0, 0, srf.w, srf.h, palette, kColorCount);
 	destination.transBlitFrom(srf, kColorGreen2);
+	srf.free();
 }
 
 } // End of namespace Graphics
diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index fa2ef20..9cee908 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -230,25 +230,28 @@ void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, in
 		if (!palette)
 			warning("Trying to blit into a surface with 1bpp, you need the palette.");
 
-		Surface srf;
-		srf.create(target.w, target.h, _bmp->format);
+		Surface *srf = new Surface();
+		srf->create(target.w, target.h, _bmp->format);
 
-		drawRegions(srf, dx, dy, dw, dh);
+		drawRegions(*srf, dx, dy, dw, dh);
 
 		//TODO: This can be further optimized by keeping the data between draws,
 		// and using a unique identifier for each palette, so that it only gets
 		// recalculated when the palette changes.
 		_cached_colors.clear();
 
-		for (uint i = 0; i < srf.w; ++i) {
-			for (uint j = 0; j < srf.h; ++j) {
-				uint32 color = *(uint32*)srf.getBasePtr(i, j);
+		for (uint i = 0; i < srf->w; ++i) {
+			for (uint j = 0; j < srf->h; ++j) {
+				uint32 color = *(uint32*)srf->getBasePtr(i, j);
 				if (color > 0) {
 					*((byte *)target.getBasePtr(i, j)) = closestGrayscale(color, palette, numColors);
 				}
 			}
 		}
 
+		srf->free();
+		delete srf;
+
 		return;
 	}
 


Commit: ec6bb1431eb3e54f4a1dddd051cb9b8dfa14f43d
    https://github.com/scummvm/scummvm/commit/ec6bb1431eb3e54f4a1dddd051cb9b8dfa14f43d
Author: Borja Lorente (blorente at ucm.es)
Date: 2016-08-26T12:27:16+02:00

Commit Message:
GRAPHICS: Fix leak in ninepatch destructor

Changed paths:
    graphics/macgui/macwindow.cpp
    graphics/nine_patch.cpp



diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index abb91f1..975d526 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -317,14 +317,14 @@ void MacWindow::setScroll(float scrollPos, float scrollSize) {
 
 void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo, int ro, int to, int bo) {
 	Image::BitmapDecoder bmpDecoder;
-	Graphics::Surface source;
+	Graphics::Surface *source;
 	Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
 
 	bmpDecoder.loadStream(file);
-	source = *(bmpDecoder.getSurface());
+	source = bmpDecoder.getSurface()->convertTo(surface->getSupportedPixelFormat(), bmpDecoder.getPalette());
 
-	source.convertToInPlace(surface->getSupportedPixelFormat(), bmpDecoder.getPalette());
-	surface->copyFrom(source);
+	surface->create(source->w, source->h, surface->getSupportedPixelFormat());
+	surface->copyFrom(*source);
 	surface->applyColorKey(255, 0, 255, false);
 
 	if (active)
@@ -336,6 +336,8 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo
 		_macBorder.setOffsets(lo, ro, to, bo);
 
 	updateInnerDims();
+	source->free();
+	delete source;
 }
 
 void MacWindow::setCloseable(bool closeable) {
diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index 9cee908..56e1202 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -260,8 +260,10 @@ void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, in
 }
 
 NinePatchBitmap::~NinePatchBitmap() {
-	if (_destroy_bmp)
+	if (_destroy_bmp) {
+		_bmp->free();
 		delete _bmp;
+	}
 }
 
 void NinePatchBitmap::drawRegions(Graphics::Surface &target, int dx, int dy, int dw, int dh) {


Commit: b1657f47483c3ad4fe653fe7ddd837842c07a708
    https://github.com/scummvm/scummvm/commit/b1657f47483c3ad4fe653fe7ddd837842c07a708
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-09-02T23:39:32+02:00

Commit Message:
Merge pull request #816 from blorente/macgui-fix

GRAPHICS: [GSoC] Fix leaks and bugs in MacGui

Changed paths:
    graphics/macgui/macwindow.cpp
    graphics/macgui/macwindowborder.cpp
    graphics/macgui/macwindowborder.h
    graphics/macgui/macwindowmanager.cpp
    graphics/nine_patch.cpp








More information about the Scummvm-git-logs mailing list