mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-08 11:02:57 +02:00
Move the GFX_LOCK/GFX_UNLOCK call for disposing into disposable.h.
It's currently not (much of) a problem because few or no games use multiple threads, but I believe that ruby can run its garbage collector while the GVL is released, which means that Graphics.update and Graphics.wait are currently not thread safe. Moving the call to GFX_LOCK into dispose() should fix this.
This commit is contained in:
parent
477162d1d3
commit
23e9f6cb1c
2 changed files with 10 additions and 9 deletions
|
@ -36,13 +36,7 @@ RB_METHOD(disposableDispose)
|
||||||
if (!d)
|
if (!d)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
|
||||||
/* Nothing to do if already disposed */
|
|
||||||
if (d->isDisposed())
|
|
||||||
return Qnil;
|
|
||||||
|
|
||||||
GFX_LOCK;
|
|
||||||
d->dispose();
|
d->dispose();
|
||||||
GFX_UNLOCK;
|
|
||||||
|
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,16 @@ public:
|
||||||
if (disposed)
|
if (disposed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
GFX_LOCK;
|
||||||
|
try {
|
||||||
releaseResources();
|
releaseResources();
|
||||||
disposed = true;
|
disposed = true;
|
||||||
wasDisposed();
|
wasDisposed();
|
||||||
|
} catch (Exception &e) {
|
||||||
|
GFX_UNLOCK;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
GFX_UNLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isDisposed() const
|
bool isDisposed() const
|
||||||
|
|
Loading…
Add table
Reference in a new issue