mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-04 13:13:03 +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)
|
||||
return Qnil;
|
||||
|
||||
/* Nothing to do if already disposed */
|
||||
if (d->isDisposed())
|
||||
return Qnil;
|
||||
|
||||
GFX_LOCK;
|
||||
d->dispose();
|
||||
GFX_UNLOCK;
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
|
|
@ -50,9 +50,16 @@ public:
|
|||
if (disposed)
|
||||
return;
|
||||
|
||||
releaseResources();
|
||||
disposed = true;
|
||||
wasDisposed();
|
||||
GFX_LOCK;
|
||||
try {
|
||||
releaseResources();
|
||||
disposed = true;
|
||||
wasDisposed();
|
||||
} catch (Exception &e) {
|
||||
GFX_UNLOCK;
|
||||
throw e;
|
||||
}
|
||||
GFX_UNLOCK;
|
||||
}
|
||||
|
||||
bool isDisposed() const
|
||||
|
|
Loading…
Add table
Reference in a new issue