From cee8828dfb9b763262bc32dc997683f85cf316c1 Mon Sep 17 00:00:00 2001 From: Trevor SANDY Date: Sun, 28 May 2023 18:33:03 +0200 Subject: [PATCH] Blender LDraw Render - refactor get Blender addon version match #416 --- builds/linux/obs/PKGBUILD | 2 +- builds/linux/obs/alldeps/PKGBUILD | 2 +- builds/linux/obs/alldeps/debian/changelog | 6 +- builds/linux/obs/alldeps/debian/lpub3d.dsc | 2 +- builds/linux/obs/alldeps/lpub3d.spec | 4 +- builds/linux/obs/debian/changelog | 6 +- builds/linux/obs/debian/lpub3d.dsc | 2 +- builds/linux/obs/lpub3d.spec | 4 +- builds/utilities/version.info | 2 +- gitversion.pri | 6 +- mainApp/blenderpreferences.cpp | 92 +++++++++++++--------- mainApp/docs/README.txt | 2 +- mainApp/docs/RELEASE_NOTES.html | 2 +- mainApp/extras/LPub3D_Npp_UDL.xml | 4 +- 14 files changed, 77 insertions(+), 59 deletions(-) diff --git a/builds/linux/obs/PKGBUILD b/builds/linux/obs/PKGBUILD index cf6b3faaa..459f26471 100755 --- a/builds/linux/obs/PKGBUILD +++ b/builds/linux/obs/PKGBUILD @@ -2,7 +2,7 @@ # Last Update: July 19, 2020 # Copyright (C) 2017 - 2023 by Trevor SANDY pkgname=lpub3d -pkgver=2.4.6.3385 +pkgver=2.4.6.3386 pkgrel=1 pkgdesc="An LDraw Building Instruction Editor" url="https://github.com/trevorsandy/lpub3d.git" diff --git a/builds/linux/obs/alldeps/PKGBUILD b/builds/linux/obs/alldeps/PKGBUILD index afff6c933..63bb0bd9e 100644 --- a/builds/linux/obs/alldeps/PKGBUILD +++ b/builds/linux/obs/alldeps/PKGBUILD @@ -2,7 +2,7 @@ # Last Update: July 19, 2020 # Copyright (C) 2017 - 2023 by Trevor SANDY pkgname=lpub3d -pkgver=2.4.6.3385 +pkgver=2.4.6.3386 pkgrel=1 pkgdesc="An LDraw Building Instruction Editor" url="https://github.com/trevorsandy/lpub3d.git" diff --git a/builds/linux/obs/alldeps/debian/changelog b/builds/linux/obs/alldeps/debian/changelog index ba9da310f..a7cc10c7a 100644 --- a/builds/linux/obs/alldeps/debian/changelog +++ b/builds/linux/obs/alldeps/debian/changelog @@ -1,5 +1,5 @@ -lpub3d (2.4.6.3385) debian; urgency=medium +lpub3d (2.4.6.3386) debian; urgency=medium - * LPub3D version 2.4.6.274.3385_20230528 for Linux + * LPub3D version 2.4.6.275.3386_20230528 for Linux - -- Trevor SANDY Sun, 28 May 2023 18:31:04 +0200 + -- Trevor SANDY Sun, 28 May 2023 18:33:06 +0200 diff --git a/builds/linux/obs/alldeps/debian/lpub3d.dsc b/builds/linux/obs/alldeps/debian/lpub3d.dsc index 80c53ee63..d8c9cdd47 100644 --- a/builds/linux/obs/alldeps/debian/lpub3d.dsc +++ b/builds/linux/obs/alldeps/debian/lpub3d.dsc @@ -2,7 +2,7 @@ Format: 1.0 Source: lpub3d Binary: lpub3d Architecture: any -Version: 2.4.6.3385 +Version: 2.4.6.3386 Maintainer: Trevor SANDY Homepage: https://trevorsandy.github.io/lpub3d/ Standards-Version: 3.9.7 diff --git a/builds/linux/obs/alldeps/lpub3d.spec b/builds/linux/obs/alldeps/lpub3d.spec index 40f4e2251..c81794ac1 100644 --- a/builds/linux/obs/alldeps/lpub3d.spec +++ b/builds/linux/obs/alldeps/lpub3d.spec @@ -120,7 +120,7 @@ BuildRequires: fdupes Summary: An LDraw Building Instruction Editor Name: lpub3d Icon: lpub3d.xpm -Version: 2.4.6.3385 +Version: 2.4.6.3386 Release: %{?dist} URL: https://trevorsandy.github.io/lpub3d Vendor: Trevor SANDY @@ -797,7 +797,7 @@ update-desktop-database || true %endif %changelog -* Sun May 28 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3385 +* Sun May 28 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3386 - LPub3D 2.4.4 enhancements and fixes - see RELEASE_NOTES for details * Tue May 31 2022 - trevor dot sandy at gmail dot com 2.4.4.2670 diff --git a/builds/linux/obs/debian/changelog b/builds/linux/obs/debian/changelog index 54e3885b9..0664bc14d 100644 --- a/builds/linux/obs/debian/changelog +++ b/builds/linux/obs/debian/changelog @@ -1,5 +1,5 @@ -lpub3d (2.4.6.3385) debian; urgency=medium +lpub3d (2.4.6.3386) debian; urgency=medium - * LPub3D version 2.4.6.274.3385_20230528 for Linux + * LPub3D version 2.4.6.275.3386_20230528 for Linux - -- Trevor SANDY Sun, 28 May 2023 18:31:05 +0200 + -- Trevor SANDY Sun, 28 May 2023 18:33:07 +0200 diff --git a/builds/linux/obs/debian/lpub3d.dsc b/builds/linux/obs/debian/lpub3d.dsc index b5897dff8..bb2278260 100755 --- a/builds/linux/obs/debian/lpub3d.dsc +++ b/builds/linux/obs/debian/lpub3d.dsc @@ -2,7 +2,7 @@ Format: 1.0 Source: lpub3d Binary: lpub3d Architecture: any -Version: 2.4.6.3385 +Version: 2.4.6.3386 Maintainer: Trevor SANDY Homepage: https://trevorsandy.github.io/lpub3d/ Standards-Version: 3.9.7 diff --git a/builds/linux/obs/lpub3d.spec b/builds/linux/obs/lpub3d.spec index c74851e0e..fafc55153 100755 --- a/builds/linux/obs/lpub3d.spec +++ b/builds/linux/obs/lpub3d.spec @@ -82,7 +82,7 @@ BuildRequires: fdupes Summary: An LDraw Building Instruction Editor Name: lpub3d Icon: lpub3d.xpm -Version: 2.4.6.3385 +Version: 2.4.6.3386 Release: 1%{?dist} URL: https://trevorsandy.github.io/lpub3d Vendor: Trevor SANDY @@ -313,7 +313,7 @@ update-desktop-database || true %endif %changelog -* Sun May 28 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3385 +* Sun May 28 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3386 - LPub3D 2.4.4 enhancements and fixes - see RELEASE_NOTES for details * Tue May 31 2022 - trevor dot sandy at gmail dot com 2.4.4.2670 diff --git a/builds/utilities/version.info b/builds/utilities/version.info index 8bb3ca94c..e6be2ef90 100755 --- a/builds/utilities/version.info +++ b/builds/utilities/version.info @@ -1 +1 @@ -2 4 6 274 3385 d787e6efb +2 4 6 275 3386 fd5427028 diff --git a/gitversion.pri b/gitversion.pri index 3060a3999..d771f5211 100644 --- a/gitversion.pri +++ b/gitversion.pri @@ -41,7 +41,7 @@ equals(GIT_DIR, undefined) { # Check if we do not have a valid version number (i.e. no version tag found) isEmpty(GIT_VERSION) { - GIT_REVISION = 274 + GIT_REVISION = 275 GIT_SHA = $$system($$GIT_BASE_COMMAND rev-parse --short HEAD 2> $$NULL_DEVICE) GIT_COMMIT = $$system($$GIT_BASE_COMMAND rev-list --count HEAD 2> $$NULL_DEVICE) GIT_VERSION = v$${VERSION}-$${GIT_REVISION}-$${GIT_SHA} @@ -69,7 +69,7 @@ equals(GIT_DIR, undefined) { # Get commit count GIT_COMMIT = $$system($$GIT_BASE_COMMAND rev-list --count HEAD 2> $$NULL_DEVICE) isEmpty(GIT_COMMIT) { - GIT_COMMIT = 3385 + GIT_COMMIT = 3386 message("~~~ ERROR! GIT_COMMIT NOT DEFINED, USING $$GIT_COMMIT ~~~") } @@ -117,7 +117,7 @@ if (equals(USE_GIT_VER_FILE, true)|equals(USE_VERSION_INFO_VAR, true)) { GIT_VERSION = $$cat($$GIT_VER_FILE, lines) } else { message("~~~ ERROR! $$GIT_DIR_ENV VERSION_INFO FILE $$GIT_VER_FILE NOT FOUND ~~~") - GIT_VERSION = $${VERSION}.274.3385.d787e6efb + GIT_VERSION = $${VERSION}.275.3386.fd5427028 message("~~~ GIT_DIR [$$GIT_DIR_ENV, USING VERSION] $$GIT_VERSION ~~~") GIT_VERSION ~= s/\./" " } diff --git a/mainApp/blenderpreferences.cpp b/mainApp/blenderpreferences.cpp index 0dc8db141..4e7b7a710 100644 --- a/mainApp/blenderpreferences.cpp +++ b/mainApp/blenderpreferences.cpp @@ -1272,19 +1272,24 @@ bool BlenderPreferences::extractBlenderAddon(const QString &blenderDir) bool BlenderPreferences::getBlenderAddon(const QString &blenderDir) { - enum BlenderAddOnUpdate + enum AddonEnc { - BLENDER_ADDON_FAIL = -1, - BLENDER_ADDON_DOWNLOAD, - BLENDER_ADDON_RELOAD, - BLENDER_ADDON_CANCEL + ADDON_FAIL = -1, + ADDON_NOT_FOUND, + ADDON_DOWNLOAD = ADDON_NOT_FOUND, + ADDON_ARCHIVE, + ADDON_EXTRACTED, + ADDON_RELOAD, + ADDON_CANCEL }; - QString const blenderAddonDir = QDir::toNativeSeparators(QString("%1/addons").arg(blenderDir)); - QString const blenderAddonFile = QDir::toNativeSeparators(QString("%1/%2").arg(blenderDir).arg(VER_BLENDER_ADDON_FILE)); - bool blenderAddonExists = QFileInfo(blenderAddonFile).isReadable(); - QString status = tr("Installing Blender addon..."); - BlenderAddOnUpdate AddOnUpdate = BLENDER_ADDON_DOWNLOAD; + QString const blenderAddonDir = QDir::toNativeSeparators(QString("%1/addons").arg(blenderDir)); + QString const blenderAddonFile = QDir::toNativeSeparators(QString("%1/%2").arg(blenderDir).arg(VER_BLENDER_ADDON_FILE)); + QString const addonVersionFile = QDir::toNativeSeparators(QString("%1/%2/__version__.py").arg(blenderAddonDir).arg(BLENDER_RENDER_ADDON)); + bool extractedAddon = QFileInfo(addonVersionFile).isReadable(); + bool blenderAddonExists = extractedAddon || QFileInfo(blenderAddonFile).isReadable(); + QString status = tr("Installing Blender addon..."); + AddonEnc addonAction = ADDON_DOWNLOAD; QString localVersion, onlineVersion; using namespace std; @@ -1313,26 +1318,42 @@ bool BlenderPreferences::getBlenderAddon(const QString &blenderDir) auto getBlenderAddonVersionMatch = [&] () { - QuaZip zip(blenderAddonFile); - if (!zip.open(QuaZip::mdUnzip)) { - QString const result = tr("Could not open archive to check content. Return code %1.
" - "Archive file %2 may be open in another program.") - .arg(zip.getZipError()).arg(QFileInfo(blenderAddonFile).fileName()); - emit gui->messageSig(LOG_WARNING, result); - return false; // Download new archive - } + QByteArray ba; + if (!extractedAddon) { + QuaZip zip(blenderAddonFile); + if (!zip.open(QuaZip::mdUnzip)) { + QString const result = tr("Could not open archive to check content. Return code %1.
" + "Archive file %2 may be open in another program.") + .arg(zip.getZipError()).arg(QFileInfo(blenderAddonFile).fileName()); + emit gui->messageSig(LOG_WARNING, result); + return false; // Download new archive + } - QString const versionFile = QString("addons/%1/__version__.py").arg(BLENDER_RENDER_ADDON); - zip.setCurrentFile(versionFile); - QuaZipFile file(&zip); - if (!file.open(QIODevice::ReadOnly)) { - emit gui->messageSig(LOG_ERROR, QObject::tr("Cannot read addon archive file: [%1]
%2.") - .arg(versionFile) - .arg(file.errorString())); - return false; // Download new archive + QString const addonVersionFile = QString("addons/%1/__version__.py").arg(BLENDER_RENDER_ADDON); + zip.setCurrentFile(addonVersionFile); + QuaZipFile file(&zip); + if (!file.open(QIODevice::ReadOnly)) { + emit gui->messageSig(LOG_ERROR, QObject::tr("Cannot read addon archive version file: [%1]
%2.") + .arg(addonVersionFile) + .arg(file.errorString())); + return false; // Download new archive + } + ba = file.readAll(); + file.close(); + zip.close(); + if (zip.getZipError() != UNZ_OK) + emit gui->messageSig(LOG_WARNING, tr("Archive close error. Return code %1.").arg(zip.getZipError())); + } else { + QFile file(addonVersionFile); + if (!file.open(QIODevice::ReadOnly)) { + emit gui->messageSig(LOG_ERROR, QObject::tr("Cannot read addon version file: [%1]
%2.") + .arg(addonVersionFile) + .arg(file.errorString())); + return false; // Download new archive + } + ba = file.readAll(); + file.close(); } - QByteArray ba = file.readAll(); - file.close(); QTextStream content(ba.data()); while (!content.atEnd()) @@ -1344,9 +1365,6 @@ bool BlenderPreferences::getBlenderAddon(const QString &blenderDir) localVersion = content.readAll().trimmed().replace("(","v").replace(",",".").replace(" ","").replace(")",""); } } - zip.close(); - if (zip.getZipError() != UNZ_OK) - emit gui->messageSig(LOG_WARNING, tr("Archive close error. Return code %1.").arg(zip.getZipError())); lpub->downloadFile(VER_BLENDER_ADDON_LATEST_URL, tr("Latest Addon"),false/*promptRedirect*/,false/*showProgress*/); QByteArray response_data = lpub->getDownloadedFile(); @@ -1368,7 +1386,7 @@ bool BlenderPreferences::getBlenderAddon(const QString &blenderDir) if (blenderAddonExists) { if (getBlenderAddonVersionMatch()) { - AddOnUpdate = BLENDER_ADDON_RELOAD; + addonAction = ADDON_RELOAD; } else if (Preferences::modeGUI) { QPixmap _icon = QPixmap(":/icons/lpub96.png"); if (_icon.isNull()) @@ -1390,18 +1408,18 @@ bool BlenderPreferences::getBlenderAddon(const QString &blenderDir) int execReturn = box.exec(); if (execReturn == QMessageBox::Cancel) { status = tr("Blender addon setup cancelled"); - AddOnUpdate = BLENDER_ADDON_CANCEL; + addonAction = ADDON_CANCEL; } else if (execReturn == QMessageBox::No) { - AddOnUpdate = BLENDER_ADDON_RELOAD; + addonAction = ADDON_RELOAD; } } - if (AddOnUpdate == BLENDER_ADDON_DOWNLOAD) + if (addonAction == ADDON_DOWNLOAD) status = tr("Download addon..."); gAddonPreferences->statusUpdate(true/*addon*/, false/*error*/,status); - if (AddOnUpdate == BLENDER_ADDON_CANCEL) { + if (addonAction == ADDON_CANCEL) { gAddonPreferences->mDialogCancelled = true; return false; } @@ -1428,7 +1446,7 @@ bool BlenderPreferences::getBlenderAddon(const QString &blenderDir) } // Download Blender addon - if (AddOnUpdate == BLENDER_ADDON_DOWNLOAD) { + if (addonAction == ADDON_DOWNLOAD) { blenderAddonExists = false; lpub->downloadFile(VER_BLENDER_ADDON_URL, tr("Blender Addon"),false/*promptRedirect*/,false/*showProgress*/); QByteArray Buffer = lpub->getDownloadedFile(); diff --git a/mainApp/docs/README.txt b/mainApp/docs/README.txt index 95fe548a1..f1d78ae71 100755 --- a/mainApp/docs/README.txt +++ b/mainApp/docs/README.txt @@ -1,4 +1,4 @@ -LPub3D 2.4.6.274.3385 (28 05 2023 18:31:05) +LPub3D 2.4.6.275.3386 (28 05 2023 18:33:07) Features, enhancements, fixes and changes ------------ diff --git a/mainApp/docs/RELEASE_NOTES.html b/mainApp/docs/RELEASE_NOTES.html index 26c4df68e..1514e6cd7 100644 --- a/mainApp/docs/RELEASE_NOTES.html +++ b/mainApp/docs/RELEASE_NOTES.html @@ -18,7 +18,7 @@
-

LPub3D 2.4.6.274.3385 (28 05 2023 18:31:05)

+

LPub3D 2.4.6.275.3386 (28 05 2023 18:33:07)


LPub3D Official release.
diff --git a/mainApp/extras/LPub3D_Npp_UDL.xml b/mainApp/extras/LPub3D_Npp_UDL.xml index f1863fb59..516740209 100644 --- a/mainApp/extras/LPub3D_Npp_UDL.xml +++ b/mainApp/extras/LPub3D_Npp_UDL.xml @@ -14,8 +14,8 @@ ;; ;; Author......: Trevor SANDY ;; Name........: LPub3D_Npp_UDL.xml -;; Version.....: 2.4.6.274.3385 -;; Last Update.: Sun, 28 May 2023 18:31:05 +0200 +;; Version.....: 2.4.6.275.3386 +;; Last Update.: Sun, 28 May 2023 18:33:07 +0200 ;; License.....: GPLv3 ;; Homepage....: https://trevorsandy.github.io/lpub3d ;; Copyright (C) 2021 - 2023 by Trevor SANDY