[Scummvm-git-logs] scummvm master -> 193856d08ce82edbdb4f5aa71ee125209dbe18f9

lephilousophe noreply at scummvm.org
Sat Oct 11 15:54:24 UTC 2025


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

Summary:
33fc7f38cf COMMON: Don't write 0 bytes in MemoryReadWriteStream
0a1eabea4e ANDROID: Properly get an InputStream from a ParcelFileDescriptor
eaa4ad4f98 ANDROID: Cleanup SAF warnings from Android Studio
7764e73bba ANDROID: Fix local reference leak when there is an exception in getNewSAFTree
434ce3d563 GUI: Free write stream when deleting cache
ef35d61078 GUI: Reset download size when starting a download
193856d08c GUI: Force redraw when widget visibility changes


Commit: 33fc7f38cf388b1a8cafed06631afac9f2acbe0b
    https://github.com/scummvm/scummvm/commit/33fc7f38cf388b1a8cafed06631afac9f2acbe0b
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-10-11T17:49:45+02:00

Commit Message:
COMMON: Don't write 0 bytes in MemoryReadWriteStream

If the buffer is empty, writing 0 bytes will cause a division by 0
because of the modulo operation.

Changed paths:
    common/memstream.h


diff --git a/common/memstream.h b/common/memstream.h
index e787b95bb1e..de3b871efa4 100644
--- a/common/memstream.h
+++ b/common/memstream.h
@@ -323,6 +323,9 @@ public:
 	}
 
 	uint32 write(const void *dataPtr, uint32 dataSize) override {
+		if (dataSize == 0) {
+			return 0;
+		}
 		ensureCapacity(_length + dataSize);
 		if (_writePos + dataSize < _capacity) {
 			memcpy(_data + _writePos, dataPtr, dataSize);


Commit: 0a1eabea4e58f0d40979a01df9d24fba400215d7
    https://github.com/scummvm/scummvm/commit/0a1eabea4e58f0d40979a01df9d24fba400215d7
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-10-11T17:49:45+02:00

Commit Message:
ANDROID: Properly get an InputStream from a ParcelFileDescriptor

Changed paths:
    backends/platform/android/org/scummvm/scummvm/BackupManager.java


diff --git a/backends/platform/android/org/scummvm/scummvm/BackupManager.java b/backends/platform/android/org/scummvm/scummvm/BackupManager.java
index 170d2755e67..2dde0564f4c 100644
--- a/backends/platform/android/org/scummvm/scummvm/BackupManager.java
+++ b/backends/platform/android/org/scummvm/scummvm/BackupManager.java
@@ -261,7 +261,7 @@ public class BackupManager {
 				ZipEntry entry = new ZipEntry(folderName + component);
 
 				zos.putNextEntry(entry);
-				copyStream(zos, new FileInputStream(pfd.getFileDescriptor()));
+				copyStream(zos, new ParcelFileDescriptor.AutoCloseInputStream(pfd));
 				zos.closeEntry();
 			} catch(FileNotFoundException ignored) {
 				return false;


Commit: eaa4ad4f985577a84543c30689279fc9aa483d6b
    https://github.com/scummvm/scummvm/commit/eaa4ad4f985577a84543c30689279fc9aa483d6b
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-10-11T17:49:45+02:00

Commit Message:
ANDROID: Cleanup SAF warnings from Android Studio

Changed paths:
    backends/fs/android/android-saf-fs.cpp
    backends/platform/android/org/scummvm/scummvm/SAFFSTree.java


diff --git a/backends/fs/android/android-saf-fs.cpp b/backends/fs/android/android-saf-fs.cpp
index 4837b46ecdf..cce887a8f8e 100644
--- a/backends/fs/android/android-saf-fs.cpp
+++ b/backends/fs/android/android-saf-fs.cpp
@@ -742,7 +742,6 @@ void AndroidSAFFilesystemNode::cacheData(JNIEnv *env, jobject node) {
 
 	if (!_safParent) {
 		jstring nameObj = (jstring)env->GetObjectField(_safTree, _FID__treeName);
-		debug("_FID__treeName: %p", nameObj);
 		const char *nameP = env->GetStringUTFChars(nameObj, 0);
 		if (nameP != 0) {
 			_newName = Common::String(nameP);
@@ -754,7 +753,6 @@ void AndroidSAFFilesystemNode::cacheData(JNIEnv *env, jobject node) {
 	Common::String workingPath;
 
 	jstring pathObj = (jstring)env->GetObjectField(node, _FID__path);
-	debug("_FID__path: %p", pathObj);
 	const char *path = env->GetStringUTFChars(pathObj, 0);
 	if (path == nullptr) {
 		env->DeleteLocalRef(pathObj);
diff --git a/backends/platform/android/org/scummvm/scummvm/SAFFSTree.java b/backends/platform/android/org/scummvm/scummvm/SAFFSTree.java
index de2f4233279..868294af87b 100644
--- a/backends/platform/android/org/scummvm/scummvm/SAFFSTree.java
+++ b/backends/platform/android/org/scummvm/scummvm/SAFFSTree.java
@@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicLong;
 public class SAFFSTree {
 	@RequiresApi(api = Build.VERSION_CODES.BASE)
 	public interface IOBusyListener {
-		public void onIOBusy(float ratio);
+		void onIOBusy(float ratio);
 	}
 
 	private static class IOTime {
@@ -196,6 +196,9 @@ public class SAFFSTree {
 		}
 	}
 
+	/** @noinspection unused
+	 * This version is used by the C++ side
+	 */
 	public static void addNodeRef(long nodeId) {
 		assert(nodeId != 0);
 		SAFFSNode node = _nodes.get(nodeId);
@@ -205,6 +208,9 @@ public class SAFFSTree {
 		assert(newId == nodeId);
 	}
 
+	/** @noinspection unused
+	 * This version is used by the C++ side
+	 */
 	public static void decNodeRef(long nodeId) {
 		assert(nodeId != 0);
 		SAFFSNode node = _nodes.get(nodeId);
@@ -213,10 +219,12 @@ public class SAFFSTree {
 		node.decRef();
 	}
 
+	/** @noinspection unused
+	 * This version is used by the C++ side
+	 */
 	public static SAFFSNode refToNode(long nodeId) {
 		assert(nodeId != 0);
-		SAFFSNode node = _nodes.get(nodeId);
-		return node;
+		return _nodes.get(nodeId);
 	}
 
 	public static class SAFFSNode implements Comparable<SAFFSNode> {
@@ -298,11 +306,11 @@ public class SAFFSTree {
 		}
 	}
 
-	private Context _context;
-	private Uri _treeUri;
+	private final Context _context;
+	private final Uri _treeUri;
 
-	private SAFFSNode _root;
-	private String _treeName;
+	private final SAFFSNode _root;
+	private final String _treeName;
 
 	public SAFFSTree(Context context, Uri treeUri) {
 		_context = context;
@@ -310,12 +318,13 @@ public class SAFFSTree {
 
 		_root = new SAFFSNode().reset(null, "", DocumentsContract.getTreeDocumentId(treeUri), 0);
 		// Update flags and get name
-		_treeName = stat(_root);
-		if (_treeName == null) {
+		String treeName = stat(_root);
+		if (treeName == null) {
 			// The tree likely got deleted
 			// Use the document ID instead as this will let the user do some cleanup
-			_treeName = DocumentsContract.getTreeDocumentId(treeUri);
+			treeName = DocumentsContract.getTreeDocumentId(treeUri);
 		}
+		_treeName = treeName;
 	}
 
 	public String getTreeId() {
@@ -331,7 +340,7 @@ public class SAFFSTree {
 	private void clearCache() {
 		ArrayDeque<SAFFSNode> stack = new ArrayDeque<>();
 		stack.push(_root);
-		while (stack.size() > 0) {
+		while (!stack.isEmpty()) {
 			SAFFSNode node = stack.pop();
 			node._dirty = true;
 			if (node._children == null) {
@@ -403,7 +412,9 @@ public class SAFFSTree {
 		return results.toArray(new SAFFSNode[0]);
 	}
 
-	// This version is used by the C++ side
+	/** @noinspection unused
+	 * This version is used by the C++ side
+	 */
 	public SAFFSNode[] getChildren(long nodeId) {
 		SAFFSNode node = _nodes.get(nodeId);
 		assert(node != null);
@@ -432,6 +443,9 @@ public class SAFFSTree {
 			c = resolver.query(searchUri, new String[] { DocumentsContract.Document.COLUMN_DISPLAY_NAME,
 				DocumentsContract.Document.COLUMN_DOCUMENT_ID, DocumentsContract.Document.COLUMN_MIME_TYPE,
 				DocumentsContract.Document.COLUMN_FLAGS }, null, null, null);
+			if (c == null) {
+				return results;
+			}
 			while (c.moveToNext()) {
 				final String displayName = c.getString(0);
 				final String documentId = c.getString(1);
@@ -441,7 +455,7 @@ public class SAFFSTree {
 				final int ourFlags = SAFFSNode.computeFlags(mimeType, flags);
 
 				SAFFSNode newnode = null;
-				SoftReference<SAFFSNode> oldnodeRef = null;
+				SoftReference<SAFFSNode> oldnodeRef;
 				if (oldChildren != null) {
 					oldnodeRef = oldChildren.remove(displayName);
 					if (oldnodeRef != null) {
@@ -473,11 +487,13 @@ public class SAFFSTree {
 	}
 
 	public SAFFSNode getChild(SAFFSNode node, String name) {
-		// This variable is used to hold a strong reference on every children nodes
+		//This variable is used to hold a strong reference on every children nodes
+		//noinspection unused
 		Collection<SAFFSNode> children;
 
 		if (node._children == null || node._dirty) {
 			try {
+				//noinspection UnusedAssignment
 				children = fetchChildren(node);
 			} catch (Exception e) {
 				Log.w(ScummVM.LOG_TAG, "Failed to get children: " + e);
@@ -497,6 +513,7 @@ public class SAFFSTree {
 
 		// Node reference was stale, force a refresh
 		try {
+			//noinspection UnusedAssignment
 			children = fetchChildren(node);
 		} catch (Exception e) {
 			Log.w(ScummVM.LOG_TAG, "Failed to get children: " + e);
@@ -516,7 +533,9 @@ public class SAFFSTree {
 		return newnode;
 	}
 
-	// This version is used by the C++ side
+	/** @noinspection unused
+	 * This version is used by the C++ side
+	 */
 	public SAFFSNode getChild(long nodeId, String name) {
 		SAFFSNode node = _nodes.get(nodeId);
 		assert(node != null);
@@ -528,7 +547,9 @@ public class SAFFSTree {
 		return createDocument(node, name, DocumentsContract.Document.MIME_TYPE_DIR);
 	}
 
-	// This version is used by the C++ side
+	/** @noinspection unused
+	 * This version is used by the C++ side
+	 */
 	public SAFFSNode createDirectory(long nodeId, String name) {
 		SAFFSNode node = _nodes.get(nodeId);
 		assert(node != null);
@@ -540,7 +561,9 @@ public class SAFFSTree {
 		return createDocument(node, name, "application/octet-stream");
 	}
 
-	// This version is used by the C++ side
+	/** @noinspection unused
+	 * This version is used by the C++ side
+	 */
 	public SAFFSNode createFile(long nodeId, String name) {
 		SAFFSNode node = _nodes.get(nodeId);
 		assert(node != null);
@@ -552,7 +575,9 @@ public class SAFFSTree {
 		return createStream(node, "r");
 	}
 
-	// This version is used by the C++ side
+	/** @noinspection unused
+	 * This version is used by the C++ side
+	 */
 	public int createReadStream(long nodeId) {
 		SAFFSNode node = _nodes.get(nodeId);
 		assert(node != null);
@@ -564,7 +589,9 @@ public class SAFFSTree {
 		return createStream(node, "wt");
 	}
 
-	// This version is used by the C++ side
+	/** @noinspection unused
+	 * This version is used by the C++ side
+	 */
 	public int createWriteStream(long nodeId) {
 		SAFFSNode node = _nodes.get(nodeId);
 		assert(node != null);
@@ -615,7 +642,9 @@ public class SAFFSTree {
 		return 0;
 	}
 
-	// This version is used by the C++ side
+	/** @noinspection unused
+	 * This version is used by the C++ side
+	 */
 	public int removeNode(long nodeId) {
 		SAFFSNode node = _nodes.get(nodeId);
 		assert(node != null);
@@ -623,6 +652,9 @@ public class SAFFSTree {
 		return removeNode(node);
 	}
 
+	/** @noinspection unused
+	 * This version is used by the C++ side
+	 */
 	public void removeTree() {
 		final ContentResolver resolver = _context.getContentResolver();
 
@@ -733,7 +765,10 @@ public class SAFFSTree {
 		try {
 			c = resolver.query(uri, new String[] { DocumentsContract.Document.COLUMN_DISPLAY_NAME,
 				DocumentsContract.Document.COLUMN_MIME_TYPE, DocumentsContract.Document.COLUMN_FLAGS }, null, null, null);
-			while (c.moveToNext()) {
+			if (c == null) {
+				return null;
+			}
+			if (c.moveToNext()) {
 				final String displayName = c.getString(0);
 				final String mimeType = c.getString(1);
 				final int flags = c.getInt(2);
@@ -748,9 +783,7 @@ public class SAFFSTree {
 			if (c != null) {
 				try {
 					c.close();
-				} catch (RuntimeException e) {
-					throw e;
-				} catch (Exception e) {
+				} catch (Exception ignored) {
 				}
 			}
 


Commit: 7764e73bba41cae5ca84c290d828b7eb1a27bfa3
    https://github.com/scummvm/scummvm/commit/7764e73bba41cae5ca84c290d828b7eb1a27bfa3
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-10-11T17:49:45+02:00

Commit Message:
ANDROID: Fix local reference leak when there is an exception in getNewSAFTree

Changed paths:
    backends/platform/android/jni-android.cpp


diff --git a/backends/platform/android/jni-android.cpp b/backends/platform/android/jni-android.cpp
index 3477445309f..d382be3e8e9 100644
--- a/backends/platform/android/jni-android.cpp
+++ b/backends/platform/android/jni-android.cpp
@@ -1074,6 +1074,9 @@ jobject JNI::getNewSAFTree(bool writable, const Common::String &initURI,
 	jobject tree = env->CallObjectMethod(_jobj, _MID_getNewSAFTree,
 	                                     writable, javaInitURI, javaPrompt);
 
+	env->DeleteLocalRef(javaInitURI);
+	env->DeleteLocalRef(javaPrompt);
+
 	if (env->ExceptionCheck()) {
 		LOGE("getNewSAFTree: error");
 
@@ -1083,9 +1086,6 @@ jobject JNI::getNewSAFTree(bool writable, const Common::String &initURI,
 		return nullptr;
 	}
 
-	env->DeleteLocalRef(javaInitURI);
-	env->DeleteLocalRef(javaPrompt);
-
 	return tree;
 }
 


Commit: 434ce3d563af89c76be2ccc1104d91452f8690df
    https://github.com/scummvm/scummvm/commit/434ce3d563af89c76be2ccc1104d91452f8690df
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-10-11T17:49:45+02:00

Commit Message:
GUI: Free write stream when deleting cache

This fixes cache deletion and avoids a memory leak.

Changed paths:
    gui/downloadpacksdialog.cpp


diff --git a/gui/downloadpacksdialog.cpp b/gui/downloadpacksdialog.cpp
index de92782c2f3..2851a000f2a 100644
--- a/gui/downloadpacksdialog.cpp
+++ b/gui/downloadpacksdialog.cpp
@@ -475,6 +475,7 @@ void DownloadPacksDialog::clearCache() {
 			// Overwrite previously downloaded pack files with dummy data
 			str->writeByte(0);
 			str->finalize();
+			delete str;
 		}
 		g_state->fileHash.clear();
 


Commit: ef35d610787056f2319fabd08760d1917f285512
    https://github.com/scummvm/scummvm/commit/ef35d610787056f2319fabd08760d1917f285512
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-10-11T17:49:45+02:00

Commit Message:
GUI: Reset download size when starting a download

If we restarted a download just after making one and clearing the cache,
the count would continue to add up and the progress bar would go up to
200%.

Changed paths:
    gui/downloadpacksdialog.cpp


diff --git a/gui/downloadpacksdialog.cpp b/gui/downloadpacksdialog.cpp
index 2851a000f2a..3c225fa6fb0 100644
--- a/gui/downloadpacksdialog.cpp
+++ b/gui/downloadpacksdialog.cpp
@@ -88,6 +88,7 @@ void DialogState::downloadList() {
 
 void DialogState::proceedDownload() {
 	startTime = lastUpdate = g_system->getMillis();
+	downloadedSize = 0;
 	g_system->taskStarted(OSystem::kDataPackDownload);
 	takeOneFile();
 }


Commit: 193856d08ce82edbdb4f5aa71ee125209dbe18f9
    https://github.com/scummvm/scummvm/commit/193856d08ce82edbdb4f5aa71ee125209dbe18f9
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-10-11T17:49:45+02:00

Commit Message:
GUI: Force redraw when widget visibility changes

If the widget is shown, we mark it dirty.
When the widget is hidden, we have to redraw the full dialog to avoid
leftovers (an invisible widget is never redrawn nor erased).

Changed paths:
    gui/widget.cpp


diff --git a/gui/widget.cpp b/gui/widget.cpp
index 580ee1850f4..e8767f7670a 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -213,10 +213,17 @@ bool Widget::isEnabled() const {
 }
 
 void Widget::setVisible(bool e) {
-	if (e)
-		clearFlags(WIDGET_INVISIBLE);
-	else
-		setFlags(WIDGET_INVISIBLE);
+	if (!(_flags & WIDGET_INVISIBLE) != e) {
+		if (e) {
+			clearFlags(WIDGET_INVISIBLE);
+			markAsDirty();
+		} else {
+			setFlags(WIDGET_INVISIBLE);
+			// When becoming invisible the whole dialog must be redrawn
+			// to hide the widgets
+			g_gui.scheduleTopDialogRedraw();
+		}
+	}
 }
 
 bool Widget::isVisible() const {




More information about the Scummvm-git-logs mailing list