Skip to content

Commit 93a163f

Browse files
committed
fix crash + loader misbehaving
1 parent 2253498 commit 93a163f

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/Loader/Loader.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,12 @@ namespace Loader
453453
if ((addon->MD5.empty() || addon->MD5 != md5) || std::filesystem::exists(updatePath))
454454
{
455455
UpdateSwapAddon(addon->Path);
456-
QueueAddon(ELoaderAction::Reload, addon->Path);
456+
457+
// only reload if it already is loadedw
458+
if (addon->State == EAddonState::Loaded)
459+
{
460+
QueueAddon(ELoaderAction::Reload, addon->Path);
461+
}
457462
}
458463
}
459464

@@ -704,7 +709,7 @@ namespace Loader
704709
std::filesystem::path tmpPath = aPath.string();
705710
std::thread([tmpPath, addon, locked, shouldLoad, onlyInitialLaunch]()
706711
{
707-
Sleep(5000);
712+
bool lShouldLoad = shouldLoad;
708713
if (UpdateAddon(tmpPath, addon->Definitions->Signature, addon->Definitions->Name,
709714
addon->Definitions->Version, addon->Definitions->Provider,
710715
addon->Definitions->UpdateLink != nullptr ? addon->Definitions->UpdateLink : ""))
@@ -714,6 +719,7 @@ namespace Loader
714719
{
715720
// reset state, because it updated
716721
addon->IsDisabledUntilUpdate = false;
722+
lShouldLoad = true;
717723

718724
// mutex because we're async/threading
719725
{
@@ -723,19 +729,22 @@ namespace Loader
723729
}
724730

725731
/* only call reload if it wasn't unloaded */
726-
if (!onlyInitialLaunch)
732+
if (lShouldLoad)
727733
{
728-
QueueAddon(ELoaderAction::Reload, tmpPath);
729-
}
730-
else
731-
{
732-
std::string msg = addon->Definitions->Name;
733-
msg.append(" ");
734-
msg.append(Language.Translate("((000079))"));
735-
GUI::Alerts::Notify(msg.c_str());
734+
if (!onlyInitialLaunch)
735+
{
736+
QueueAddon(ELoaderAction::Reload, tmpPath);
737+
}
738+
else
739+
{
740+
std::string msg = addon->Definitions->Name;
741+
msg.append(" ");
742+
msg.append(Language.Translate("((000079))"));
743+
GUI::Alerts::Notify(msg.c_str());
744+
}
736745
}
737746
}
738-
else if (locked && shouldLoad && !addon->IsDisabledUntilUpdate) // if addon is locked and not DUU
747+
else if (locked && lShouldLoad && !addon->IsDisabledUntilUpdate) // if addon is locked and not DUU
739748
{
740749
// the lock state is checked because if it will be locked it means it was unloaded, prior to checking for an update
741750

0 commit comments

Comments
 (0)