diff --git a/loader/include/Geode/loader/Loader.hpp b/loader/include/Geode/loader/Loader.hpp index cb63fed1..f9dd1815 100644 --- a/loader/include/Geode/loader/Loader.hpp +++ b/loader/include/Geode/loader/Loader.hpp @@ -101,7 +101,8 @@ namespace geode { void updateResources(); void updateResources(bool forceReload); - void queueInGDThread(ScheduledFunction func); + [[deprecated("use queueInMainThread instead")]] void queueInGDThread(ScheduledFunction func); + void queueInMainThread(ScheduledFunction func); void waitForModsToBeLoaded(); /** diff --git a/loader/src/hooks/LoadingLayer.cpp b/loader/src/hooks/LoadingLayer.cpp index 333b7c18..9307998c 100644 --- a/loader/src/hooks/LoadingLayer.cpp +++ b/loader/src/hooks/LoadingLayer.cpp @@ -91,7 +91,7 @@ struct CustomLoadingLayer : Modify { void loadAssets() { if (Loader::get()->getLoadingState() != Loader::LoadingState::Done) { this->updateLoadedModsLabel(); - Loader::get()->queueInGDThread([this]() { + Loader::get()->queueInMainThread([this]() { this->loadAssets(); }); return; diff --git a/loader/src/loader/Index.cpp b/loader/src/loader/Index.cpp index 0ccfc6c9..8187933a 100644 --- a/loader/src/loader/Index.cpp +++ b/loader/src/loader/Index.cpp @@ -668,7 +668,7 @@ void Index::Impl::installNext(size_t index, IndexInstallList const& list) { } auto const& eventModID = list.target->getMetadata().getID(); - Loader::get()->queueInGDThread([eventModID]() { + Loader::get()->queueInMainThread([eventModID]() { ModInstallEvent(eventModID, UpdateFinished()).post(); }); @@ -741,7 +741,7 @@ void Index::Impl::installNext(size_t index, IndexInstallList const& list) { } void Index::cancelInstall(IndexItemHandle item) { - Loader::get()->queueInGDThread([this, item]() { + Loader::get()->queueInMainThread([this, item]() { if (m_impl->m_runningInstallations.count(item)) { m_impl->m_runningInstallations.at(item)->cancel(); m_impl->m_runningInstallations.erase(item); @@ -750,13 +750,13 @@ void Index::cancelInstall(IndexItemHandle item) { } void Index::install(IndexInstallList const& list) { - Loader::get()->queueInGDThread([this, list]() { + Loader::get()->queueInMainThread([this, list]() { m_impl->installNext(0, list); }); } void Index::install(IndexItemHandle item) { - Loader::get()->queueInGDThread([this, item]() { + Loader::get()->queueInMainThread([this, item]() { if (m_impl->m_runningInstallations.count(item)) { return; } diff --git a/loader/src/loader/Loader.cpp b/loader/src/loader/Loader.cpp index 004e9695..5864c1e3 100644 --- a/loader/src/loader/Loader.cpp +++ b/loader/src/loader/Loader.cpp @@ -112,7 +112,11 @@ void Loader::updateResources(bool forceReload) { } void Loader::queueInGDThread(ScheduledFunction func) { - return m_impl->queueInGDThread(func); + return m_impl->queueInMainThread(func); +} + +void Loader::queueInMainThread(ScheduledFunction func) { + return m_impl->queueInMainThread(func); } void Loader::waitForModsToBeLoaded() { diff --git a/loader/src/loader/LoaderImpl.cpp b/loader/src/loader/LoaderImpl.cpp index 4927e1c4..0f25ff12 100644 --- a/loader/src/loader/LoaderImpl.cpp +++ b/loader/src/loader/LoaderImpl.cpp @@ -347,7 +347,7 @@ void Loader::Impl::populateModList(std::vector& modQueue) { m_mods.insert({metadata.getID(), mod}); - queueInGDThread([this, mod]() { + queueInMainThread([this, mod]() { auto searchPath = dirs::getModRuntimeDir() / mod->getID() / "resources"; CCFileUtils::get()->addSearchPath(searchPath.string().c_str()); updateModResources(mod); @@ -579,7 +579,7 @@ void Loader::Impl::refreshModGraph() { else m_loadingState = LoadingState::Mods; - queueInGDThread([]() { + queueInMainThread([]() { Loader::get()->m_impl->continueRefreshModGraph(); }); } @@ -619,7 +619,7 @@ void Loader::Impl::continueRefreshModGraph() { log::info("Took {}s", static_cast(time) / 1000.f); if (m_loadingState != LoadingState::Done) { - queueInGDThread([]() { + queueInMainThread([]() { Loader::get()->m_impl->continueRefreshModGraph(); }); } @@ -675,7 +675,7 @@ bool Loader::Impl::loadHooks() { return !thereWereErrors; } -void Loader::Impl::queueInGDThread(ScheduledFunction func) { +void Loader::Impl::queueInMainThread(ScheduledFunction func) { std::lock_guard lock(m_gdThreadMutex); m_gdThreadQueue.push_back(func); } diff --git a/loader/src/loader/LoaderImpl.hpp b/loader/src/loader/LoaderImpl.hpp index 0fe1b87d..92468f2a 100644 --- a/loader/src/loader/LoaderImpl.hpp +++ b/loader/src/loader/LoaderImpl.hpp @@ -158,7 +158,7 @@ namespace geode { json::Value processRawIPC(void* rawHandle, std::string const& buffer); - void queueInGDThread(ScheduledFunction func); + void queueInMainThread(ScheduledFunction func); void executeGDThreadQueue(); void logConsoleMessage(std::string const& msg); diff --git a/loader/src/loader/ModImpl.cpp b/loader/src/loader/ModImpl.cpp index dddce70e..7f05c554 100644 --- a/loader/src/loader/ModImpl.cpp +++ b/loader/src/loader/ModImpl.cpp @@ -155,7 +155,7 @@ std::vector Mod::Impl::getHooks() const { // Settings and saved values Result<> Mod::Impl::loadData() { - Loader::get()->queueInGDThread([&]() { + Loader::get()->queueInMainThread([&]() { ModStateEvent(m_self, ModEventType::DataLoaded).post(); }); diff --git a/loader/src/ui/internal/list/ModListCell.cpp b/loader/src/ui/internal/list/ModListCell.cpp index ba48fb89..a1951860 100644 --- a/loader/src/ui/internal/list/ModListCell.cpp +++ b/loader/src/ui/internal/list/ModListCell.cpp @@ -227,7 +227,7 @@ void ModCell::onEnable(CCObject* sender) { else { tryOrAlert(m_mod->disable(), "Error disabling mod"); } - Loader::get()->queueInGDThread([this]() { + Loader::get()->queueInMainThread([this]() { if (m_layer) { m_layer->updateAllStates(); } diff --git a/loader/src/utils/file.cpp b/loader/src/utils/file.cpp index 40b6eb4e..8df76c0d 100644 --- a/loader/src/utils/file.cpp +++ b/loader/src/utils/file.cpp @@ -602,7 +602,7 @@ Result<> file::watchFile(ghc::filesystem::path const& file) { auto watcher = std::make_unique( file, [](auto const& path) { - Loader::get()->queueInGDThread([=] { + Loader::get()->queueInMainThread([=] { FileWatchEvent(path).post(); }); } diff --git a/loader/src/utils/web.cpp b/loader/src/utils/web.cpp index 70d715c6..72ca2eea 100644 --- a/loader/src/utils/web.cpp +++ b/loader/src/utils/web.cpp @@ -277,7 +277,7 @@ SentAsyncWebRequest::Impl::Impl(SentAsyncWebRequest* self, AsyncWebRequest const } return 1; } - Loader::get()->queueInGDThread([self = data->self, now, total]() { + Loader::get()->queueInMainThread([self = data->self, now, total]() { std::lock_guard _(self->m_mutex); for (auto& prog : self->m_progresses) { prog(*self->m_self, now, total); @@ -302,7 +302,7 @@ SentAsyncWebRequest::Impl::Impl(SentAsyncWebRequest* self, AsyncWebRequest const // request, then they may still cancel it m_finished = true; - Loader::get()->queueInGDThread([this, ret]() { + Loader::get()->queueInMainThread([this, ret]() { std::lock_guard _(m_mutex); for (auto& then : m_thens) { then(*m_self, ret); @@ -329,7 +329,7 @@ void SentAsyncWebRequest::Impl::doCancel() { } } - Loader::get()->queueInGDThread([this]() { + Loader::get()->queueInMainThread([this]() { std::lock_guard _(m_mutex); for (auto& canc : m_cancelleds) { canc(*m_self); @@ -366,7 +366,7 @@ void SentAsyncWebRequest::Impl::error(std::string const& error, int code) { m_statusCV.wait(lock, [this]() { return !m_paused; }); - Loader::get()->queueInGDThread([this, error, code]() { + Loader::get()->queueInMainThread([this, error, code]() { { std::lock_guard _(m_mutex); for (auto& expect : m_expects) {