[Scummvm-git-logs] scummvm master -> 49e30c93cdae281ef90d0106a552c38ca9b0b1e7
larsamannen
noreply at scummvm.org
Fri Jul 21 14:48:07 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
49e30c93cd AGS: Remove function FileCloseNotify
Commit: 49e30c93cdae281ef90d0106a552c38ca9b0b1e7
https://github.com/scummvm/scummvm/commit/49e30c93cdae281ef90d0106a552c38ca9b0b1e7
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-07-21T16:48:03+02:00
Commit Message:
AGS: Remove function FileCloseNotify
In AGS there is a possibility to define a function, FileCloseNotify
with arguments, which is called when closing a file. This possibility
seems not to be used by any of the engines supported by ScummVM since
it's set to nullptr. This is not a problem in itself. Hoewever when
enabling compiler optimisiations the compiler may optimise away the
FileCloseNotify definition. This was discovered when compiling iOS
with Apple Clang in "Release" mode that the if-case in the code block
below was removed while the args parameter was left:
if (FileCloseNotify) {
CloseNotifyArgs args;
args.Filepath = _fileName;
args.WorkMode = _workMode;
FileCloseNotify(args);
}
This caused a nullptr exception since FileCloseNotify was nullptr.
A bit strange behavior by the compiler which could remove the entire
code block above.
Since the FileCloseNotify is not used in ScummVM, remove it as it
only seems to be used in upstream by the emscripten code which is
not part of the ScummVM repository.
Changed paths:
engines/ags/shared/util/file_stream.cpp
engines/ags/shared/util/file_stream.h
diff --git a/engines/ags/shared/util/file_stream.cpp b/engines/ags/shared/util/file_stream.cpp
index 4b24c767302..fdf7bcba4aa 100644
--- a/engines/ags/shared/util/file_stream.cpp
+++ b/engines/ags/shared/util/file_stream.cpp
@@ -48,12 +48,6 @@ bool FileStream::HasErrors() const {
void FileStream::Close() {
delete _file;
_file = nullptr;
- if (FileCloseNotify) {
- CloseNotifyArgs args;
- args.Filepath = _fileName;
- args.WorkMode = _workMode;
- FileCloseNotify(args);
- }
}
bool FileStream::Flush() {
@@ -200,8 +194,6 @@ void FileStream::Open(const String &file_name, FileOpenMode open_mode, FileWorkM
}
}
-FileStream::FFileCloseNotify FileStream::FileCloseNotify = nullptr;
-
String FileStream::getSaveName(const String &filename) {
return String(filename.GetCStr() + strlen(SAVE_FOLDER_PREFIX));
}
diff --git a/engines/ags/shared/util/file_stream.h b/engines/ags/shared/util/file_stream.h
index d2aa6a7d016..aad5f2cfdc0 100644
--- a/engines/ags/shared/util/file_stream.h
+++ b/engines/ags/shared/util/file_stream.h
@@ -39,10 +39,6 @@ public:
FileWorkMode WorkMode;
};
- // definition of function called when file closes
- typedef std::function<void(const CloseNotifyArgs &args)> FFileCloseNotify;
-
- static FFileCloseNotify FileCloseNotify;
// Represents an open file object
// The constructor may raise std::runtime_error if
// - there is an issue opening the file (does not exist, locked, permissions, etc)
More information about the Scummvm-git-logs
mailing list