mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -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
15
loader/include/Geode/cocos/cocoa/CCObject.h
vendored
15
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 {
|
||||
PlayLayer = 5,
|
||||
LevelEditorLayer = 6,
|
||||
MenuLayer = 15,
|
||||
};
|
||||
)
|
||||
// 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() {
|
||||
ModStateEvent(m_self, ModEventType::DataLoaded).post();
|
||||
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();
|
||||
|
||||
ModStateEvent(m_self, ModEventType::Loaded).post();
|
||||
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());
|
||||
ModStateEvent(m_self, ModEventType::Unloaded).post();
|
||||
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() {
|
|||
}
|
||||
}
|
||||
|
||||
ModStateEvent(m_self, ModEventType::Enabled).post();
|
||||
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");
|
||||
}
|
||||
|
||||
ModStateEvent(m_self, ModEventType::Disabled).post();
|
||||
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