From 14db94ee2d4e30055604976c5ce18ba25220c5dc Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Thu, 17 Feb 2022 17:28:52 -0600 Subject: [PATCH] Addon Manager: Correct macro display If the "download macros" preference is off, the macro will not yet have a URL to load the data from. Make sure to load the macro before attempting to display it. Also resolves the issue with macros being unable to be installed under similar circumstances. --- src/Mod/AddonManager/package_details.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Mod/AddonManager/package_details.py b/src/Mod/AddonManager/package_details.py index de21e7c812..91af473164 100644 --- a/src/Mod/AddonManager/package_details.py +++ b/src/Mod/AddonManager/package_details.py @@ -454,18 +454,23 @@ class PackageDetails(QWidget): def show_macro(self, repo: AddonManagerRepo) -> None: """loads information of a given macro""" - if HAS_QTWEBENGINE: - self.ui.webView.load(QUrl(repo.macro.url)) - self.ui.urlBar.setText(repo.macro.url) + if not repo.macro.url: + # We need to populate the macro information... may as well do it while the user reads the wiki page + self.worker = GetMacroDetailsWorker(repo) + self.worker.readme_updated.connect(self.macro_readme_updated) + self.worker.start() else: - readme_data = NetworkManager.AM_NETWORK_MANAGER.blocking_get(repo.macro.url) + self.macro_readme_updated() + + def macro_readme_updated(self): + if HAS_QTWEBENGINE: + self.ui.webView.load(QUrl(self.repo.macro.url)) + self.ui.urlBar.setText(self.repo.macro.url) + else: + readme_data = NetworkManager.AM_NETWORK_MANAGER.blocking_get(self.repo.macro.url) text = readme_data.data().decode("utf8") self.ui.textBrowserReadMe.setHtml(text) - # We need to populate the macro information... may as well do it while the user reads the wiki page - self.worker = GetMacroDetailsWorker(repo) - self.worker.start() - def run_javascript(self): """Modify the page for a README to optimize for viewing in a smaller window"""