From 931fe6c22daad7c6394e452c00c3aa12c0d7a5e1 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Fri, 17 Jul 2026 15:12:30 -0500 Subject: [PATCH] Harden the ClassicAPI-missing path so the disable notice can show pfUI's TOC depends on the !!!ClassicAPI addon, so a nil CLASSIC_API_VERSION means the addon loaded but the DLL isn't present -- yet the graceful-disable branch itself called ClassicAPI APIs (EventUtil.ContinueOnPlayerLogin, and Mixin/CallbackRegistryMixin for pfUI.events), so it crashed instead of informing the user. - Defer the popup with a bare PLAYER_ENTERING_WORLD frame (stock 1.12) instead of EventUtil/IsLoggedIn/PLAYER_LOGIN (ClassicAPI-era). - Read the editbox via getglobal rather than _G. - Guard pfUI.events creation behind `not pfUI.disabled`. - Reword the notice: since the addon is present but the DLL isn't (or is outdated), tell the user the addon ships bundled with the DLL and to delete the !!!ClassicAPI folder and (re)install the latest release. --- pfUI.lua | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/pfUI.lua b/pfUI.lua index 5e9634d9..924cb4c4 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -36,9 +36,16 @@ do if not CLASSIC_API_VERSION or CLASSIC_API_VERSION < PFUI_CLASSIC_API_MIN then local minVersion = FormatVersion(PFUI_CLASSIC_API_MIN) pfUI.disabled = true - EventUtil.ContinueOnPlayerLogin(function() + local detail + if not CLASSIC_API_VERSION then + detail = "The ClassicAPI DLL isn't loaded. The |cff33ffcc!!!ClassicAPI|r addon ships bundled with it -- delete your |cff33ffcc!!!ClassicAPI|r folder and install the latest release from:" + else + detail = "ClassicAPI " .. minVersion .. " or newer is required. Delete your |cff33ffcc!!!ClassicAPI|r folder and reinstall the latest release from:" + end + + local function ShowRequiredPopup() StaticPopupDialogs["PFUI_CLASSICAPI_REQUIRED"] = { - text = "This fork of |cff33ffccpf|cffffffffUI|r requires ClassicAPI\n " .. minVersion .. " or newer.\n\nAll |cff33ffccpf|cffffffffUI|r modules have been disabled.\nInstall ClassicAPI from:", + text = "|cff33ffccpf|cffffffffUI|r has been disabled.\n\n" .. detail, button1 = OKAY, hasEditBox = 1, editBoxWidth = 280, @@ -47,7 +54,7 @@ do hideOnEscape = 1, preferredIndex = 3, OnShow = function() - local editBox = _G[this:GetName().."EditBox"] + local editBox = getglobal(this:GetName().."EditBox") if editBox then editBox:SetText(PFUI_CLASSIC_API_LATEST_URL) editBox:HighlightText() @@ -57,9 +64,15 @@ do } StaticPopup_Show("PFUI_CLASSICAPI_REQUIRED") DEFAULT_CHAT_FRAME:AddMessage( - "This fork of |cff33ffccpf|cffffffffUI|r requires ClassicAPI " .. minVersion .. "+. Get it at " .. PFUI_CLASSIC_API_LATEST_URL, + "|cff33ffccpf|cffffffffUI|r disabled: " .. detail .. " " .. PFUI_CLASSIC_API_LATEST_URL, 1, 0.3, 0.3 ) + end + local loginFrame = CreateFrame("Frame") + loginFrame:RegisterEvent("PLAYER_ENTERING_WORLD") + loginFrame:SetScript("OnEvent", function() + loginFrame:UnregisterEvent("PLAYER_ENTERING_WORLD") + ShowRequiredPopup() end) elseif CLASSIC_API_VERSION < PFUI_CLASSIC_API_LATEST then EventUtil.ContinueOnPlayerLogin(function() @@ -97,9 +110,11 @@ pfUI.movables = {} pfUI.version = {} pfUI.env = {} -pfUI.events = Mixin({}, CallbackRegistryMixin) -pfUI.events:OnLoad() -pfUI.events:SetUndefinedEventsAllowed(true) +if not pfUI.disabled then + pfUI.events = Mixin({}, CallbackRegistryMixin) + pfUI.events:OnLoad() + pfUI.events:SetUndefinedEventsAllowed(true) +end -- check if macro addons are loaded (disables macrotweak/macroscan) function pfUI:MacroAddonsLoaded()