Commit fdc552bd authored by Christian Kandeler's avatar Christian Kandeler

QbsProjectManager: Fine-tune project parse result handling.

And add some log output to help with debugging.

Change-Id: I806aee8b34ee8d90bdd40fa8d9ac2cd313485c28
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent 9f15f707
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "qbspmlogging.h"
namespace QbsProjectManager {
namespace Internal {
Q_LOGGING_CATEGORY(qbsPmLog, "qtc.qbspm")
}
}
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#ifndef QBSPMLOGGING_P_H
#define QBSPMLOGGING_P_H
#include <QLoggingCategory>
namespace QbsProjectManager {
namespace Internal {
Q_DECLARE_LOGGING_CATEGORY(qbsPmLog)
}
}
#endif // Include guard
......@@ -27,6 +27,7 @@
#include "qbsbuildconfiguration.h"
#include "qbslogsink.h"
#include "qbspmlogging.h"
#include "qbsprojectfile.h"
#include "qbsprojectmanager.h"
#include "qbsprojectparser.h"
......@@ -176,11 +177,13 @@ static void collectFilesForProject(const qbs::ProjectData &project, QSet<QString
QStringList QbsProject::files(Project::FilesMode fileMode) const
{
Q_UNUSED(fileMode);
qCDebug(qbsPmLog) << Q_FUNC_INFO << m_qbsProject.isValid() << isParsing();
if (!m_qbsProject.isValid() || isParsing())
return QStringList();
QSet<QString> result;
collectFilesForProject(m_projectData, result);
result.unite(m_qbsProject.buildSystemFiles());
qCDebug(qbsPmLog) << "file count:" << result.count();
return result.toList();
}
......@@ -431,47 +434,55 @@ bool QbsProject::needsSpecialDeployment() const
return true;
}
bool QbsProject::checkCancelStatus()
{
const CancelStatus cancelStatus = m_cancelStatus;
m_cancelStatus = CancelStatusNone;
if (cancelStatus != CancelStatusCancelingForReparse)
return false;
qCDebug(qbsPmLog) << "Cancel request while parsing, starting re-parse";
m_qbsProjectParser->deleteLater();
m_qbsProjectParser = 0;
parseCurrentBuildConfiguration();
return true;
}
void QbsProject::handleProjectStructureAvailable()
{
QTC_ASSERT(m_qbsProjectParser, return);
qCDebug(qbsPmLog) << "Project structure available";
if (checkCancelStatus())
return;
bool dataChanged = false;
m_qbsProject = m_qbsProjectParser->qbsProject();
const qbs::ProjectData &projectData = m_qbsProject.projectData();
QTC_CHECK(m_qbsProject.isValid());
QTC_ASSERT(m_qbsProject.isValid(), return);
if (projectData != m_projectData) {
m_projectData = projectData;
rootProjectNode()->update();
updateDocuments(m_qbsProject.isValid()
? m_qbsProject.buildSystemFiles() : QSet<QString>() << projectFilePath().toString());
dataChanged = true;
}
const qbs::ProjectData &projectData = m_qbsProject.projectData();
if (projectData == m_projectData)
return;
if (dataChanged) {
auto * const futureInterface = m_qbsUpdateFutureInterface;
m_qbsUpdateFutureInterface = nullptr; // So that isParsing() returns false;
updateCppCodeModel();
updateQmlJsCodeModel();
emit fileListChanged();
m_qbsUpdateFutureInterface = futureInterface;
}
qCDebug(qbsPmLog) << "Project data changed.";
m_projectData = projectData;
rootProjectNode()->update();
updateDocuments(QSet<QString>() << projectFilePath().toString());
auto * const futureInterface = m_qbsUpdateFutureInterface;
m_qbsUpdateFutureInterface = nullptr; // So that isParsing() returns false;
updateCppCodeModel();
updateQmlJsCodeModel();
emit fileListChanged();
m_qbsUpdateFutureInterface = futureInterface;
}
void QbsProject::handleQbsParsingDone(bool success)
{
QTC_ASSERT(m_qbsProjectParser, return);
QTC_ASSERT(m_qbsUpdateFutureInterface, return);
const CancelStatus cancelStatus = m_cancelStatus;
m_cancelStatus = CancelStatusNone;
qCDebug(qbsPmLog) << "Parsing done completely, success:" << success;
// Start a new one parse operation right away, ignoring the old result.
if (cancelStatus == CancelStatusCancelingForReparse) {
m_qbsProjectParser->deleteLater();
m_qbsProjectParser = 0;
parseCurrentBuildConfiguration();
if (checkCancelStatus())
return;
}
generateErrors(m_qbsProjectParser->error());
......@@ -484,15 +495,12 @@ void QbsProject::handleQbsParsingDone(bool success)
m_qbsProjectParser->deleteLater();
m_qbsProjectParser = 0;
if (m_qbsUpdateFutureInterface) {
m_qbsUpdateFutureInterface->reportFinished();
delete m_qbsUpdateFutureInterface;
m_qbsUpdateFutureInterface = 0;
}
m_qbsUpdateFutureInterface->reportFinished();
delete m_qbsUpdateFutureInterface;
m_qbsUpdateFutureInterface = 0;
if (success)
updateBuildTargetData();
updateAfterBuild();
emit projectParsingDone(success);
}
......
......@@ -137,6 +137,7 @@ private:
void updateDeploymentInfo();
void updateBuildTargetData();
void handleProjectStructureAvailable();
bool checkCancelStatus();
void projectLoaded() override;
static bool ensureWriteableQbsFile(const QString &file);
......
......@@ -31,6 +31,7 @@ HEADERS = \
qbslogsink.h \
qbsnodes.h \
qbsparser.h \
qbspmlogging.h \
qbsprofilessettingspage.h \
qbsproject.h \
qbsprojectfile.h \
......@@ -56,6 +57,7 @@ SOURCES = \
qbslogsink.cpp \
qbsnodes.cpp \
qbsparser.cpp \
qbspmlogging.cpp \
qbsprofilessettingspage.cpp \
qbsproject.cpp \
qbsprojectfile.cpp \
......
......@@ -90,6 +90,8 @@ QtcPlugin {
"qbsnodes.h",
"qbsparser.cpp",
"qbsparser.h",
"qbspmlogging.cpp",
"qbspmlogging.h",
"qbsprofilessettingspage.cpp",
"qbsprofilessettingspage.h",
"qbsprofilessettingswidget.ui",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment