From 346aa261799bd615b67d931a5018b762b8a38fe2 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Fri, 4 Oct 2024 12:28:59 +0200 Subject: [PATCH] WIP: temporary fix for Windows build and disabled debug for testing --- src/app/CMakeLists.txt | 2 +- src/app/downloadmanager.cpp | 22 +++++++++++----------- src/app/releasemanager.cpp | 24 ++++++++++++------------ src/helper/win/CMakeLists.txt | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 75fdf759..9449894a 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -55,7 +55,7 @@ if (WIN32) # HACK: we need to remove -std=c++11 definition for manifest file, otherwise # it will complain about undefined option "s" (as first letter from -Std=c++11) remove_definitions(-std=c++11) - target_sources(mediawriter PRIVATE data/windows.rc) + # target_sources(mediawriter PRIVATE data/windows.rc) endif() if (APPLE) diff --git a/src/app/downloadmanager.cpp b/src/app/downloadmanager.cpp index c79ed368..c81c4470 100644 --- a/src/app/downloadmanager.cpp +++ b/src/app/downloadmanager.cpp @@ -63,14 +63,14 @@ QString DownloadManager::userAgent() */ QString DownloadManager::downloadFile(DownloadReceiver *receiver, const QUrl &url, const QString &folder, Progress *progress) { - mDebug() << this->metaObject()->className() << "Going to download" << url; + // mDebug() << this->metaObject()->className() << "Going to download" << url; QString bareFileName = QString("%1/%2").arg(folder).arg(url.fileName()); QDir dir; dir.mkpath(folder); if (QFile::exists(bareFileName)) { - mDebug() << this->metaObject()->className() << "The file already exists on" << bareFileName; + // mDebug() << this->metaObject()->className() << "The file already exists on" << bareFileName; return bareFileName; } @@ -133,7 +133,7 @@ void DownloadManager::cancel() if (m_current) { m_current->deleteLater(); m_current = nullptr; - mDebug() << this->metaObject()->className() << "Cancelling"; + // mDebug() << this->metaObject()->className() << "Cancelling"; } } @@ -149,7 +149,7 @@ void DownloadManager::onStringDownloaded(const QString &text) if (!m_current) return; - mDebug() << this->metaObject()->className() << "Received a list of mirrors"; + // mDebug() << this->metaObject()->className() << "Received a list of mirrors"; QStringList mirrors; for (const QString &i : text.split("\n")) { @@ -199,7 +199,7 @@ void DownloadManager::onDownloadError(const QString &message) DownloadManager::DownloadManager() { - mDebug() << this->metaObject()->className() << "User-Agent:" << userAgent(); + // mDebug() << this->metaObject()->className() << "User-Agent:" << userAgent(); QNetworkProxyFactory::setUseSystemConfiguration(true); } @@ -235,7 +235,7 @@ void Download::handleNewReply(QNetworkReply *reply) m_receiver->onDownloadError(tr("Unable to fetch the requested image.")); return; } - mDebug() << this->metaObject()->className() << "Trying to download from a mirror:" << reply->url(); + // mDebug() << this->metaObject()->className() << "Trying to download from a mirror:" << reply->url(); if (m_reply) m_reply->deleteLater(); @@ -275,14 +275,14 @@ bool Download::hasCatchedUp() void Download::start() { if (m_catchingUp) { - mDebug() << this->metaObject()->className() << "Will need to precompute the hash of the previously downloaded part"; + // mDebug() << this->metaObject()->className() << "Will need to precompute the hash of the previously downloaded part"; // first precompute the SHA hash of the already downloaded part m_file->open(QIODevice::ReadOnly); m_previousSize = 0; QTimer::singleShot(0, this, SLOT(catchUp())); } else if (!m_path.isEmpty()) { - mDebug() << this->metaObject()->className() << "Creating a new empty file"; + // mDebug() << this->metaObject()->className() << "Creating a new empty file"; m_file->open(QIODevice::WriteOnly); } } @@ -299,7 +299,7 @@ void Download::catchUp() if (!m_file->atEnd()) { QTimer::singleShot(0, this, SLOT(catchUp())); } else { - mDebug() << this->metaObject()->className() << "Finished computing the hash of the downloaded part"; + // mDebug() << this->metaObject()->className() << "Finished computing the hash of the downloaded part"; m_file->close(); m_file->open(QIODevice::Append); m_catchingUp = false; @@ -372,7 +372,7 @@ void Download::onFinished() { m_timer.stop(); if (m_reply->error() != 0) { - mDebug() << this->metaObject()->className() << "An error occurred at the end:" << m_reply->errorString(); + // mDebug() << this->metaObject()->className() << "An error occurred at the end:" << m_reply->errorString(); if (m_file && m_file->size() == 0) { m_file->remove(); } @@ -381,7 +381,7 @@ void Download::onFinished() onReadyRead(); qApp->eventDispatcher()->processEvents(QEventLoop::ExcludeSocketNotifiers); } - mDebug() << this->metaObject()->className() << "Finished successfully"; + // mDebug() << this->metaObject()->className() << "Finished successfully"; if (m_file) { m_file->close(); m_receiver->onFileDownloaded(m_file->fileName(), m_hash.result().toHex()); diff --git a/src/app/releasemanager.cpp b/src/app/releasemanager.cpp index 516bd764..622e9087 100644 --- a/src/app/releasemanager.cpp +++ b/src/app/releasemanager.cpp @@ -34,7 +34,7 @@ ReleaseManager::ReleaseManager(QObject *parent) : QSortFilterProxyModel(parent) , m_sourceModel(new ReleaseListModel(this)) { - mDebug() << this->metaObject()->className() << "construction"; + // mDebug() << this->metaObject()->className() << "construction"; setSourceModel(m_sourceModel); qmlRegisterUncreatableType("MediaWriter", 1, 0, "Release", ""); @@ -155,7 +155,7 @@ int ReleaseManager::firstSource() const void ReleaseManager::selectLocalFile(const QString &path) { - mDebug() << this->metaObject()->className() << "Setting local file to" << path; + // mDebug() << this->metaObject()->className() << "Setting local file to" << path; for (int i = 0; i < m_sourceModel->rowCount(); i++) { Release *r = m_sourceModel->get(i); if (r->source() == Release::LOCAL) { @@ -268,7 +268,7 @@ ReleaseVariant *ReleaseManager::variant() void ReleaseManager::onStringDownloaded(const QString &text) { - mDebug() << this->metaObject()->className() << "Received a metadata json"; + // mDebug() << this->metaObject()->className() << "Received a metadata json"; QRegularExpression re("(\\d+)\\s?(\\S+)?"); auto doc = QJsonDocument::fromJson(text.toUtf8()); @@ -315,7 +315,7 @@ void ReleaseManager::onStringDownloaded(const QString &text) version = re.match(versionWithStatus).captured(1).toInt(); status = re.match(versionWithStatus).captured(2); - mDebug() << this->metaObject()->className() << "Adding" << release << versionWithStatus << arch; + // mDebug() << this->metaObject()->className() << "Adding" << release << versionWithStatus << arch; if (!release.isEmpty() && !url.isEmpty() && !arch.isEmpty()) updateUrl(release, version, status, type, category, releaseDate, arch, url, sha256, size); @@ -819,13 +819,13 @@ bool ReleaseVariant::updateUrl(const QString &url, const QString &sha256, int64_ { bool changed = false; if (!url.isEmpty() && m_url.toUtf8().trimmed() != url.toUtf8().trimmed()) { - mWarning() << "Url" << m_url << "changed to" << url; + // mWarning() << "Url" << m_url << "changed to" << url; m_url = url; emit urlChanged(); changed = true; } if (!sha256.isEmpty() && m_shaHash.trimmed() != sha256.trimmed()) { - mWarning() << "SHA256 hash of" << url << "changed from" << m_shaHash << "to" << sha256; + // mWarning() << "SHA256 hash of" << url << "changed from" << m_shaHash << "to" << sha256; m_shaHash = sha256; emit shaHashChanged(); changed = true; @@ -963,7 +963,7 @@ void ReleaseVariant::onFileDownloaded(const QString &path, const QString &hash) setStatus(FAILED_DOWNLOAD); return; } - mDebug() << this->metaObject()->className() << "SHA256 check passed"; + // mDebug() << this->metaObject()->className() << "SHA256 check passed"; qApp->eventDispatcher()->processEvents(QEventLoop::AllEvents); @@ -979,12 +979,12 @@ void ReleaseVariant::onFileDownloaded(const QString &path, const QString &hash) setStatus(FAILED_DOWNLOAD); return; } else { - mDebug() << this->metaObject()->className() << "MD5 check passed"; + // mDebug() << this->metaObject()->className() << "MD5 check passed"; QString finalFilename(path); finalFilename = finalFilename.replace(QRegularExpression("[.]part$"), ""); if (finalFilename != path) { - mDebug() << this->metaObject()->className() << "Renaming from" << path << "to" << finalFilename; + // mDebug() << this->metaObject()->className() << "Renaming from" << path << "to" << finalFilename; if (!QFile::rename(path, finalFilename)) { setErrorString(tr("Unable to rename the temporary file.")); setStatus(FAILED_DOWNLOAD); @@ -995,7 +995,7 @@ void ReleaseVariant::onFileDownloaded(const QString &path, const QString &hash) m_iso = finalFilename; emit isoChanged(); - mDebug() << this->metaObject()->className() << "Image is ready"; + // mDebug() << this->metaObject()->className() << "Image is ready"; setStatus(READY); if (QFile(m_iso).size() != m_size) { @@ -1039,7 +1039,7 @@ void ReleaseVariant::download() m_iso = ret; emit isoChanged(); - mDebug() << this->metaObject()->className() << m_iso << "is already downloaded"; + // mDebug() << this->metaObject()->className() << m_iso << "is already downloaded"; setStatus(READY); if (QFile(m_iso).size() != m_size) { @@ -1068,7 +1068,7 @@ void ReleaseVariant::resetStatus() bool ReleaseVariant::erase() { if (QFile(m_iso).remove()) { - mDebug() << this->metaObject()->className() << "Deleted" << m_iso; + // mDebug() << this->metaObject()->className() << "Deleted" << m_iso; m_iso = QString(); emit isoChanged(); return true; diff --git a/src/helper/win/CMakeLists.txt b/src/helper/win/CMakeLists.txt index 60695802..50e8d5f7 100644 --- a/src/helper/win/CMakeLists.txt +++ b/src/helper/win/CMakeLists.txt @@ -21,7 +21,7 @@ add_executable(helper ${HELPER_SRCS}) # HACK: we need to remove -std=c++11 definition for manifest file, otherwise # it will complain about undefined option "s" (as first letter from -Std=c++11) remove_definitions(-std=c++17) -target_sources(helper PRIVATE helper.exe.rc) +#target_sources(helper PRIVATE helper.exe.rc) target_link_libraries(helper Qt6::Core