AMIGAOS: Cleanup and free signals via atexit(), 2nd attempt

Second attempt at fixing #6956
"ScummVM returned with unfreed signals (AmigaOS4)"

This only runs the cleanup code if the OSystem_AmigaOS
instance has not been destroyed already.
This commit is contained in:
PushmePullyu 2024-03-11 16:46:59 +01:00 committed by Filippos Karapetis
parent 198e346bf8
commit 926d5fd0b7
2 changed files with 16 additions and 1 deletions

View File

@ -27,7 +27,22 @@
#include "backends/fs/amigaos/amigaos-fs-factory.h"
#include "backends/dialogs/amigaos/amigaos-dialogs.h"
static bool cleanupDone = false;
static void cleanup() {
if (!cleanupDone)
g_system->destroy();
}
OSystem_AmigaOS::~OSystem_AmigaOS() {
cleanupDone = true;
}
void OSystem_AmigaOS::init() {
// Register cleanup function to avoid unfreed signals
if (atexit(cleanup))
warning("Failed to register cleanup function via atexit()");
// Initialize File System Factory
_fsFactory = new AmigaOSFilesystemFactory();

View File

@ -27,7 +27,7 @@
class OSystem_AmigaOS : public OSystem_SDL {
public:
OSystem_AmigaOS() {}
virtual ~OSystem_AmigaOS() {}
virtual ~OSystem_AmigaOS();
bool hasFeature(Feature f) override;