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.
This commit is contained in:
Lars Sundström 2023-07-20 22:07:59 +02:00
parent 29dfd1382c
commit 49e30c93cd
2 changed files with 0 additions and 12 deletions

View File

@ -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));
}

View File

@ -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)