mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-27 01:45:35 -05:00
ensure mod events are only posted in gd thread
This commit is contained in:
parent
da691652cf
commit
93fd396ed9
2 changed files with 23 additions and 13 deletions
9
loader/include/Geode/cocos/cocoa/CCObject.h
vendored
9
loader/include/Geode/cocos/cocoa/CCObject.h
vendored
|
@ -47,14 +47,13 @@ NS_CC_BEGIN
|
|||
* @{
|
||||
*/
|
||||
|
||||
RT_ADD(
|
||||
// please someone tell we why in higher being(s)'s name rob did this
|
||||
enum class CCObjectType {
|
||||
// please someone tell we why in higher being(s)'s name rob did this
|
||||
enum class CCObjectType {
|
||||
PlayLayer = 5,
|
||||
LevelEditorLayer = 6,
|
||||
GameObject = 13,
|
||||
MenuLayer = 15,
|
||||
};
|
||||
)
|
||||
};
|
||||
|
||||
class CCZone;
|
||||
class CCObject;
|
||||
|
|
|
@ -116,7 +116,9 @@ std::vector<Hook*> Mod::Impl::getHooks() const {
|
|||
// Settings and saved values
|
||||
|
||||
Result<> Mod::Impl::loadData() {
|
||||
Loader::get()->queueInGDThread([&]() {
|
||||
ModStateEvent(m_self, ModEventType::DataLoaded).post();
|
||||
});
|
||||
|
||||
// Settings
|
||||
// Check if settings exist
|
||||
|
@ -182,6 +184,7 @@ Result<> Mod::Impl::loadData() {
|
|||
}
|
||||
|
||||
Result<> Mod::Impl::saveData() {
|
||||
// saveData is expected to be synchronous, and always called from GD thread
|
||||
ModStateEvent(m_self, ModEventType::DataSaved).post();
|
||||
|
||||
// Data saving should be fully fail-safe
|
||||
|
@ -308,7 +311,9 @@ Result<> Mod::Impl::loadBinary() {
|
|||
|
||||
LoaderImpl::get()->releaseNextMod();
|
||||
|
||||
Loader::get()->queueInGDThread([&]() {
|
||||
ModStateEvent(m_self, ModEventType::Loaded).post();
|
||||
});
|
||||
|
||||
Loader::get()->updateAllDependencies();
|
||||
|
||||
|
@ -329,7 +334,9 @@ Result<> Mod::Impl::unloadBinary() {
|
|||
GEODE_UNWRAP(this->saveData());
|
||||
|
||||
GEODE_UNWRAP(this->disable());
|
||||
Loader::get()->queueInGDThread([&]() {
|
||||
ModStateEvent(m_self, ModEventType::Unloaded).post();
|
||||
});
|
||||
|
||||
// Disabling unhooks and unpatches already
|
||||
for (auto const& hook : m_hooks) {
|
||||
|
@ -367,7 +374,9 @@ Result<> Mod::Impl::enable() {
|
|||
}
|
||||
}
|
||||
|
||||
Loader::get()->queueInGDThread([&]() {
|
||||
ModStateEvent(m_self, ModEventType::Enabled).post();
|
||||
});
|
||||
m_enabled = true;
|
||||
|
||||
return Ok();
|
||||
|
@ -381,7 +390,9 @@ Result<> Mod::Impl::disable() {
|
|||
return Err("Mod does not support disabling");
|
||||
}
|
||||
|
||||
Loader::get()->queueInGDThread([&]() {
|
||||
ModStateEvent(m_self, ModEventType::Disabled).post();
|
||||
});
|
||||
|
||||
for (auto const& hook : m_hooks) {
|
||||
GEODE_UNWRAP(this->disableHook(hook));
|
||||
|
|
Loading…
Reference in a new issue