forked from qt-creator/qt-creator
Disable observer and jsdebugger services when they're already part of Qt
As of Qt 4.8 the observer and jsdebugger services are part of Qt. This means the following changes are necessary in Qt Creator: * Do not link to the QmlJSDebugger library. * Do not create JSDebuggerAgent and QDeclarativeViewObserver instances in the QmlApplicationViewer and use the new declarative_debug CONFIG option to enable those services in Qt. This is done automatically for debug builds. * Point out the QML Debugging Library and the QML Observer are "Not needed" in the Qt options page. * Change the label in qmake options from "Link QML debugging library" to "Enable QML debugging". It still remains as a way to enable this functionality in release builds or for QtQuick applications not based on Qt Creator's template. * Rely on qmlviewer for debugging QML UI projects rather than the observer, which is no longer necessary. Reviewed-by: Kai Koehne
This commit is contained in:
@@ -16,19 +16,17 @@
|
||||
#include <QtDeclarative/QDeclarativeEngine>
|
||||
#include <QtDeclarative/QDeclarativeContext>
|
||||
|
||||
#if defined(QMLJSDEBUGGER)
|
||||
#include <qt_private/qdeclarativedebughelper_p.h>
|
||||
#endif
|
||||
#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
|
||||
|
||||
#if defined(QMLJSDEBUGGER) && !defined(NO_JSDEBUGGER)
|
||||
#include <qt_private/qdeclarativedebughelper_p.h>
|
||||
|
||||
#if !defined(NO_JSDEBUGGER)
|
||||
#include <jsdebuggeragent.h>
|
||||
#endif
|
||||
#if defined(QMLJSDEBUGGER) && !defined(NO_QMLOBSERVER)
|
||||
#if !defined(NO_QMLOBSERVER)
|
||||
#include <qdeclarativeviewobserver.h>
|
||||
#endif
|
||||
|
||||
#if defined(QMLJSDEBUGGER)
|
||||
|
||||
// Enable debugging before any QDeclarativeEngine is created
|
||||
struct QmlJsDebuggingEnabler
|
||||
{
|
||||
@@ -76,12 +74,15 @@ QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) :
|
||||
{
|
||||
connect(engine(), SIGNAL(quit()), SLOT(close()));
|
||||
setResizeMode(QDeclarativeView::SizeRootObjectToView);
|
||||
#if defined(QMLJSDEBUGGER) && !defined(NO_JSDEBUGGER)
|
||||
// Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
|
||||
#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
|
||||
#if !defined(NO_JSDEBUGGER)
|
||||
new QmlJSDebugger::JSDebuggerAgent(engine());
|
||||
#endif
|
||||
#if defined(QMLJSDEBUGGER) && !defined(NO_QMLOBSERVER)
|
||||
#if !defined(NO_QMLOBSERVER)
|
||||
new QmlJSDebugger::QDeclarativeViewObserver(this, this);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
QmlApplicationViewer::~QmlApplicationViewer()
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# may offer an updated version of it.
|
||||
|
||||
QT += declarative
|
||||
CONFIG(debug, debug|release):CONFIG += declarative_debug
|
||||
|
||||
SOURCES += $$PWD/qmlapplicationviewer.cpp
|
||||
HEADERS += $$PWD/qmlapplicationviewer.h
|
||||
|
||||
@@ -134,6 +134,8 @@ QString QmlProjectRunConfiguration::observerPath() const
|
||||
if (!version) {
|
||||
return QString();
|
||||
} else {
|
||||
if (!version->needsQmlDebuggingLibrary())
|
||||
return version->qmlviewerCommand();
|
||||
return version->qmlObserverTool();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,8 @@ bool QmlProjectRunControlFactory::canRun(RunConfiguration *runConfiguration,
|
||||
Debugger::DebuggerPlugin::isActiveDebugLanguage(Debugger::QmlLanguage);
|
||||
|
||||
if (config && qmlDebugSupportInstalled) {
|
||||
if (!config->observerPath().isEmpty())
|
||||
if (!(config->qtVersion() && config->qtVersion()->needsQmlDebuggingLibrary())
|
||||
|| !config->observerPath().isEmpty())
|
||||
return true;
|
||||
if (config->qtVersion() && Qt4ProjectManager::QmlObserverTool::canBuild(config->qtVersion()))
|
||||
return true;
|
||||
|
||||
@@ -784,6 +784,12 @@ bool BaseQtVersion::hasQmlDebuggingLibrary() const
|
||||
return m_hasQmlDebuggingLibrary;
|
||||
}
|
||||
|
||||
bool BaseQtVersion::needsQmlDebuggingLibrary() const
|
||||
{
|
||||
updateVersionInfo();
|
||||
return qtVersion() < QtVersionNumber(4, 8, 0);
|
||||
}
|
||||
|
||||
bool BaseQtVersion::hasQmlObserver() const
|
||||
{
|
||||
updateVersionInfo();
|
||||
|
||||
@@ -181,6 +181,7 @@ public:
|
||||
virtual bool hasGdbDebuggingHelper() const;
|
||||
virtual bool hasQmlDump() const;
|
||||
virtual bool hasQmlDebuggingLibrary() const;
|
||||
virtual bool needsQmlDebuggingLibrary() const;
|
||||
virtual bool hasQmlObserver() const;
|
||||
Utils::Environment qmlToolsEnvironment() const;
|
||||
|
||||
|
||||
@@ -163,15 +163,23 @@ QStringList QMakeStep::moreArguments()
|
||||
arguments << QLatin1String("-unix");
|
||||
#endif
|
||||
|
||||
if (m_linkQmlDebuggingLibrary
|
||||
&& bc->qtVersion() && !bc->qtVersion()->qmlDebuggingHelperLibrary(true).isEmpty()) {
|
||||
if (m_linkQmlDebuggingLibrary && bc->qtVersion()) {
|
||||
if (!bc->qtVersion()->needsQmlDebuggingLibrary()) {
|
||||
// This Qt version has the QML debugging services built in, however
|
||||
// they still need to be enabled at compile time
|
||||
arguments << QLatin1String("CONFIG+=declarative_debug");
|
||||
} else {
|
||||
QString qmlDebuggingHelperLibrary = bc->qtVersion()->qmlDebuggingHelperLibrary(true);
|
||||
if (!qmlDebuggingHelperLibrary.isEmpty()) {
|
||||
// Do not turn debugger path into native path separators: Qmake does not like that!
|
||||
const QString debuggingHelperPath
|
||||
= QFileInfo(bc->qtVersion()->qmlDebuggingHelperLibrary(true)).dir().path();
|
||||
= QFileInfo(qmlDebuggingHelperLibrary).dir().path();
|
||||
|
||||
arguments << QLatin1String(Constants::QMAKEVAR_QMLJSDEBUGGER_PATH)
|
||||
+ QLatin1Char('=') + debuggingHelperPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bc->qtVersion() && !bc->qtVersion()->supportsShadowBuilds()) {
|
||||
// We have a target which does not allow shadow building.
|
||||
@@ -339,7 +347,8 @@ bool QMakeStep::isQmlDebuggingLibrarySupported(QString *reason) const
|
||||
*reason = tr("No Qt version.");
|
||||
return false;
|
||||
}
|
||||
if (version->hasQmlDebuggingLibrary())
|
||||
|
||||
if (!version->needsQmlDebuggingLibrary() || version->hasQmlDebuggingLibrary())
|
||||
return true;
|
||||
|
||||
if (!version->qtAbis().isEmpty()) {
|
||||
@@ -447,14 +456,13 @@ QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step)
|
||||
void QMakeStepConfigWidget::init()
|
||||
{
|
||||
m_ui.qmakeAdditonalArgumentsLineEdit->setText(m_step->userArguments());
|
||||
m_ui.qmlDebuggingLibraryCheckBox->setEnabled(m_step->isQmlDebuggingLibrarySupported());
|
||||
m_ui.qmlDebuggingLibraryCheckBox->setChecked(m_step->linkQmlDebuggingLibrary());
|
||||
|
||||
qmakeBuildConfigChanged();
|
||||
|
||||
updateSummaryLabel();
|
||||
updateEffectiveQMakeCall();
|
||||
updateQmlDebuggingWarningsLabel();
|
||||
updateQmlDebuggingOption();
|
||||
}
|
||||
|
||||
QString QMakeStepConfigWidget::summaryText() const
|
||||
@@ -471,7 +479,7 @@ void QMakeStepConfigWidget::qtVersionChanged()
|
||||
{
|
||||
updateSummaryLabel();
|
||||
updateEffectiveQMakeCall();
|
||||
updateQmlDebuggingWarningsLabel();
|
||||
updateQmlDebuggingOption();
|
||||
}
|
||||
|
||||
void QMakeStepConfigWidget::qmakeBuildConfigChanged()
|
||||
@@ -507,7 +515,7 @@ void QMakeStepConfigWidget::linkQmlDebuggingLibraryChanged()
|
||||
|
||||
updateSummaryLabel();
|
||||
updateEffectiveQMakeCall();
|
||||
updateQmlDebuggingWarningsLabel();
|
||||
updateQmlDebuggingOption();
|
||||
}
|
||||
|
||||
void QMakeStepConfigWidget::qmakeArgumentsLineEdited()
|
||||
@@ -557,7 +565,7 @@ void QMakeStepConfigWidget::linkQmlDebuggingLibraryChecked(bool checked)
|
||||
|
||||
updateSummaryLabel();
|
||||
updateEffectiveQMakeCall();
|
||||
updateQmlDebuggingWarningsLabel();
|
||||
updateQmlDebuggingOption();
|
||||
}
|
||||
|
||||
void QMakeStepConfigWidget::buildQmlDebuggingHelper()
|
||||
@@ -587,10 +595,9 @@ void QMakeStepConfigWidget::debuggingHelperBuildFinished(int qtVersionId, const
|
||||
|
||||
if (version == m_step->qt4BuildConfiguration()->qtVersion()) {
|
||||
m_ui.qmlDebuggingLibraryCheckBox->setChecked(m_step->linkQmlDebuggingLibrary());
|
||||
m_ui.qmlDebuggingLibraryCheckBox->setEnabled(m_step->isQmlDebuggingLibrarySupported());
|
||||
updateSummaryLabel();
|
||||
updateEffectiveQMakeCall();
|
||||
updateQmlDebuggingWarningsLabel();
|
||||
updateQmlDebuggingOption();
|
||||
}
|
||||
|
||||
|
||||
@@ -619,21 +626,25 @@ void QMakeStepConfigWidget::updateSummaryLabel()
|
||||
|
||||
}
|
||||
|
||||
void QMakeStepConfigWidget::updateQmlDebuggingWarningsLabel()
|
||||
void QMakeStepConfigWidget::updateQmlDebuggingOption()
|
||||
{
|
||||
QString reason;
|
||||
m_ui.qmlDebuggingWarningText->clear();
|
||||
if (!m_step->isQmlDebuggingLibrarySupported(&reason)) {
|
||||
m_ui.qmlDebuggingWarningText->setText(reason);
|
||||
}
|
||||
m_ui.qmlDebuggingLibraryCheckBox->setEnabled(m_step->isQmlDebuggingLibrarySupported());
|
||||
|
||||
if (m_step->linkQmlDebuggingLibrary()) {
|
||||
if (m_step->isQmlDebuggingLibrarySupported()) {
|
||||
m_ui.qmlDebuggingWarningText->setText(tr("Might make the application vulnerable. Use only in a safe environment."));
|
||||
}
|
||||
}
|
||||
BaseQtVersion *qtVersion = m_step->qt4BuildConfiguration()->qtVersion();
|
||||
if (!qtVersion || !qtVersion->needsQmlDebuggingLibrary())
|
||||
m_ui.debuggingLibraryLabel->setText(tr("Enable QML debugging:"));
|
||||
else
|
||||
m_ui.debuggingLibraryLabel->setText(tr("Link QML debugging library:"));
|
||||
|
||||
m_ui.qmlDebuggingWarningIcon->setVisible(!m_ui.qmlDebuggingWarningText->text().isEmpty());
|
||||
QString warningText;
|
||||
|
||||
if (!m_step->isQmlDebuggingLibrarySupported(&warningText))
|
||||
;
|
||||
else if (m_step->linkQmlDebuggingLibrary())
|
||||
warningText = tr("Might make your application vulnerable. Only use in a safe environment!");
|
||||
|
||||
m_ui.qmlDebuggingWarningText->setText(warningText);
|
||||
m_ui.qmlDebuggingWarningIcon->setVisible(!warningText.isEmpty());
|
||||
}
|
||||
|
||||
void QMakeStepConfigWidget::updateEffectiveQMakeCall()
|
||||
|
||||
@@ -152,7 +152,7 @@ private slots:
|
||||
|
||||
private:
|
||||
void updateSummaryLabel();
|
||||
void updateQmlDebuggingWarningsLabel();
|
||||
void updateQmlDebuggingOption();
|
||||
void updateEffectiveQMakeCall();
|
||||
Ui::QMakeStep m_ui;
|
||||
QMakeStep *m_step;
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="buildCOnfigurationSpacer">
|
||||
<spacer name="buildConfigurationSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@@ -82,7 +82,7 @@
|
||||
<widget class="QLineEdit" name="qmakeAdditonalArgumentsLineEdit"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<widget class="QLabel" name="debuggingLibraryLabel">
|
||||
<property name="text">
|
||||
<string>Link QML debugging library:</string>
|
||||
</property>
|
||||
|
||||
@@ -474,6 +474,7 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
|
||||
const bool hasGdbHelper = !version->gdbDebuggingHelperLibrary().isEmpty();
|
||||
const bool hasQmlDumper = version->hasQmlDump();
|
||||
const bool hasQmlDebuggingLib = version->hasQmlDebuggingLibrary();
|
||||
const bool needsQmlDebuggingLib = version->needsQmlDebuggingLibrary();
|
||||
const bool hasQmlObserver = !version->qmlObserverTool().isEmpty();
|
||||
|
||||
bool isBuildingGdbHelper = false;
|
||||
@@ -567,7 +568,9 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
|
||||
}
|
||||
qmlDebuggingLibStatusTextFlags = Qt::TextSelectableByMouse;
|
||||
} else {
|
||||
if (canBuildQmlDebuggingLib) {
|
||||
if (!needsQmlDebuggingLib) {
|
||||
qmlDebuggingLibStatusText = tr("<i>Not needed.</i>");
|
||||
} else if (canBuildQmlDebuggingLib) {
|
||||
qmlDebuggingLibStatusText = tr("<i>Not yet built.</i>");
|
||||
} else {
|
||||
qmlDebuggingLibStatusText = tr("<i>Cannot be compiled.</i>");
|
||||
@@ -575,7 +578,8 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
|
||||
}
|
||||
m_debuggingHelperUi->qmlDebuggingLibStatus->setText(qmlDebuggingLibStatusText);
|
||||
m_debuggingHelperUi->qmlDebuggingLibStatus->setTextInteractionFlags(qmlDebuggingLibStatusTextFlags);
|
||||
m_debuggingHelperUi->qmlDebuggingLibBuildButton->setEnabled(canBuildQmlDebuggingLib
|
||||
m_debuggingHelperUi->qmlDebuggingLibBuildButton->setEnabled(needsQmlDebuggingLib
|
||||
&& canBuildQmlDebuggingLib
|
||||
&& !isBuildingQmlDebuggingLib);
|
||||
|
||||
QString qmlObserverStatusText;
|
||||
@@ -584,7 +588,9 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
|
||||
qmlObserverStatusText = QDir::toNativeSeparators(version->qmlObserverTool());
|
||||
qmlObserverStatusTextFlags = Qt::TextSelectableByMouse;
|
||||
} else {
|
||||
if (canBuildQmlObserver) {
|
||||
if (!needsQmlDebuggingLib) {
|
||||
qmlObserverStatusText = tr("<i>Not needed.</i>");
|
||||
} else if (canBuildQmlObserver) {
|
||||
qmlObserverStatusText = tr("<i>Not yet built.</i>");
|
||||
} else {
|
||||
qmlObserverStatusText = tr("<i>Cannot be compiled.</i>");
|
||||
@@ -604,7 +610,7 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
|
||||
&& !isBuildingQmlObserver)
|
||||
&& (canBuildGdbHelper
|
||||
|| canBuildQmlDumper
|
||||
|| canBuildQmlDebuggingLib
|
||||
|| (canBuildQmlDebuggingLib && needsQmlDebuggingLib)
|
||||
|| canBuildQmlObserver));
|
||||
|
||||
m_ui->debuggingHelperWidget->setVisible(true);
|
||||
|
||||
@@ -417,7 +417,7 @@ QList<DeploymentFolder> QtQuickApp::deploymentFolders() const
|
||||
return result;
|
||||
}
|
||||
|
||||
const int QtQuickApp::StubVersion = 11;
|
||||
const int QtQuickApp::StubVersion = 12;
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qt4ProjectManager
|
||||
|
||||
Reference in New Issue
Block a user