forked from qt-creator/qt-creator
QtSupport: Use QLoggingCategory for Qt version manager
Change-Id: I27b98ff853d7b5d437cab0df61243146220dadc8 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
8ee22dd597
commit
734b6a5fdd
@@ -45,13 +45,13 @@
|
|||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QLoggingCategory>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTextStream>
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QTextStream>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -74,7 +74,7 @@ static FileSystemWatcher *m_configFileWatcher = nullptr;
|
|||||||
static QTimer *m_fileWatcherTimer = nullptr;
|
static QTimer *m_fileWatcherTimer = nullptr;
|
||||||
static PersistentSettingsWriter *m_writer = nullptr;
|
static PersistentSettingsWriter *m_writer = nullptr;
|
||||||
|
|
||||||
enum { debug = 0 };
|
static Q_LOGGING_CATEGORY(log, "qtc.qt.versions", QtWarningMsg);
|
||||||
|
|
||||||
static FilePath globalSettingsFileName()
|
static FilePath globalSettingsFileName()
|
||||||
{
|
{
|
||||||
@@ -253,14 +253,14 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
|
|||||||
if (reader.load(path))
|
if (reader.load(path))
|
||||||
data = reader.restoreValues();
|
data = reader.restoreValues();
|
||||||
|
|
||||||
if (debug) {
|
if (log().isDebugEnabled()) {
|
||||||
qDebug()<< "======= Existing Qt versions =======";
|
qCDebug(log) << "======= Existing Qt versions =======";
|
||||||
for (BaseQtVersion *version : qAsConst(m_versions)) {
|
for (BaseQtVersion *version : qAsConst(m_versions)) {
|
||||||
qDebug() << version->qmakeCommand().toString() << "id:"<<version->uniqueId();
|
qCDebug(log) << version->qmakeCommand().toString() << "id:"<<version->uniqueId();
|
||||||
qDebug() << " autodetection source:"<< version->autodetectionSource();
|
qCDebug(log) << " autodetection source:"<< version->autodetectionSource();
|
||||||
qDebug() << "";
|
qCDebug(log) << "";
|
||||||
}
|
}
|
||||||
qDebug()<< "======= Adding sdk versions =======";
|
qCDebug(log)<< "======= Adding sdk versions =======";
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList sdkVersions;
|
QStringList sdkVersions;
|
||||||
@@ -287,8 +287,7 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
|
|||||||
factory = f;
|
factory = f;
|
||||||
}
|
}
|
||||||
if (!factory) {
|
if (!factory) {
|
||||||
if (debug)
|
qCDebug(log, "Warning: Unable to find factory for type '%s'", qPrintable(type));
|
||||||
qDebug("Warning: Unable to find factory for type '%s'", qPrintable(type));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// First try to find a existing Qt version to update
|
// First try to find a existing Qt version to update
|
||||||
@@ -297,8 +296,7 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
|
|||||||
for (BaseQtVersion *v : versionsCopy) {
|
for (BaseQtVersion *v : versionsCopy) {
|
||||||
if (v->autodetectionSource() == autoDetectionSource) {
|
if (v->autodetectionSource() == autoDetectionSource) {
|
||||||
id = v->uniqueId();
|
id = v->uniqueId();
|
||||||
if (debug)
|
qCDebug(log) << " Qt version found with same autodetection source" << autoDetectionSource << " => Migrating id:" << id;
|
||||||
qDebug() << " Qt version found with same autodetection source" << autoDetectionSource << " => Migrating id:" << id;
|
|
||||||
m_versions.remove(id);
|
m_versions.remove(id);
|
||||||
qtversionMap[Constants::QTVERSIONID] = id;
|
qtversionMap[Constants::QTVERSIONID] = id;
|
||||||
qtversionMap[Constants::QTVERSIONNAME] = v->unexpandedDisplayName();
|
qtversionMap[Constants::QTVERSIONNAME] = v->unexpandedDisplayName();
|
||||||
@@ -317,8 +315,7 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
|
|||||||
}
|
}
|
||||||
// Create a new qtversion
|
// Create a new qtversion
|
||||||
if (!restored) { // didn't replace any existing versions
|
if (!restored) { // didn't replace any existing versions
|
||||||
if (debug)
|
qCDebug(log) << " No Qt version found matching" << autoDetectionSource << " => Creating new version";
|
||||||
qDebug() << " No Qt version found matching" << autoDetectionSource << " => Creating new version";
|
|
||||||
if (BaseQtVersion *qtv = factory->restore(type, qtversionMap)) {
|
if (BaseQtVersion *qtv = factory->restore(type, qtversionMap)) {
|
||||||
Q_ASSERT(qtv->isAutodetected());
|
Q_ASSERT(qtv->isAutodetected());
|
||||||
m_versions.insert(qtv->uniqueId(), qtv);
|
m_versions.insert(qtv->uniqueId(), qtv);
|
||||||
@@ -326,38 +323,37 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
|
|||||||
restored = true;
|
restored = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!restored)
|
if (!restored) {
|
||||||
if (debug)
|
qCDebug(log, "Warning: Unable to update qtversion '%s' from sdk installer.",
|
||||||
qDebug("Warning: Unable to update qtversion '%s' from sdk installer.",
|
qPrintable(autoDetectionSource));
|
||||||
qPrintable(autoDetectionSource));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) {
|
if (log().isDebugEnabled()) {
|
||||||
qDebug() << "======= Before removing outdated sdk versions =======";
|
qCDebug(log) << "======= Before removing outdated sdk versions =======";
|
||||||
for (BaseQtVersion *version : qAsConst(m_versions)) {
|
for (BaseQtVersion *version : qAsConst(m_versions)) {
|
||||||
qDebug() << version->qmakeCommand().toString() << "id:"<<version->uniqueId();
|
qCDebug(log) << version->qmakeCommand().toString() << "id:"<<version->uniqueId();
|
||||||
qDebug() << " autodetection source:"<< version->autodetectionSource();
|
qCDebug(log) << " autodetection source:"<< version->autodetectionSource();
|
||||||
qDebug() << "";
|
qCDebug(log) << "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const VersionMap versionsCopy = m_versions; // m_versions is modified in loop
|
const VersionMap versionsCopy = m_versions; // m_versions is modified in loop
|
||||||
for (BaseQtVersion *qtVersion : versionsCopy) {
|
for (BaseQtVersion *qtVersion : versionsCopy) {
|
||||||
if (qtVersion->autodetectionSource().startsWith("SDK.")) {
|
if (qtVersion->autodetectionSource().startsWith("SDK.")) {
|
||||||
if (!sdkVersions.contains(qtVersion->autodetectionSource())) {
|
if (!sdkVersions.contains(qtVersion->autodetectionSource())) {
|
||||||
if (debug)
|
qCDebug(log) << " removing version"<<qtVersion->autodetectionSource();
|
||||||
qDebug() << " removing version"<<qtVersion->autodetectionSource();
|
|
||||||
m_versions.remove(qtVersion->uniqueId());
|
m_versions.remove(qtVersion->uniqueId());
|
||||||
removed << qtVersion->uniqueId();
|
removed << qtVersion->uniqueId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) {
|
if (log().isDebugEnabled()) {
|
||||||
qDebug()<< "======= End result =======";
|
qCDebug(log)<< "======= End result =======";
|
||||||
for (BaseQtVersion *version : qAsConst(m_versions)) {
|
for (BaseQtVersion *version : qAsConst(m_versions)) {
|
||||||
qDebug() << version->qmakeCommand().toString() << "id:" << version->uniqueId();
|
qCDebug(log) << version->qmakeCommand().toString() << "id:" << version->uniqueId();
|
||||||
qDebug() << " autodetection source:"<< version->autodetectionSource();
|
qCDebug(log) << " autodetection source:"<< version->autodetectionSource();
|
||||||
qDebug() << "";
|
qCDebug(log) << "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (emitSignal)
|
if (emitSignal)
|
||||||
|
Reference in New Issue
Block a user