From f432e47921061d18123a8ffb2e9297d110d08058 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 16 Oct 2012 10:42:59 +0200 Subject: [PATCH 01/35] Remove Q_ASSERTs Change-Id: I7344935fd488b4bd65517378ca198185023c2532 Reviewed-by: Daniel Teske --- src/plugins/projectexplorer/kitinformation.cpp | 4 ---- src/plugins/projectexplorer/kitmanager.cpp | 4 ++-- src/plugins/projectexplorer/kitmanagerconfigwidget.cpp | 5 +++-- src/plugins/projectexplorer/kitmodel.cpp | 8 -------- src/plugins/projectexplorer/kitoptionspage.cpp | 1 - 5 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/plugins/projectexplorer/kitinformation.cpp b/src/plugins/projectexplorer/kitinformation.cpp index 6d0b3a64067..81c068c43f6 100644 --- a/src/plugins/projectexplorer/kitinformation.cpp +++ b/src/plugins/projectexplorer/kitinformation.cpp @@ -89,7 +89,6 @@ QList SysRootKitInformation::validate(const Kit *k) const KitConfigWidget *SysRootKitInformation::createConfigWidget(Kit *k) const { - Q_ASSERT(k); return new Internal::SysRootInformationConfigWidget(k); } @@ -184,7 +183,6 @@ void ToolChainKitInformation::fix(Kit *k) KitConfigWidget *ToolChainKitInformation::createConfigWidget(Kit *k) const { - Q_ASSERT(k); return new Internal::ToolChainInformationConfigWidget(k); } @@ -280,7 +278,6 @@ QList DeviceTypeKitInformation::validate(const Kit *k) const KitConfigWidget *DeviceTypeKitInformation::createConfigWidget(Kit *k) const { - Q_ASSERT(k); return new Internal::DeviceTypeInformationConfigWidget(k); } @@ -373,7 +370,6 @@ void DeviceKitInformation::fix(Kit *k) KitConfigWidget *DeviceKitInformation::createConfigWidget(Kit *k) const { - Q_ASSERT(k); return new Internal::DeviceInformationConfigWidget(k); } diff --git a/src/plugins/projectexplorer/kitmanager.cpp b/src/plugins/projectexplorer/kitmanager.cpp index a9540c239c0..e5fc49583ed 100644 --- a/src/plugins/projectexplorer/kitmanager.cpp +++ b/src/plugins/projectexplorer/kitmanager.cpp @@ -115,7 +115,7 @@ KitManager::KitManager(QObject *parent) : QObject(parent), d(new Internal::KitManagerPrivate()) { - Q_ASSERT(!m_instance); + QTC_CHECK(!m_instance); m_instance = this; connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), @@ -256,7 +256,7 @@ void KitManager::registerKitInformation(KitInformation *ki) void KitManager::deregisterKitInformation(KitInformation *ki) { - Q_ASSERT(d->m_informationList.contains(ki)); + QTC_CHECK(d->m_informationList.contains(ki)); d->m_informationList.removeAll(ki); delete ki; } diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp index 86fc51e6431..3770f16000c 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp @@ -33,6 +33,7 @@ #include "kitmanager.h" #include +#include #include #include @@ -159,8 +160,8 @@ QString KitManagerConfigWidget::validityMessage() const void KitManagerConfigWidget::addConfigWidget(ProjectExplorer::KitConfigWidget *widget) { - Q_ASSERT(widget); - Q_ASSERT(!m_widgets.contains(widget)); + QTC_ASSERT(widget, return); + QTC_ASSERT(!m_widgets.contains(widget), return); addToLayout(widget->displayName(), widget->toolTip(), widget, widget->buttonWidget()); m_widgets.append(widget); diff --git a/src/plugins/projectexplorer/kitmodel.cpp b/src/plugins/projectexplorer/kitmodel.cpp index 6f2f5bafe9d..04dc879556c 100644 --- a/src/plugins/projectexplorer/kitmodel.cpp +++ b/src/plugins/projectexplorer/kitmodel.cpp @@ -76,7 +76,6 @@ public: // so operate on a temporary list QList tmp = childNodes; qDeleteAll(tmp); - Q_ASSERT(childNodes.isEmpty()); } KitNode *parent; @@ -93,8 +92,6 @@ KitModel::KitModel(QBoxLayout *parentLayout, QObject *parent) : m_parentLayout(parentLayout), m_defaultNode(0) { - Q_ASSERT(m_parentLayout); - connect(KitManager::instance(), SIGNAL(kitAdded(ProjectExplorer::Kit*)), this, SLOT(addKit(ProjectExplorer::Kit*))); connect(KitManager::instance(), SIGNAL(kitRemoved(ProjectExplorer::Kit*)), @@ -196,7 +193,6 @@ Qt::ItemFlags KitModel::flags(const QModelIndex &index) const return 0; KitNode *node = static_cast(index.internalPointer()); - Q_ASSERT(node); if (!node->widget) return Qt::ItemIsEnabled; @@ -216,7 +212,6 @@ Kit *KitModel::kit(const QModelIndex &index) if (!index.isValid()) return 0; KitNode *node = static_cast(index.internalPointer()); - Q_ASSERT(node); return node->widget->workingCopy(); } @@ -231,7 +226,6 @@ void KitModel::setDefaultKit(const QModelIndex &index) if (!index.isValid()) return; KitNode *node = static_cast(index.internalPointer()); - Q_ASSERT(node); if (node->widget) setDefaultNode(node); } @@ -246,7 +240,6 @@ KitManagerConfigWidget *KitModel::widget(const QModelIndex &index) if (!index.isValid()) return 0; KitNode *node = static_cast(index.internalPointer()); - Q_ASSERT(node); return node->widget; } @@ -284,7 +277,6 @@ void KitModel::apply() Q_ASSERT(!n->parent); n->widget->removeKit(); } - Q_ASSERT(m_toRemoveList.isEmpty()); // Update kits: foreach (KitNode *n, m_manualRoot->childNodes) { diff --git a/src/plugins/projectexplorer/kitoptionspage.cpp b/src/plugins/projectexplorer/kitoptionspage.cpp index 71a0a4d6197..e61123c1a1c 100644 --- a/src/plugins/projectexplorer/kitoptionspage.cpp +++ b/src/plugins/projectexplorer/kitoptionspage.cpp @@ -94,7 +94,6 @@ QWidget *KitOptionsPage::createPage(QWidget *parent) QVBoxLayout *verticalLayout = new QVBoxLayout(m_configWidget); verticalLayout->addLayout(horizontalLayout); - Q_ASSERT(!m_model); m_model = new Internal::KitModel(verticalLayout); connect(m_model, SIGNAL(kitStateChanged()), this, SLOT(updateState())); From b9ca111ab131b8b6db4a1169c436cebdf1f503cd Mon Sep 17 00:00:00 2001 From: Marcus Folkesson Date: Mon, 5 Nov 2012 15:16:12 +0100 Subject: [PATCH 02/35] debugger: gdb: Use RemoteGdbServerAdapter for StartRemoteProcess mode The RemoteGdbServerAdapter should be invoked (instead of LocalPlainGdbAdapter) when using startmode StartRemoteProcess. Change-Id: I0f4c9dc2a275ef4b42ddf5b425b8dee839c83458 Signed-off-by: Marcus Folkesson Reviewed-by: Orgad Shaneh Reviewed-by: hjk (cherry picked from commit 0b121abb5e6d47aeef55f049ffc95e0e072f2707) --- src/plugins/debugger/gdb/gdbengine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 02078f40f15..9b63495d169 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -5367,6 +5367,7 @@ DebuggerEngine *createGdbEngine(const DebuggerStartParameters &sp) switch (sp.startMode) { case AttachCore: return new GdbCoreEngine(sp); + case StartRemoteProcess: case AttachToRemoteServer: return new GdbRemoteServerEngine(sp); case StartRemoteGdb: From 7b000a05695ffb88d3b67df4faba171d986fd870 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 19 Nov 2012 10:05:43 +0100 Subject: [PATCH 03/35] debugger: fix win64interrupt start when installed into path with spaces Change-Id: I88796cf54fb4308b1f6e200a9233d8fb42bd9f01 Reviewed-by: Friedemann Kleint --- src/plugins/debugger/procinterrupt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/debugger/procinterrupt.cpp b/src/plugins/debugger/procinterrupt.cpp index 54a250437c0..49c003972be 100644 --- a/src/plugins/debugger/procinterrupt.cpp +++ b/src/plugins/debugger/procinterrupt.cpp @@ -134,7 +134,7 @@ bool Debugger::Internal::interruptProcess(int pID, int engineType, QString *erro *errorMessage = QLatin1String("DebugBreakProcess failed: ") + Utils::winErrorMessage(GetLastError()); } else { const QString executable = QCoreApplication::applicationDirPath() + QLatin1String("/win64interrupt.exe"); - switch (QProcess::execute(executable + QLatin1Char(' ') + QString::number(pID))) { + switch (QProcess::execute(executable, QStringList(QString::number(pID)))) { case -2: *errorMessage = QString::fromLatin1("Cannot start %1. Check src\\tools\\win64interrupt\\win64interrupt.c for more information."). arg(QDir::toNativeSeparators(executable)); From 696c898377c1c3e74f3ad5dc961cd8de82bce8ce Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Mon, 19 Nov 2012 14:52:45 +0100 Subject: [PATCH 04/35] Squish: Handling different cursor behavior on Mac Change-Id: I21dfc2783ee6cb3f83f7ce54a809593cabe03495 Reviewed-by: Christian Stenger --- tests/system/suite_editors/tst_select_all/test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/system/suite_editors/tst_select_all/test.py b/tests/system/suite_editors/tst_select_all/test.py index da1e18333c5..b09bc3e29d4 100644 --- a/tests/system/suite_editors/tst_select_all/test.py +++ b/tests/system/suite_editors/tst_select_all/test.py @@ -42,7 +42,11 @@ def main(): else: pos = size if key == "": - pos -= 1 + if platform.system() == "Darwin": + # native cursor behavior on Mac is different + pos = 0 + else: + pos -= 1 test.compare(editor.textCursor().selectionStart(), pos) test.compare(editor.textCursor().selectionEnd(), pos) test.compare(editor.textCursor().position(), pos) From 440b3f49ff1b0739043667d6008533d2374e5c41 Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Thu, 15 Nov 2012 17:25:42 +0100 Subject: [PATCH 05/35] Doc: new Qt Quick 2.0 file wizard Task-number: QTCREATORBUG-8236 Change-Id: Ibffcae0d4b9d25801d23d2fa0d84ed7fe444feb5 Reviewed-by: Kai Koehne --- doc/src/projects/creator-projects-creating.qdoc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/src/projects/creator-projects-creating.qdoc b/doc/src/projects/creator-projects-creating.qdoc index e9bad373398..b23504aea41 100644 --- a/doc/src/projects/creator-projects-creating.qdoc +++ b/doc/src/projects/creator-projects-creating.qdoc @@ -273,7 +273,11 @@ \o Qt resource files, which allow you to store binary files in the application executable - \o QML files, which specify elements in Qt Quick projects + \o QML files, which specify elements in Qt Quick projects. + \gui {Qt Quick 1} creates a QML file that imports Qt Quick 1.1 and + \gui {Qt Quick 2} creates a QML file that imports Qt Quick 2.0. + Select \gui {Qt Quick 1} to add files to a Qt Quick 1 application + and \gui {Qt Quick 2} to add files to a Qt Quick 2 application. \o JavaScript files that you can use to write the application logic in Qt Quick projects From 6b3d87dad97f92e60bcf410b6a3a5f2905dabc58 Mon Sep 17 00:00:00 2001 From: Jing Bai Date: Fri, 9 Nov 2012 15:23:48 +0100 Subject: [PATCH 06/35] make setting default Kit work Copying from working copy to the real kit copy causes KM to reset changes and call "discard()". Then m_isDefaultKit is reset which makes the logic in "apply()" a mess. Try to avoid this by saving m_isDefaultKit Task-number: QTCREATORBUG-8205 Change-Id: Ie8243d7dc2aca92788d719c0c147127b3a7e8714 Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/kitmanagerconfigwidget.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp index 3770f16000c..675aeba9499 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp @@ -111,17 +111,18 @@ QString KitManagerConfigWidget::displayName() const void KitManagerConfigWidget::apply() { + bool mustSetDefault = m_isDefaultKit; KitManager *km = KitManager::instance(); bool mustRegister = false; if (!m_kit) { mustRegister = true; m_kit = new Kit; } - m_kit->copyFrom(m_modifiedKit); + m_kit->copyFrom(m_modifiedKit);//m_isDefaultKit is reset in discard() here. if (mustRegister) km->registerKit(m_kit); - if (m_isDefaultKit) + if (mustSetDefault) km->setDefaultKit(m_kit); emit dirty(); } @@ -187,7 +188,7 @@ bool KitManagerConfigWidget::configures(Kit *k) const void KitManagerConfigWidget::setIsDefaultKit(bool d) { - if (m_isDefaultKit != d) + if (m_isDefaultKit == d) return; m_isDefaultKit = d; emit dirty(); From c09f2249bb468cdaf04232f5825af3a6ff9170e4 Mon Sep 17 00:00:00 2001 From: "Christian A. Reiter" Date: Mon, 19 Nov 2012 13:36:48 +0100 Subject: [PATCH 07/35] fix German double mapped key accelerator for menus "Datei", "Debuggen" Change-Id: I249d730661279346de5c3654cdcfe335d5ead15e Reviewed-by: Robert Loehning --- share/qtcreator/translations/qtcreator_de.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/qtcreator/translations/qtcreator_de.ts b/share/qtcreator/translations/qtcreator_de.ts index 3cd02f334c9..56e84e40107 100644 --- a/share/qtcreator/translations/qtcreator_de.ts +++ b/share/qtcreator/translations/qtcreator_de.ts @@ -7831,7 +7831,7 @@ konnte dem Projekt '%2' nicht hinzugefügt werden. &Debug - &Debuggen + Deb&uggen &Start Debugging From feae690513f4c8d69b737771e13026e3bfc89474 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Mon, 19 Nov 2012 17:10:31 +0100 Subject: [PATCH 08/35] Squish: Update for Target -> Kit renaming Change-Id: I3c8ae3c67f2459c13b885ed935bb1dc31e09c359 Reviewed-by: Christian Stenger --- tests/system/shared/project_explorer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/shared/project_explorer.py b/tests/system/shared/project_explorer.py index 215093a7844..aacc57bbfab 100644 --- a/tests/system/shared/project_explorer.py +++ b/tests/system/shared/project_explorer.py @@ -204,7 +204,7 @@ def __getTargetFromToolTip__(toolTip): if toolTip == None or not isinstance(toolTip, (str, unicode)): test.warning("Parameter toolTip must be of type str or unicode and can't be None!") return None - pattern = re.compile(".*Target:(.*)Deploy.*") + pattern = re.compile(".*Kit:(.*)Deploy.*") target = pattern.match(toolTip) if target == None: test.fatal("UI seems to have changed - expected ToolTip does not match.", From c03182e428e65f6ee1ca20e79fb2fa93dea34cad Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 19 Nov 2012 14:46:09 +0100 Subject: [PATCH 09/35] Fix crash when closing creator Fix crash when closing creator after the kit options page was shown. Also fixes a memory leak. Change-Id: I5c5f72fc3c83aaefecfb722a86902f5cbb880a70 Reviewed-by: hjk --- src/plugins/projectexplorer/kitmanagerconfigwidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp index 675aeba9499..7fcfee2af0d 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp @@ -98,6 +98,9 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k, QWidget *parent) : KitManagerConfigWidget::~KitManagerConfigWidget() { + qDeleteAll(m_widgets); + m_widgets.clear(); + delete m_modifiedKit; // Make sure our workingCopy did not get registered somehow: foreach (const Kit *k, KitManager::instance()->kits()) From dd8396ed06bf18a0c0fab62bacaec891b1891e32 Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Tue, 20 Nov 2012 10:54:32 +0100 Subject: [PATCH 10/35] Doc: using QML Scene for Qt 5 and Qt Quick 2 Task-number: QTCREATORBUG-8170 Change-Id: I2d1a2635b1efe820390084d20712c1fd9961276e Reviewed-by: Kai Koehne --- doc/src/howto/creator-external-tools.qdoc | 14 +++++++------- doc/src/overview/creator-advanced.qdoc | 3 ++- doc/src/projects/creator-projects-creating.qdoc | 5 +++-- doc/src/qtquick/qtquick-creating.qdoc | 3 ++- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/doc/src/howto/creator-external-tools.qdoc b/doc/src/howto/creator-external-tools.qdoc index ac1f5faf92a..2ea158b0226 100644 --- a/doc/src/howto/creator-external-tools.qdoc +++ b/doc/src/howto/creator-external-tools.qdoc @@ -31,7 +31,7 @@ \title Using External Tools You can use external tools directly from \QC. Qt Linguist, - QML Viewer, the + QML preview tools, the default text editor for your system, and the \c sort tool are preconfigured for use. You can change their default configurations and configure new tools. @@ -59,14 +59,14 @@ \l{http://qt-project.org/doc/qt-4.8/linguist-manual.html} {Qt Linguist Manual}. - \section1 Using QML Viewer + \section1 Previewing QML Files - You can preview the current QML document in the QML Viewer. The QML Viewer - invokes the QML runtime to load QML documents and also includes additional - features useful for the development of QML-based applications. + You can preview the current QML document in the QML Viewer (Qt Quick 1) or + QML Scene (Qt Quick 2). The preview tools enable you to load QML documents + for viewing and testing while you are developing an application. - To preview the currently active QML file, select \gui {Tools > External > - Qt Quick > Preview (qmlviewer)}. + To preview the currently active QML file, select \gui Tools > \gui External + > \gui {Qt Quick} > \gui {Preview (qmlviewer)} or \gui {Preview (qmlscene)}. \section1 Using External Text Editors diff --git a/doc/src/overview/creator-advanced.qdoc b/doc/src/overview/creator-advanced.qdoc index 12f5bbe8aaa..78693a7afc0 100644 --- a/doc/src/overview/creator-advanced.qdoc +++ b/doc/src/overview/creator-advanced.qdoc @@ -71,7 +71,8 @@ \o \l{Using External Tools} You can use external tools directly from \QC. Qt Linguist, - QML Viewer, the default text editor for your system, and the \c sort + QML preview tools (QML Viewer and QML Scene), the default text + editor for your system, and the \c sort tool are preconfigured for use. You can change their default configurations and configure new tools. diff --git a/doc/src/projects/creator-projects-creating.qdoc b/doc/src/projects/creator-projects-creating.qdoc index b23504aea41..21b9bd5e609 100644 --- a/doc/src/projects/creator-projects-creating.qdoc +++ b/doc/src/projects/creator-projects-creating.qdoc @@ -141,8 +141,9 @@ \o Qt Quick UI - Use a single QML file that contains the main view. You can run - Qt Quick UI projects in the QML Viewer and you need not build + Use a single QML file that contains the main view. You can + review Qt Quick UI projects in a \l{Previewing QML Files} + {preview tool} and you need not build them. You do not need to have the development environment installed on your computer to create and run this type of projects diff --git a/doc/src/qtquick/qtquick-creating.qdoc b/doc/src/qtquick/qtquick-creating.qdoc index 00588530eef..623b84961c7 100644 --- a/doc/src/qtquick/qtquick-creating.qdoc +++ b/doc/src/qtquick/qtquick-creating.qdoc @@ -59,7 +59,8 @@ develop for platforms that run Qt 5. \o \gui {Qt Quick UI} creates a Qt Quick UI project with a single QML file that contains the main view. You can review Qt Quick UI - projects in the QML Viewer and you need not build them. You do not + projects in a \l{Previewing QML Files}{preview tool} and you need + not build them. You do not need to have the development environment installed on your computer to create and run this type of projects. From 18e4db4f70da96650b836962be2e389c2fb0996b Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 7 Nov 2012 10:05:52 +0100 Subject: [PATCH 11/35] QmlDesigner: do not show warning for qml2puppet in 2.6 Since Qt Quick 2.0 is not supported the message about the missing qml2puppet is just confusing. Task-number: QTCREATORBUG-7858 Change-Id: I4c4454ff1179459456523b540cee7d395aaf8c5c Reviewed-by: Christian Stenger Reviewed-by: Eike Ziller Reviewed-by: Kai Koehne Reviewed-by: Marco Bubke --- .../instances/nodeinstanceserverproxy.cpp | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp index 13687835a48..2144aa4fc7c 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp @@ -194,21 +194,23 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV } } else { - QMessageBox::warning(0, tr("Cannot Start QML Puppet Executable"), - tr("The executable of the QML Puppet process (%1) cannot be started. " - "Please check your installation. " - "QML Puppet is a process which runs in the background to render the items."). - arg(applicationPath)); + if (!hasQtQuick2(m_nodeInstanceView.data())) + QMessageBox::warning(0, tr("Cannot Start QML Puppet Executable"), + tr("The executable of the QML Puppet process (%1) cannot be started. " + "Please check your installation. " + "QML Puppet is a process which runs in the background to render the items."). + arg(applicationPath)); } m_localServer->close(); } else { - QMessageBox::warning(0, tr("Cannot Find QML Puppet Executable"), - tr("The executable of the QML Puppet process (%1) cannot be found. " - "Please check your installation. " - "QML Puppet is a process which runs in the background to render the items."). - arg(applicationPath)); + if (!hasQtQuick2(m_nodeInstanceView.data())) + QMessageBox::warning(0, tr("Cannot Find QML Puppet Executable"), + tr("The executable of the QML Puppet process (%1) cannot be found. " + "Please check your installation. " + "QML Puppet is a process which runs in the background to render the items."). + arg(applicationPath)); } } From c6d97aea5482c7130aec21bc3ed4151d7125765b Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 20 Nov 2012 15:14:33 +0100 Subject: [PATCH 12/35] sdktool: Make sure to put a sane qmake path into qtversions.xml Task-number: QTBUG-27980 Change-Id: Ic339384422da425a35d1f0180603605def71c5f3 Reviewed-by: Kai Koehne --- src/tools/sdktool/addqtoperation.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/tools/sdktool/addqtoperation.cpp b/src/tools/sdktool/addqtoperation.cpp index ec5f6b4e2b5..83f0c34f67a 100644 --- a/src/tools/sdktool/addqtoperation.cpp +++ b/src/tools/sdktool/addqtoperation.cpp @@ -37,6 +37,8 @@ #include "settings.h" +#include + #include // Qt version file stuff: @@ -172,9 +174,15 @@ bool AddQtOperation::test() const || map.value(QLatin1String(VERSION)).toInt() != 1) return false; +#if defined Q_OS_WIN map = addQt(map, QLatin1String("testId"), QLatin1String("Test Qt Version"), QLatin1String("testType"), - QLatin1String("/tmp/test/qmake"), + QLatin1String("/tmp//../tmp/test\\qmake"), KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue")))); +#else + map = addQt(map, QLatin1String("testId"), QLatin1String("Test Qt Version"), QLatin1String("testType"), + QLatin1String("/tmp//../tmp/test/qmake"), + KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue")))); +#endif if (map.count() != 2 || !map.contains(QLatin1String(VERSION)) @@ -281,13 +289,16 @@ QVariantMap AddQtOperation::addQt(const QVariantMap &map, nameList << GetOperation::get(map, nameKey).toString(); const QString uniqueName = makeUnique(displayName, nameList); + // Sanitize qmake path: + QString saneQmake = QDir::cleanPath(QDir::fromNativeSeparators(qmake)); + // insert data: KeyValuePairList data; data << KeyValuePair(QStringList() << qt << QLatin1String(ID), QVariant(-1)); data << KeyValuePair(QStringList() << qt << QLatin1String(DISPLAYNAME), QVariant(uniqueName)); data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTED), QVariant(true)); data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTION_SOURCE), QVariant(id)); - data << KeyValuePair(QStringList() << qt << QLatin1String(QMAKE), QVariant(qmake)); + data << KeyValuePair(QStringList() << qt << QLatin1String(QMAKE), QVariant(saneQmake)); data << KeyValuePair(QStringList() << qt << QLatin1String(TYPE), QVariant(type)); KeyValuePairList qtExtraList; From 280dc45537958e48a83f56115a3ffb348d710fa2 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 20 Nov 2012 16:13:53 +0100 Subject: [PATCH 13/35] sdktool: Fix removal of Qt versions Task-number: QTCREATORBUG-8234 Change-Id: Ieb537f831f5c5404078fd3bfe191ea164e36bc5b Reviewed-by: Tim Jenssen --- src/tools/sdktool/rmqtoperation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/sdktool/rmqtoperation.cpp b/src/tools/sdktool/rmqtoperation.cpp index af17a6e9160..f8a1d22185c 100644 --- a/src/tools/sdktool/rmqtoperation.cpp +++ b/src/tools/sdktool/rmqtoperation.cpp @@ -87,7 +87,7 @@ int RmQtOperation::execute() const if (result == map) return -2; - return save(map, QLatin1String("qtversion")) ? 0 : -3; + return save(result, QLatin1String("qtversion")) ? 0 : -3; } #ifdef WITH_TESTS From af2b39699a308efc7f9579619fdbcba57b0f8c14 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 20 Nov 2012 16:28:53 +0100 Subject: [PATCH 14/35] SDKtool: Fix autodetection sources of Qt versions Make sure to use autodetection sources (--id) in sdktool that are actually expected by Creator. Do so by prepending the necessary magic. This makes sure that creator will actually remove the SDK Qt versions again once they get removed by SDKtool. Task-number: QTCREATORBUG-8235 Change-Id: I8dde1ab1ae192c8f79de9fb9104461e7435237ec Reviewed-by: Tim Jenssen --- src/tools/sdktool/addqtoperation.cpp | 8 ++++++-- src/tools/sdktool/rmqtoperation.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/tools/sdktool/addqtoperation.cpp b/src/tools/sdktool/addqtoperation.cpp index 83f0c34f67a..c2443c741af 100644 --- a/src/tools/sdktool/addqtoperation.cpp +++ b/src/tools/sdktool/addqtoperation.cpp @@ -255,8 +255,12 @@ QVariantMap AddQtOperation::addQt(const QVariantMap &map, const QString &id, const QString &displayName, const QString &type, const QString &qmake, const KeyValuePairList &extra) { + QString sdkId = id; + if (!id.startsWith(QLatin1String("SDK."))) + sdkId = QString::fromLatin1("SDK.") + id; + // Sanity check: Make sure autodetection source is not in use already: - QStringList valueKeys = FindValueOperation::findValues(map, id); + QStringList valueKeys = FindValueOperation::findValues(map, sdkId); bool hasId = false; foreach (const QString &k, valueKeys) { if (k.endsWith(QString(QLatin1Char('/')) + QLatin1String(AUTODETECTION_SOURCE))) { @@ -297,7 +301,7 @@ QVariantMap AddQtOperation::addQt(const QVariantMap &map, data << KeyValuePair(QStringList() << qt << QLatin1String(ID), QVariant(-1)); data << KeyValuePair(QStringList() << qt << QLatin1String(DISPLAYNAME), QVariant(uniqueName)); data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTED), QVariant(true)); - data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTION_SOURCE), QVariant(id)); + data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTION_SOURCE), QVariant(sdkId)); data << KeyValuePair(QStringList() << qt << QLatin1String(QMAKE), QVariant(saneQmake)); data << KeyValuePair(QStringList() << qt << QLatin1String(TYPE), QVariant(type)); diff --git a/src/tools/sdktool/rmqtoperation.cpp b/src/tools/sdktool/rmqtoperation.cpp index f8a1d22185c..85ea6bfc99d 100644 --- a/src/tools/sdktool/rmqtoperation.cpp +++ b/src/tools/sdktool/rmqtoperation.cpp @@ -133,12 +133,17 @@ bool RmQtOperation::test() const QVariantMap RmQtOperation::rmQt(const QVariantMap &map, const QString &id) { + QString sdkId = id; + if (!id.startsWith(QLatin1String("SDK."))) + sdkId = QString::fromLatin1("SDK.") + id; + QVariantList qtList; for (QVariantMap::const_iterator i = map.begin(); i != map.end(); ++i) { if (!i.key().startsWith(QLatin1String(PREFIX))) continue; QVariantMap qtData = i.value().toMap(); - if (qtData.value(QLatin1String(AUTODETECTION_SOURCE)).toString() != id) + const QString dataId = qtData.value(QLatin1String(AUTODETECTION_SOURCE)).toString(); + if ((dataId != id) && (dataId != sdkId)) qtList.append(qtData); } From 7c9c1924f07f1eb999656e775c2339a2cf5d0084 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Tue, 6 Nov 2012 16:39:51 +0100 Subject: [PATCH 15/35] debugger: compile fix in self test MSVC does not support #warning Change-Id: Ie9f9575a53c4c124e2ecffc6ad55181f2049ec5f Reviewed-by: Joerg Bornemann Reviewed-by: Eike Ziller Reviewed-by: hjk --- tests/manual/debugger/simple/simple_test_app.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/manual/debugger/simple/simple_test_app.cpp b/tests/manual/debugger/simple/simple_test_app.cpp index 18a9a69ad7a..01271d80284 100644 --- a/tests/manual/debugger/simple/simple_test_app.cpp +++ b/tests/manual/debugger/simple/simple_test_app.cpp @@ -89,12 +89,12 @@ #if !(USE_AUTOBREAK) #undef USE_AUTOBREAK #define USE_AUTOBREAK 1 -#warning Switching on USE_AUTOBREAK +#pragma message ("Switching on USE_AUTOBREAK") #endif // !USE_AUTOBREAK #if USE_UNINITIALIZED_AUTOBREAK #undef USE_UNINITIALIZED_AUTOBREAK #define USE_UNINITIALIZED_AUTOBREAK 0 -#warning Switching off USE_AUTOBREAK +#pragma message ("Switching off USE_UNINITIALIZED_AUTOBREAK") #endif // USE_UNINITIALIZED_AUTOBREAK #endif From d61e55c29dcc2ba10694b1b0bf12698563c795ac Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 21 Nov 2012 12:20:14 +0100 Subject: [PATCH 16/35] Make sure cloned kits are considered to be manual Task-number: QTCREATORBUG-8231 Change-Id: Ic5f4cc876fef1a06e877702a272230fc7f44b1f4 Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/kit.h | 2 ++ src/plugins/projectexplorer/kitmodel.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/plugins/projectexplorer/kit.h b/src/plugins/projectexplorer/kit.h index 3dfcd61034f..475b1d9601a 100644 --- a/src/plugins/projectexplorer/kit.h +++ b/src/plugins/projectexplorer/kit.h @@ -43,6 +43,7 @@ namespace ProjectExplorer { namespace Internal { class KitManagerPrivate; +class KitModel; class KitPrivate; } // namespace Internal @@ -108,6 +109,7 @@ private: Internal::KitPrivate *d; friend class KitManager; + friend class Internal::KitModel; // needed for setAutoDetected() when cloning kits }; class KitGuard diff --git a/src/plugins/projectexplorer/kitmodel.cpp b/src/plugins/projectexplorer/kitmodel.cpp index 04dc879556c..d38d8fbf906 100644 --- a/src/plugins/projectexplorer/kitmodel.cpp +++ b/src/plugins/projectexplorer/kitmodel.cpp @@ -323,6 +323,7 @@ Kit *KitModel::markForAddition(Kit *baseKit) if (baseKit) { Kit *k = node->widget->workingCopy(); k->copyFrom(baseKit); + k->setAutoDetected(false); // Make sure we have a manual kit! k->setDisplayName(tr("Clone of %1").arg(k->displayName())); } From 634ab62870d2e1560a601a53a8d684356975e746 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 21 Nov 2012 12:04:39 +0100 Subject: [PATCH 17/35] Fix build issues being empty for non-qmake projects In qmake based projects we override LC_ALL to make sure the parsers do not fail to extract build issues from the compiler output. Do the same for the other build systems. Task-number: QTCREATORBUG-5097 Change-Id: I75830c362a736df42a0500c889c3c42e42b82047 Reviewed-by: Daniel Teske --- src/plugins/autotoolsprojectmanager/makestep.cpp | 6 +++++- src/plugins/cmakeprojectmanager/makestep.cpp | 15 +++++++-------- .../genericprojectmanager/genericmakestep.cpp | 6 +++++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/plugins/autotoolsprojectmanager/makestep.cpp b/src/plugins/autotoolsprojectmanager/makestep.cpp index c0160986a4a..de9f1bf164a 100644 --- a/src/plugins/autotoolsprojectmanager/makestep.cpp +++ b/src/plugins/autotoolsprojectmanager/makestep.cpp @@ -186,7 +186,11 @@ bool MakeStep::init() ProcessParameters *pp = processParameters(); pp->setMacroExpander(bc->macroExpander()); - pp->setEnvironment(bc->environment()); + Utils::Environment env = bc->environment(); + // Force output to english for the parsers. Do this here and not in the toolchain's + // addToEnvironment() to not screw up the users run environment. + env.set(QLatin1String("LC_ALL"), QLatin1String("C")); + pp->setEnvironment(env); pp->setWorkingDirectory(bc->buildDirectory()); pp->setCommand(tc ? tc->makeCommand(bc->environment()) : QLatin1String("make")); pp->setArguments(arguments); diff --git a/src/plugins/cmakeprojectmanager/makestep.cpp b/src/plugins/cmakeprojectmanager/makestep.cpp index 74070d8c374..da32f5f50ec 100644 --- a/src/plugins/cmakeprojectmanager/makestep.cpp +++ b/src/plugins/cmakeprojectmanager/makestep.cpp @@ -188,14 +188,13 @@ bool MakeStep::init() ProcessParameters *pp = processParameters(); pp->setMacroExpander(bc->macroExpander()); - if (m_useNinja) { - Utils::Environment env = bc->environment(); - if (!env.value(QLatin1String("NINJA_STATUS")).startsWith(m_ninjaProgressString)) - env.set(QLatin1String("NINJA_STATUS"), m_ninjaProgressString + QLatin1String("%o/sec] ")); - pp->setEnvironment(env); - } else { - pp->setEnvironment(bc->environment()); - } + Utils::Environment env = bc->environment(); + // Force output to english for the parsers. Do this here and not in the toolchain's + // addToEnvironment() to not screw up the users run environment. + env.set(QLatin1String("LC_ALL"), QLatin1String("C")); + if (m_useNinja && !env.value(QLatin1String("NINJA_STATUS")).startsWith(m_ninjaProgressString)) + env.set(QLatin1String("NINJA_STATUS"), m_ninjaProgressString + QLatin1String("%o/sec] ")); + pp->setEnvironment(env); pp->setWorkingDirectory(bc->buildDirectory()); pp->setCommand(makeCommand(tc, bc->environment())); pp->setArguments(arguments); diff --git a/src/plugins/genericprojectmanager/genericmakestep.cpp b/src/plugins/genericprojectmanager/genericmakestep.cpp index 3e7fd4f1612..6b130778857 100644 --- a/src/plugins/genericprojectmanager/genericmakestep.cpp +++ b/src/plugins/genericprojectmanager/genericmakestep.cpp @@ -119,7 +119,11 @@ bool GenericMakeStep::init() ProcessParameters *pp = processParameters(); pp->setMacroExpander(bc->macroExpander()); pp->setWorkingDirectory(bc->buildDirectory()); - pp->setEnvironment(bc->environment()); + Utils::Environment env = bc->environment(); + // Force output to english for the parsers. Do this here and not in the toolchain's + // addToEnvironment() to not screw up the users run environment. + env.set(QLatin1String("LC_ALL"), QLatin1String("C")); + pp->setEnvironment(env); pp->setCommand(makeCommand(bc->environment())); pp->setArguments(allArguments()); From 70467d8d4984d069d50e7d1dc739f01dd463f3c4 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 21 Nov 2012 12:22:08 +0100 Subject: [PATCH 18/35] Do not append '2' to cloned kit names. They are named "Clone of Whatever", so there is no need for further differences. This solution as suggested by dt is better then the one I originally used. Task-number: QTCREATORBUG-8168 Change-Id: I0bb1b9361c05fdd6a6a4cdd556e3c6ccdb7c9ad4 Reviewed-by: Daniel Teske --- src/plugins/projectexplorer/kitmodel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/projectexplorer/kitmodel.cpp b/src/plugins/projectexplorer/kitmodel.cpp index d38d8fbf906..9131ba19d66 100644 --- a/src/plugins/projectexplorer/kitmodel.cpp +++ b/src/plugins/projectexplorer/kitmodel.cpp @@ -322,6 +322,7 @@ Kit *KitModel::markForAddition(Kit *baseKit) KitNode *node = createNode(m_manualRoot, 0); if (baseKit) { Kit *k = node->widget->workingCopy(); + KitGuard g(k); k->copyFrom(baseKit); k->setAutoDetected(false); // Make sure we have a manual kit! k->setDisplayName(tr("Clone of %1").arg(k->displayName())); From 9fa21d26c12add4cfdc3cfdd6d1e25b945684cd9 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Tue, 20 Nov 2012 15:40:10 +0100 Subject: [PATCH 19/35] Another target -> kit renaming Change-Id: I47dbca2155b6aec0dfa5ad2ca6fe632be00d39a2 Reviewed-by: Daniel Teske --- src/plugins/projectexplorer/buildmanager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index e42f7d28dd4..890ca2d74f5 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -404,7 +404,7 @@ void BuildManager::nextBuildQueue() addToOutputWindow(tr("Error while building/deploying project %1 (kit: %2)").arg(projectName, targetName), BuildStep::ErrorOutput); addToOutputWindow(tr("When executing step '%1'").arg(d->m_currentBuildStep->displayName()), BuildStep::ErrorOutput); // NBS TODO fix in qtconcurrent - d->m_progressFutureInterface->setProgressValueAndText(d->m_progress*100, tr("Error while building/deploying project %1 (target: %2)").arg(projectName, targetName)); + d->m_progressFutureInterface->setProgressValueAndText(d->m_progress*100, tr("Error while building/deploying project %1 (kit: %2)").arg(projectName, targetName)); } if (result) @@ -504,7 +504,7 @@ bool BuildManager::buildQueueAppend(QList steps, QStringList names) // print something for the user const QString projectName = bs->project()->displayName(); const QString targetName = bs->target()->displayName(); - addToOutputWindow(tr("Error while building/deploying project %1 (target: %2)").arg(projectName, targetName), BuildStep::ErrorOutput); + addToOutputWindow(tr("Error while building/deploying project %1 (kit: %2)").arg(projectName, targetName), BuildStep::ErrorOutput); addToOutputWindow(tr("When executing step '%1'").arg(bs->displayName()), BuildStep::ErrorOutput); // disconnect the buildsteps again From 3e0aae6872f1fc2a91a67693185ebccf6932da8c Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Wed, 21 Nov 2012 14:28:08 +0100 Subject: [PATCH 20/35] Creator Examples: providing custom examples-manifest.xml The user can prevent the default loading of examples and provide a custom example manifest file through the environment variable QTC_EXAMPLE_FILE Change-Id: Id458d321e2c8815312e338e458a5283ac64b5c95 Reviewed-by: hjk --- src/plugins/qtsupport/exampleslistmodel.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 31f47223adf..35b3269e8d3 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -40,6 +40,7 @@ #include #include +#include #include using QtSupport::QtVersionManager; @@ -309,6 +310,16 @@ QStringList ExamplesListModel::exampleSources(QString *examplesFallback, QString QStringList sources; QString resourceDir = Core::ICore::resourcePath() + QLatin1String("/welcomescreen/"); + // overriding examples with a custom XML file + QString exampleFileEnvKey = QLatin1String("QTC_EXAMPLE_FILE"); + if (Utils::Environment::systemEnvironment().hasKey(exampleFileEnvKey)) { + QString filePath = Utils::Environment::systemEnvironment().value(exampleFileEnvKey); + if (filePath.endsWith(QLatin1String(".xml")) && QFileInfo(filePath).exists()) { + sources.append(filePath); + return sources; + } + } + // Qt Creator shipped tutorials sources << (resourceDir + QLatin1String("/qtcreator_tutorials.xml")); From 53c0fd64496f60a2ed161b879d65eb48f45c1a41 Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Wed, 21 Nov 2012 16:52:00 +0100 Subject: [PATCH 21/35] Creator Examples: search for manifest files in qt5 submodules Change-Id: Ifd7b838f1471ea08f942d350ed649b0b174e96c5 Reviewed-by: hjk --- src/plugins/qtsupport/exampleslistmodel.cpp | 31 +++++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 35b3269e8d3..859acb271f4 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -342,10 +342,33 @@ QStringList ExamplesListModel::exampleSources(QString *examplesFallback, QString QString potentialExamplesFallback; QString potentialDemosFallback; QString potentialSourceFallback; - bool potentialFallbackHasDeclarative = false; // we prefer Qt's with declarative as fallback const QStringList pattern(QLatin1String("*.xml")); QtVersionManager *versionManager = QtVersionManager::instance(); + + foreach (BaseQtVersion *version, versionManager->validVersions()) { + // qt5 with examples OR demos manifest + if (version->qtVersion().majorVersion == 5 && (version->hasExamples() || version->hasDemos())) { + // examples directory in Qt5 is under the qtbase submodule, + // search other submodule directories for further manifest files + QDir qt5docPath = QDir(version->documentationPath()); + const QStringList examplesPattern(QLatin1String("examples-manifest.xml")); + const QStringList demosPattern(QLatin1String("demos-manifest.xml")); + QFileInfoList fis; + foreach (QFileInfo subDir, qt5docPath.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) { + if (version->hasExamples()) + fis << QDir(subDir.absoluteFilePath()).entryInfoList(examplesPattern); + if (version->hasDemos()) + fis << QDir(subDir.absoluteFilePath()).entryInfoList(demosPattern); + } + if (!fis.isEmpty()) { + foreach (const QFileInfo &fi, fis) + sources.append(fi.filePath()); + return sources; + } + } + } + foreach (BaseQtVersion *version, versionManager->validVersions()) { QFileInfoList fis; if (version->hasExamples()) @@ -357,13 +380,9 @@ QStringList ExamplesListModel::exampleSources(QString *examplesFallback, QString sources.append(fi.filePath()); return sources; } - // check if this Qt version would be the preferred fallback, Qt 4 only if (version->qtVersion().majorVersion == 4 && version->hasExamples() && version->hasDemos()) { // cached, so no performance hit - bool hasDeclarative = QDir(version->examplesPath() + QLatin1String("/declarative")).exists(); - if (potentialExamplesFallback.isEmpty() - || (!potentialFallbackHasDeclarative && hasDeclarative)) { - potentialFallbackHasDeclarative = hasDeclarative; + if (potentialExamplesFallback.isEmpty()) { potentialExamplesFallback = version->examplesPath(); potentialDemosFallback = version->demosPath(); potentialSourceFallback = version->sourcePath().toString(); From 1a003ed29bd72009ed9c619d6af92804d099dbfc Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Thu, 22 Nov 2012 12:42:57 +0100 Subject: [PATCH 22/35] SDKtool: Make sure the Qt id starts with "SDK." when setting up kits We do the same when adding a new Qt version. Change-Id: I910421ee4d913c76688b9ef6e4787edcd7c6f09f Reviewed-by: Tim Jenssen --- src/tools/sdktool/addkitoperation.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tools/sdktool/addkitoperation.cpp b/src/tools/sdktool/addkitoperation.cpp index 917ea48760a..933b8f41b7a 100644 --- a/src/tools/sdktool/addkitoperation.cpp +++ b/src/tools/sdktool/addkitoperation.cpp @@ -349,6 +349,10 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map, nameList << GetOperation::get(map, nameKey).toString(); const QString uniqueName = makeUnique(displayName, nameList); + QString qtId = qt; + if (!qtId.startsWith(QLatin1String("SDK."))) + qtId = QString::fromLatin1("SDK.") + qt; + // insert data: KeyValuePairList data; data << KeyValuePair(QStringList() << kit << QLatin1String(ID), QVariant(id)); @@ -363,7 +367,7 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map, data << KeyValuePair(QStringList() << kit << QLatin1String(DATA) << DEVICE_TYPE, QVariant(deviceType)); data << KeyValuePair(QStringList() << kit << QLatin1String(DATA) << SYSROOT, QVariant(sysRoot)); data << KeyValuePair(QStringList() << kit << QLatin1String(DATA) << TOOLCHAIN, QVariant(tc)); - data << KeyValuePair(QStringList() << kit << QLatin1String(DATA) << QT, QVariant(qt)); + data << KeyValuePair(QStringList() << kit << QLatin1String(DATA) << QT, QVariant(qtId)); data << KeyValuePair(QStringList() << kit << QLatin1String(DATA) << MKSPEC, QVariant(mkspec)); data << KeyValuePair(QStringList() << QLatin1String(DEFAULT), QVariant(defaultKit)); From d0f3d7cb89a234f88b06bc19a41e50c41b1eab0a Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 29 Oct 2012 13:54:33 +0100 Subject: [PATCH 23/35] C++: Clean up dev tools. * Add -h and -help options describing the tools and their usage. * Make the tools compile and run on Windows (MinGW, MSVC). * Rename project dirs, executables and main source files to more meaningful names: - Use same base name for project dir, *.pro file, main source file and (if applicable) script file. - Use the prefix "cplusplus-". - The names are now: - gen-cpp-ast/generate-ast --> cplusplus-update-frontend - mkvisitor --> cplusplus-mkvisitor - cplusplus-dump/cplusplus0 --> cplusplus-ast2png * Get rid of 'c++' shell scripts. * Get rid of duplicates of 'conf.c++'. Rename to 'pp-configuration.inc'. * Introduce src/tools/cplusplus-tools-utils containing common stuff that is used at least in two tools. 'pp-configuration.inc' can also be found here. * cplusplus-update-frontend: - Print file paths of written files to stdout. - Convenience: Use default values referencing the appropriate dirs and files. * cplusplus-mkvisitor: - Take only one argument, namely the path to AST.h. - Convenience: Use default path to AST.h. * cplusplus-ast2png: - Make it run without LD_LIBRARY_PATH. - As the name suggests, generate image files in png format (needs 'dot' from graphviz). - Convenience: Read from stdin, which useful for small snippets. Change-Id: I79c4061fce4a1571c0588dfedd50d4a70715d9df Reviewed-by: Erik Verbruggen --- .gitignore | 12 +- src/libs/3rdparty/cplusplus/AST.cpp | 2 +- .../cplusplus-mkvisitor.cpp} | 78 +++++++--- .../cplusplus-mkvisitor.pro | 13 ++ .../cplusplus-tools-utils.cpp | 140 ++++++++++++++++++ .../cplusplus-tools-utils.h | 62 ++++++++ .../cplusplus-tools-utils.pri | 13 ++ .../pp-configuration.inc | 10 +- .../cplusplus-update-frontend.cpp} | 90 ++++++++--- .../cplusplus-update-frontend.pro | 15 ++ src/tools/gen-cpp-ast/gen-cpp-ast.pro | 10 -- src/tools/mkvisitor/conf.c++ | 15 -- src/tools/mkvisitor/mkvisitor | 5 - src/tools/mkvisitor/mkvisitor.pro | 20 --- tests/manual/cplusplus-frontend/c++ | 5 - .../{main.cpp => cplusplus-frontend.cpp} | 41 ++++- .../cplusplus-frontend/cplusplus-frontend.pro | 26 ++-- .../cplusplus-ast2png.cpp} | 138 +++++++++++++++-- .../cplusplus-ast2png/cplusplus-ast2png.pro | 12 ++ .../dumpers.inc | 0 .../tests/templ01.cpp | 0 tests/tools/cplusplus-dump/c++ | 5 - tests/tools/cplusplus-dump/conf.c++ | 15 -- tests/tools/cplusplus-dump/cplusplus-dump.pro | 20 --- tests/tools/tools.pro | 2 +- 25 files changed, 564 insertions(+), 185 deletions(-) rename src/tools/{mkvisitor/main.cpp => cplusplus-mkvisitor/cplusplus-mkvisitor.cpp} (89%) create mode 100644 src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.pro create mode 100644 src/tools/cplusplus-tools-utils/cplusplus-tools-utils.cpp create mode 100644 src/tools/cplusplus-tools-utils/cplusplus-tools-utils.h create mode 100644 src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri rename tests/manual/cplusplus-frontend/conf.c++ => src/tools/cplusplus-tools-utils/pp-configuration.inc (63%) rename src/tools/{gen-cpp-ast/generate-ast.cpp => cplusplus-update-frontend/cplusplus-update-frontend.cpp} (95%) create mode 100644 src/tools/cplusplus-update-frontend/cplusplus-update-frontend.pro delete mode 100644 src/tools/gen-cpp-ast/gen-cpp-ast.pro delete mode 100644 src/tools/mkvisitor/conf.c++ delete mode 100755 src/tools/mkvisitor/mkvisitor delete mode 100644 src/tools/mkvisitor/mkvisitor.pro delete mode 100755 tests/manual/cplusplus-frontend/c++ rename tests/manual/cplusplus-frontend/{main.cpp => cplusplus-frontend.cpp} (64%) rename tests/tools/{cplusplus-dump/main.cpp => cplusplus-ast2png/cplusplus-ast2png.cpp} (72%) create mode 100644 tests/tools/cplusplus-ast2png/cplusplus-ast2png.pro rename tests/tools/{cplusplus-dump => cplusplus-ast2png}/dumpers.inc (100%) rename tests/tools/{cplusplus-dump => cplusplus-ast2png}/tests/templ01.cpp (100%) delete mode 100755 tests/tools/cplusplus-dump/c++ delete mode 100644 tests/tools/cplusplus-dump/conf.c++ delete mode 100644 tests/tools/cplusplus-dump/cplusplus-dump.pro diff --git a/.gitignore b/.gitignore index 35bc4f285e0..caaca826c53 100644 --- a/.gitignore +++ b/.gitignore @@ -109,8 +109,10 @@ bin/qml2puppet.exe bin/qtpromaker bin/qtpromaker.exe share/doc/qtcreator/*.qch -src/tools/gen-cpp-ast/generate-ast -src/tools/mkvisitor/cplusplus0 +src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor +src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.exe +src/tools/cplusplus-update-frontend/cplusplus-update-frontend +src/tools/cplusplus-update-frontend/cplusplus-update-frontend.exe src/tools/qml/qmldump/qmldump src/tools/examplesscanner/examplesscanner src/tools/valgrindfake/valgrind-fake @@ -118,13 +120,15 @@ bin/*.exe # Tests #------ -tests/manual/cplusplus-frontend/cplusplus0 -tests/manual/cplusplus-dump/cplusplus0 +tests/manual/cplusplus-frontend/cplusplus-frontend +tests/manual/cplusplus-frontend/cplusplus-frontend.exe tests/manual/qml-ast2dot/qml-ast2dot tests/manual/debugger/simple/libsimple_test_plugin.*dylib tests/manual/debugger/simple/simple_test_app tests/manual/plain-cplusplus/plain-c++ tests/manual/preprocessor/pp +tests/tools/cplusplus-ast2png/cplusplus-ast2png +tests/tools/cplusplus-ast2png/cplusplus-ast2png.exe tests/auto/cplusplus/codegen/tst_codegen tests/auto/cplusplus/ast/tst_ast tests/auto/cplusplus/codeformatter/tst_codeformatter diff --git a/src/libs/3rdparty/cplusplus/AST.cpp b/src/libs/3rdparty/cplusplus/AST.cpp index 94cdbc9611a..31cacbcc43c 100644 --- a/src/libs/3rdparty/cplusplus/AST.cpp +++ b/src/libs/3rdparty/cplusplus/AST.cpp @@ -29,7 +29,7 @@ /* All firstToken/lastToken methods below which have a doxygen comment with - \generated in it, will be re-generated when the tool "generate-ast" is run. + \generated in it, will be re-generated when the tool "cplusplus-update-frontend" is run. For methods which are hand-coded, or which should not be changed, make sure that the comment is gone. diff --git a/src/tools/mkvisitor/main.cpp b/src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.cpp similarity index 89% rename from src/tools/mkvisitor/main.cpp rename to src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.cpp index db85b6cbac8..ae21f90d94a 100644 --- a/src/tools/mkvisitor/main.cpp +++ b/src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.cpp @@ -44,6 +44,8 @@ #include #include +#include "cplusplus-tools-utils.h" + #include #include #include @@ -422,35 +424,65 @@ protected: } }; +void printUsage() +{ + std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName()) + << " [-v] [path to AST.h]\n\n" + << "Print a visitor class based on AST.h to stdout.\n\n"; + const QString defaulPath = QFileInfo(PATH_AST_H).canonicalFilePath(); + std::cout << "Default path: " << qPrintable(defaulPath) << '.' << "\n"; +} + int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); + QStringList args = app.arguments(); + args.removeFirst(); - QStringList files = app.arguments(); - files.removeFirst(); + bool optionVerbose = false; - foreach (const QString &fileName, files) { - QFile file(fileName); - if (! file.open(QFile::ReadOnly)) - continue; - - const QByteArray source = file.readAll(); - file.close(); - - Document::Ptr doc = Document::create(fileName); - //doc->control()->setDiagnosticClient(0); - doc->setUtf8Source(source); - doc->parse(); - - doc->translationUnit()->blockErrors(true); - - doc->check(); - Snapshot snapshot; - snapshot.insert(doc); - - LookupContext context(doc, snapshot); - MkVisitor mkVisitor(context); + // Process options & arguments + if (args.contains("-v")) { + optionVerbose = true; + args.removeOne("-v"); } + const bool helpRequested = args.contains("-h") || args.contains("-help"); + if (helpRequested || args.count() >= 2) { + printUsage(); + return helpRequested ? EXIT_SUCCESS : EXIT_FAILURE; + } + + // Run the preprocessor + QString fileName = PATH_AST_H; + if (!args.isEmpty()) + fileName = args.first(); + + const QString fileNamePreprocessed = fileName + QLatin1String(".preprocessed"); + CplusplusToolsUtils::SystemPreprocessor preprocessor(optionVerbose); + preprocessor.preprocessFile(fileName, fileNamePreprocessed); + + QFile file(fileNamePreprocessed); + if (! file.open(QFile::ReadOnly)) { + std::cerr << "Error: Could not open file \"" << qPrintable(file.fileName()) << "\"." + << std::endl; + return EXIT_FAILURE; + } + + const QByteArray source = file.readAll(); + file.close(); + + Document::Ptr doc = Document::create(fileName); + //doc->control()->setDiagnosticClient(0); + doc->setUtf8Source(source); + doc->parse(); + doc->translationUnit()->blockErrors(true); + doc->check(); + + Snapshot snapshot; + snapshot.insert(doc); + + LookupContext context(doc, snapshot); + MkVisitor mkVisitor(context); return EXIT_SUCCESS; } diff --git a/src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.pro b/src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.pro new file mode 100644 index 00000000000..aa942fc5faa --- /dev/null +++ b/src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.pro @@ -0,0 +1,13 @@ +QT = core gui +macx:CONFIG -= app_bundle +win32:CONFIG += console +TEMPLATE = app +TARGET = cplusplus-mkvisitor +DESTDIR = ./ + +include(../../../qtcreator.pri) +include(../../libs/cplusplus/cplusplus-lib.pri) +include(../../../src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri) + +DEFINES += PATH_AST_H=\\\"$$PWD/../../libs/3rdparty/cplusplus/AST.h\\\" +SOURCES += cplusplus-mkvisitor.cpp diff --git a/src/tools/cplusplus-tools-utils/cplusplus-tools-utils.cpp b/src/tools/cplusplus-tools-utils/cplusplus-tools-utils.cpp new file mode 100644 index 00000000000..5ad4ce09063 --- /dev/null +++ b/src/tools/cplusplus-tools-utils/cplusplus-tools-utils.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + + +#include "cplusplus-tools-utils.h" +#include "environment.h" + +#include +#include +#include +#include + +namespace CplusplusToolsUtils { + +QString portableExecutableName(const QString &executable) +{ +#if defined(Q_OS_WIN) + return executable + QLatin1String(".exe"); +#else + return executable; +#endif +} + +void executeCommand(const QString &command, const QStringList &arguments, const QString &outputFile, + bool verbose) +{ + QTextStream out(stderr); + if (command.isEmpty()) { + out << "Error: " << Q_FUNC_INFO << "Got empty command to execute." << endl; + exit(EXIT_FAILURE); + } + + const QString fullCommand = command + QLatin1Char(' ') + arguments.join(QLatin1String(" ")); + if (verbose) + out << "Executing: " << fullCommand << endl; + + QProcess process; + if (!outputFile.isEmpty()) + process.setStandardOutputFile(outputFile, QIODevice::Truncate); + process.start(command, arguments); + if (!process.waitForStarted()) { + out << QString("Error: Process \"%1\" did not start within timeout: %2.") + .arg(fullCommand, process.errorString()) + << endl; + exit(EXIT_FAILURE); + } + if (!process.waitForFinished()) { + if (!verbose) + out << process.readAll() << endl; + out << QString("Error: Process \"%1\" did not finish within timeout.").arg(fullCommand) + << endl; + exit(EXIT_FAILURE); + } + const int exitCode = process.exitCode(); + if (exitCode != 0) { + out << process.readAllStandardError() << endl; + out << QString("Error: Process \"%1\" finished with non zero exit value %2") + .arg(fullCommand, exitCode) << endl; + exit(EXIT_FAILURE); + } +} + +SystemPreprocessor::SystemPreprocessor(bool verbose) + : m_verbose(verbose) +{ + m_knownCompilers[portableExecutableName("gcc")] + = QLatin1String("-DCPLUSPLUS_WITHOUT_QT -U__BLOCKS__ -xc++ -E -include"); + m_knownCompilers[portableExecutableName("cl")] + = QLatin1String("/DCPLUSPLUS_WITHOUT_QT /U__BLOCKS__ /TP /E /I . /FI"); + + QMapIterator i(m_knownCompilers); + while (i.hasNext()) { + i.next(); + const QString executablePath + = Utils::Environment::systemEnvironment().searchInPath(i.key()); + if (!executablePath.isEmpty()) { + m_compiler = i.key(); + m_compilerArguments = i.value().split(QLatin1String(" "), QString::SkipEmptyParts); + m_compilerArguments + << QDir::toNativeSeparators(QLatin1String(PATH_PREPROCESSOR_CONFIG)); + break; + } + } +} + +void SystemPreprocessor::check() const +{ + QTextStream out(stderr); + if (!QFile::exists(PATH_PREPROCESSOR_CONFIG)) { + out << QString("Error: File \"%1\" does not exist.").arg(PATH_PREPROCESSOR_CONFIG) << endl; + exit(EXIT_FAILURE); + } + if (m_compiler.isEmpty()) { + const QString triedCompilers + = QStringList(m_knownCompilers.keys()).join(QLatin1String(", ")); + out << QString("Error: No compiler found. Tried %1.").arg(triedCompilers) << endl; + exit(EXIT_FAILURE); + } +} + +void SystemPreprocessor::preprocessFile(const QString &inputFile, const QString &outputFile) const +{ + check(); + if (!QFile::exists(inputFile)) { + QTextStream out(stderr); + out << QString("Error: File \"%1\" does not exist.").arg(inputFile) << endl; + exit(EXIT_FAILURE); + } + const QStringList arguments = QStringList(m_compilerArguments) + << QDir::toNativeSeparators(inputFile); + executeCommand(m_compiler, arguments, outputFile, m_verbose); +} + +} // namespace diff --git a/src/tools/cplusplus-tools-utils/cplusplus-tools-utils.h b/src/tools/cplusplus-tools-utils/cplusplus-tools-utils.h new file mode 100644 index 00000000000..bbc0c4834b2 --- /dev/null +++ b/src/tools/cplusplus-tools-utils/cplusplus-tools-utils.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + + +#ifndef CPLUSPLUSTOOLSUTILS_H +#define CPLUSPLUSTOOLSUTILS_H + +#include +#include +#include + +namespace CplusplusToolsUtils { + +QString portableExecutableName(const QString &executable); +void executeCommand(const QString &command, const QStringList &arguments, const QString &outputFile, + bool verbose = false); + +// Preprocess a file by calling an external compiler in preprocessor mode (-E, /E). +class SystemPreprocessor +{ +public: + SystemPreprocessor(bool verbose = false); + void preprocessFile(const QString &inputFile, const QString &outputFile) const; + +private: + void check() const; + + QMap m_knownCompilers; + QString m_compiler; // Compiler that will be called in preprocessor mode + QStringList m_compilerArguments; + bool m_verbose; +}; + +} // namespace + +#endif // CPLUSPLUSTOOLSUTILS_H diff --git a/src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri b/src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri new file mode 100644 index 00000000000..99002ad0d08 --- /dev/null +++ b/src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri @@ -0,0 +1,13 @@ +DEPENDPATH += $$PWD +INCLUDEPATH += $$PWD $$PWD/../../libs/utils + +DEFINES += PATH_PREPROCESSOR_CONFIG=\\\"$$PWD/pp-configuration.inc\\\" +DEFINES += QTCREATOR_UTILS_STATIC_LIB + +HEADERS += \ + $$PWD/cplusplus-tools-utils.h \ + $$PWD/../../libs/utils/environment.h + +SOURCES += \ + $$PWD/cplusplus-tools-utils.cpp \ + $$PWD/../../libs/utils/environment.cpp diff --git a/tests/manual/cplusplus-frontend/conf.c++ b/src/tools/cplusplus-tools-utils/pp-configuration.inc similarity index 63% rename from tests/manual/cplusplus-frontend/conf.c++ rename to src/tools/cplusplus-tools-utils/pp-configuration.inc index 69bafe0459c..5d6b0678c91 100644 --- a/tests/manual/cplusplus-frontend/conf.c++ +++ b/src/tools/cplusplus-tools-utils/pp-configuration.inc @@ -1,15 +1,17 @@ #define __extension__ #define __context__ #define __range__ -#define __asm(a...) -#define __asm__(a...) +#if !defined(_WIN32) && !defined(_WIN64) +# define __asm(a...) +# define __asm__(a...) +# define __stdcall +# define __fastcall +#endif #define restrict #define __restrict #define __restrict__ // #define __weak #define __builtin_va_arg(a,b) ((b)0) -#define __stdcall -#define __fastcall #define __imag__ #define __real__ #define __complex__ diff --git a/src/tools/gen-cpp-ast/generate-ast.cpp b/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp similarity index 95% rename from src/tools/gen-cpp-ast/generate-ast.cpp rename to src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp index 34d83b7326c..6d8a61dc7fa 100644 --- a/src/tools/gen-cpp-ast/generate-ast.cpp +++ b/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp @@ -91,12 +91,21 @@ static const char generatedHeader[] = "// W A R N I N G\n" "// -------------\n" "//\n" -"// This file is automatically generated.\n" +"// This file is automatically generated by \"cplusplus-update-frontend\".\n" "// Changes will be lost.\n" "//\n" "\n" ; +static void closeAndPrintFilePath(QFile &file) +{ + if (file.isOpen()) { + const QString filePath = QFileInfo(file).canonicalFilePath(); + std::cout << QDir::toNativeSeparators(filePath).toLatin1().constData() << std::endl; + file.close(); + } +} + class ASTNodes { public: @@ -226,6 +235,8 @@ public: "using namespace CPlusPlus;\n" << endl; accept(ast); + + closeAndPrintFilePath(file); } protected: @@ -354,7 +365,6 @@ public: QTextStream output(&file); out = &output; - *out << copyrightHeader << generatedHeader << "\n" "#include \"AST.h\"\n" @@ -363,6 +373,8 @@ public: "using namespace CPlusPlus;\n" << endl; accept(ast); + + closeAndPrintFilePath(file); } protected: @@ -480,6 +492,8 @@ public: << endl; accept(ast); + + closeAndPrintFilePath(file); } protected: @@ -627,7 +641,7 @@ public: accept(ast); - file.close(); + closeAndPrintFilePath(file); } protected: @@ -761,7 +775,7 @@ public: d.accept(unit->ast()); - file.close(); + closeAndPrintFilePath(file); } protected: @@ -1220,6 +1234,7 @@ void generateAST_cpp(const Snapshot &snapshot, const QDir &cplusplusDir) if (file.open(QFile::WriteOnly)) { QTextStream out(&file); out << cpp_document.toPlainText(); + closeAndPrintFilePath(file); } } @@ -1312,6 +1327,8 @@ void generateASTVisitor_H(const Snapshot &, const QDir &cplusplusDir, "} // namespace CPlusPlus\n" "\n" "#endif // CPLUSPLUS_ASTVISITOR_H\n"; + + closeAndPrintFilePath(file); } void generateASTMatcher_H(const Snapshot &, const QDir &cplusplusDir, @@ -1353,6 +1370,8 @@ void generateASTMatcher_H(const Snapshot &, const QDir &cplusplusDir, "} // namespace CPlusPlus\n" "\n" "#endif // CPLUSPLUS_ASTMATCHER_H\n"; + + closeAndPrintFilePath(file); } QStringList generateAST_H(const Snapshot &snapshot, const QDir &cplusplusDir, const QString &dumpersFile) @@ -1437,6 +1456,7 @@ QStringList generateAST_H(const Snapshot &snapshot, const QDir &cplusplusDir, co if (file.open(QFile::WriteOnly)) { QTextStream out(&file); out << document.toPlainText(); + closeAndPrintFilePath(file); } Accept0CG cg(cplusplusDir, AST_h_document->translationUnit()); @@ -1537,6 +1557,7 @@ void generateASTFwd_h(const Snapshot &snapshot, const QDir &cplusplusDir, const if (file.open(QFile::WriteOnly)) { QTextStream out(&file); out << document.toPlainText(); + closeAndPrintFilePath(file); } } @@ -1664,36 +1685,67 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir) << "} // end of namespace CPlusPlus" << endl << endl << "#endif // CPLUSPLUS_AST_PATTERN_BUILDER_H" << endl; + + closeAndPrintFilePath(file); +} + +void printUsage() +{ + const QByteArray executable = QFileInfo(qApp->arguments().first()).fileName().toLatin1(); + std::cout << "Usage: " << executable.constData() << "\n" + << " " << executable.constData() << " " + << "\n\n" + << "Generate appropriate header and source files of the C++ frontend accordingly\n" + << "to AST.h and print the paths of the written files. Run this tool after\n" + << "modifying AST.h." + << "\n\n"; + const QString defaultPathCppFrontend = QFileInfo(PATH_CPP_FRONTEND).canonicalFilePath(); + const QString defaultPathDumpersFile = QFileInfo(PATH_DUMPERS_FILE).canonicalFilePath(); + std::cout << "Default values:" << "\n" + << " frontend-dir: " << qPrintable(defaultPathCppFrontend) << "\n" + << " dumpers-file: " << qPrintable(defaultPathDumpersFile) << "\n"; } int main(int argc, char *argv[]) { MyQApplication app(argc, argv); + QStringList args = app.arguments(); + args.removeFirst(); - QStringList files = app.arguments(); - files.removeFirst(); + QString pathCppFrontend = PATH_CPP_FRONTEND; + QString pathDumpersFile = PATH_DUMPERS_FILE; - if (files.size() != 1 && files.size() != 2) { - std::cerr << "Usage: cplusplus [path to C++ front-end]" << std::endl; - std::cerr << " or: cplusplus [path to C++ front-end] [dumpers file name]" << std::endl; - return EXIT_FAILURE; + const bool helpRequested = args.contains("-h") || args.contains("-help"); + if (args.count() == 1 || args.count() >= 3 || helpRequested) { + printUsage(); + return helpRequested ? EXIT_SUCCESS : EXIT_FAILURE; + } else if (args.count() == 2) { + pathCppFrontend = args.at(0); + pathDumpersFile = args.at(1); } - QDir cplusplusDir(files.first()); + QDir cplusplusDir(pathCppFrontend); + if (!QFile::exists(pathCppFrontend)) { + std::cerr << "Error: Directory \"" << qPrintable(cplusplusDir.absolutePath()) + << "\" does not exist." << std::endl; + return EXIT_FAILURE; + } if (!QFileInfo(cplusplusDir, QLatin1String("AST.h")).exists()) { - std::cerr << "Cannot find AST.h in " << qPrintable(cplusplusDir.absolutePath()) - << std::endl; + std::cerr << "Error: Cannot find AST.h in \"" << qPrintable(cplusplusDir.absolutePath()) + << "\"." << std::endl; + return EXIT_FAILURE; + } + if (!QFile::exists(pathDumpersFile)) { + std::cerr << "Error: File \"" << qPrintable(pathDumpersFile) + << "\" does not exist." << std::endl; return EXIT_FAILURE; } - - QString dumpersFile; - if (files.size() == 2) - dumpersFile = files.last(); Snapshot snapshot; - QStringList astDerivedClasses = generateAST_H(snapshot, cplusplusDir, dumpersFile); + QStringList astDerivedClasses = generateAST_H(snapshot, cplusplusDir, pathDumpersFile); astDerivedClasses.sort(); generateASTFwd_h(snapshot, cplusplusDir, astDerivedClasses); - generateASTPatternBuilder_h(cplusplusDir); + + return EXIT_SUCCESS; } diff --git a/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.pro b/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.pro new file mode 100644 index 00000000000..7b0e853cd42 --- /dev/null +++ b/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.pro @@ -0,0 +1,15 @@ +QT = core gui +macx:CONFIG -= app_bundle +win32:CONFIG += console +TEMPLATE = app +TARGET = cplusplus-update-frontend +DESTDIR = ./ +DEFINES += QTCREATOR_UTILS_STATIC_LIB +INCLUDEPATH += . ../../libs + +include(../../../qtcreator.pri) +include(../../libs/cplusplus/cplusplus-lib.pri) + +DEFINES += PATH_CPP_FRONTEND=\\\"$$PWD/../../libs/3rdparty/cplusplus\\\" +DEFINES += PATH_DUMPERS_FILE=\\\"$$PWD/../../../tests/tools/cplusplus-ast2png/dumpers.inc\\\" +SOURCES += cplusplus-update-frontend.cpp ../../libs/utils/changeset.cpp diff --git a/src/tools/gen-cpp-ast/gen-cpp-ast.pro b/src/tools/gen-cpp-ast/gen-cpp-ast.pro deleted file mode 100644 index e7fb63f3de4..00000000000 --- a/src/tools/gen-cpp-ast/gen-cpp-ast.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT = core gui -macx:CONFIG -= app_bundle -TEMPLATE = app -TARGET = generate-ast -INCLUDEPATH += . ../../libs - -include(../../libs/cplusplus/cplusplus-lib.pri) - -# Input -SOURCES += generate-ast.cpp ../../libs/utils/changeset.cpp diff --git a/src/tools/mkvisitor/conf.c++ b/src/tools/mkvisitor/conf.c++ deleted file mode 100644 index 69bafe0459c..00000000000 --- a/src/tools/mkvisitor/conf.c++ +++ /dev/null @@ -1,15 +0,0 @@ -#define __extension__ -#define __context__ -#define __range__ -#define __asm(a...) -#define __asm__(a...) -#define restrict -#define __restrict -#define __restrict__ -// #define __weak -#define __builtin_va_arg(a,b) ((b)0) -#define __stdcall -#define __fastcall -#define __imag__ -#define __real__ -#define __complex__ diff --git a/src/tools/mkvisitor/mkvisitor b/src/tools/mkvisitor/mkvisitor deleted file mode 100755 index 1c6444ba6e0..00000000000 --- a/src/tools/mkvisitor/mkvisitor +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -me=$(dirname $0) -${CPP-gcc} -DCPLUSPLUS_WITHOUT_QT -U__BLOCKS__ -xc++ -E -include $me/conf.c++ ../../libs/3rdparty/cplusplus/AST.h > $me/file.i -$me/cplusplus0 $me/file.i -rm -f $me/file.i diff --git a/src/tools/mkvisitor/mkvisitor.pro b/src/tools/mkvisitor/mkvisitor.pro deleted file mode 100644 index 03c53754d27..00000000000 --- a/src/tools/mkvisitor/mkvisitor.pro +++ /dev/null @@ -1,20 +0,0 @@ -QT = core gui -macx:CONFIG -= app_bundle -TARGET = cplusplus0 -INCLUDEPATH += . ../../libs - -include(../../libs/cplusplus/cplusplus-lib.pri) - -# Input -SOURCES += main.cpp - -unix { - debug:OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared - release:OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared - - debug:MOC_DIR = $${OUT_PWD}/.moc/debug-shared - release:MOC_DIR = $${OUT_PWD}/.moc/release-shared - - RCC_DIR = $${OUT_PWD}/.rcc/ - UI_DIR = $${OUT_PWD}/.uic/ -} diff --git a/tests/manual/cplusplus-frontend/c++ b/tests/manual/cplusplus-frontend/c++ deleted file mode 100755 index a5908b79ff1..00000000000 --- a/tests/manual/cplusplus-frontend/c++ +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -me=$(dirname $0) -${CPP-gcc} -U__BLOCKS__ -xc++ -E -include $me/conf.c++ $* > $me/file.i -$me/cplusplus0 $me/file.i - diff --git a/tests/manual/cplusplus-frontend/main.cpp b/tests/manual/cplusplus-frontend/cplusplus-frontend.cpp similarity index 64% rename from tests/manual/cplusplus-frontend/main.cpp rename to tests/manual/cplusplus-frontend/cplusplus-frontend.cpp index 7baba4de90c..f31af8e5f0a 100644 --- a/tests/manual/cplusplus-frontend/main.cpp +++ b/tests/manual/cplusplus-frontend/cplusplus-frontend.cpp @@ -40,6 +40,8 @@ #include #include +#include "cplusplus-tools-utils.h" + #include #include #include @@ -54,18 +56,47 @@ using namespace CPlusPlus; +void printUsage() +{ + std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName()) + << " [-v] ...\n\n" + << "Run the parser with the given files.\n"; +} + int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); + QStringList args = app.arguments(); + args.removeFirst(); - QStringList files = app.arguments(); - files.removeFirst(); + bool optionVerbose = false; + // Process options & arguments + if (args.contains("-v")) { + optionVerbose = true; + args.removeOne("-v"); + } + const bool helpRequested = args.contains("-h") || args.contains("-help"); + if (args.isEmpty() || helpRequested) { + printUsage(); + return helpRequested ? EXIT_SUCCESS : EXIT_FAILURE; + } + + // Process files + const QStringList files = args; foreach (const QString &fileName, files) { - QFile file(fileName); - if (! file.open(QFile::ReadOnly)) - continue; + // Run preprocessor + const QString fileNamePreprocessed = fileName + QLatin1String(".preprocessed"); + CplusplusToolsUtils::SystemPreprocessor preprocessor(optionVerbose); + preprocessor.preprocessFile(fileName, fileNamePreprocessed); + // Run parser + QFile file(fileNamePreprocessed); + if (! file.open(QFile::ReadOnly)) { + std::cerr << "Error: Could not open file \"" << qPrintable(file.fileName()) << "\"." + << std::endl; + return EXIT_FAILURE; + } const QByteArray source = file.readAll(); file.close(); diff --git a/tests/manual/cplusplus-frontend/cplusplus-frontend.pro b/tests/manual/cplusplus-frontend/cplusplus-frontend.pro index 529645f6a41..c2a6300ca01 100644 --- a/tests/manual/cplusplus-frontend/cplusplus-frontend.pro +++ b/tests/manual/cplusplus-frontend/cplusplus-frontend.pro @@ -1,21 +1,13 @@ QT = core gui macx:CONFIG -= app_bundle -TARGET = cplusplus0 +win32:CONFIG += console +TEMPLATE = app +TARGET = cplusplus-frontend +DESTDIR = ./ + include(../../../qtcreator.pri) -include($$IDE_SOURCE_TREE/src/libs/cplusplus/cplusplus.pri) -include($$IDE_SOURCE_TREE/src/libs/languageutils/languageutils.pri) -include($$IDE_SOURCE_TREE/src/libs/utils/utils.pri) +include($$IDE_SOURCE_TREE/src/libs/cplusplus/cplusplus-lib.pri) +include($$IDE_SOURCE_TREE/tests/auto/qttestrpath.pri) +include(../../../src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri) -# Input -SOURCES += main.cpp - -unix { - debug:OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared - release:OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared - - debug:MOC_DIR = $${OUT_PWD}/.moc/debug-shared - release:MOC_DIR = $${OUT_PWD}/.moc/release-shared - - RCC_DIR = $${OUT_PWD}/.rcc/ - UI_DIR = $${OUT_PWD}/.uic/ -} +SOURCES += cplusplus-frontend.cpp diff --git a/tests/tools/cplusplus-dump/main.cpp b/tests/tools/cplusplus-ast2png/cplusplus-ast2png.cpp similarity index 72% rename from tests/tools/cplusplus-dump/main.cpp rename to tests/tools/cplusplus-ast2png/cplusplus-ast2png.cpp index 168f7c2b117..8af2b289e58 100644 --- a/tests/tools/cplusplus-dump/main.cpp +++ b/tests/tools/cplusplus-ast2png/cplusplus-ast2png.cpp @@ -42,6 +42,9 @@ #include #include +#include "cplusplus-tools-utils.h" + +#include #include #include #include @@ -58,6 +61,22 @@ # include #endif +// For isatty(), _isatty() +#if defined(Q_OS_WIN) +# include +#else +# include +#endif + +bool tty_for_stdin() +{ +#if defined(Q_OS_WIN) + return _isatty(_fileno(stdin)); +#else + return isatty(fileno(stdin)); +#endif +} + using namespace CPlusPlus; class ASTDump: protected ASTVisitor @@ -68,9 +87,6 @@ public: void operator()(AST *ast) { QByteArray basename = translationUnit()->fileName(); - int dotIdx = basename.lastIndexOf('.'); - if (dotIdx != -1) - basename.truncate(dotIdx); basename.append(".ast.dot"); out.open(basename.constData()); @@ -89,11 +105,10 @@ public: out << "}" << std::endl; out.close(); - std::cout << basename.constData() << std::endl; } // the following file can be generated by using: - // generate-ast + // cplusplus-update-frontend #include "dumpers.inc" protected: @@ -195,9 +210,6 @@ public: void operator()(Symbol *s) { QByteArray basename = translationUnit->fileName(); - int dotIdx = basename.lastIndexOf('.'); - if (dotIdx != -1) - basename.truncate(dotIdx); basename.append(".symbols.dot"); out.open(basename.constData()); @@ -218,7 +230,6 @@ public: out << "}" << std::endl; out.close(); - std::cout << basename.constData() << std::endl; } protected: @@ -351,19 +362,103 @@ private: Overview o; }; + +void createImageFromDot(const QString &inputFile, const QString &outputFile, bool verbose) +{ + const QString command = CplusplusToolsUtils::portableExecutableName(QLatin1String("dot")); + const QStringList arguments = QStringList() + << QLatin1String("-Tpng") << QLatin1String("-o") << outputFile << inputFile; + CplusplusToolsUtils::executeCommand(command, arguments, QString(), verbose); +} + +const char PATH_STDIN_FILE[] = "_stdincontents.cpp"; + +QString example() +{ + return +#if defined(Q_OS_WIN) + QString::fromLatin1("> echo int foo() {} | %1 && %2.ast.png") +#elif defined(Q_OS_MAC) + QString::fromLatin1("$ echo \"int foo() {}\" | ./%1 && open %2.ast.png") +#else + QString::fromLatin1("$ echo \"int foo() {}\" | ./%1 && xdg-open %2.ast.png") +#endif + .arg(QFileInfo(qApp->arguments().at(0)).fileName(), PATH_STDIN_FILE); +} + +void printUsage() +{ + std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName()) + << " [-v] ...\n\n"; + + std::cout << qPrintable(QString::fromLatin1( + "Visualize AST and symbol hierarchy of given C++ files by generating png image files\n" + "in the same directory as the input files. Print paths to generated image files.\n" + "\n" + "Standard input is also read. The resulting files starts with \"%1\"\n" + "and are created in the current working directory. To show the AST for simple snippets\n" + "you might want to execute:\n" + "\n" + " %2\n" + "\n" + "Prerequisites:\n" + " 1) Make sure to have 'dot' from graphviz locatable by PATH.\n" + " 2) Make sure to have an up to date dumpers file by using 'cplusplus-update-frontend'.\n" + ).arg(PATH_STDIN_FILE, example())); +} + int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); + QStringList args = app.arguments(); + args.removeFirst(); - QStringList files = app.arguments(); - files.removeFirst(); + bool optionVerbose = false; + // Data from stdin? + if (!tty_for_stdin()) { + QFile file("_stdincontents.cpp"); + if (! file.open(QFile::WriteOnly)) { + std::cerr << "Error: Cannot open file for writing\"" << qPrintable(file.fileName()) + << "\"" << std::endl; + exit(EXIT_FAILURE); + } + file.write(QTextStream(stdin).readAll().toLocal8Bit()); + file.close(); + args.append(file.fileName()); + } + + // Process options & arguments + if (args.contains("-v")) { + optionVerbose = true; + args.removeOne("-v"); + } + const bool helpRequested = args.contains("-h") || args.contains("-help"); + if (args.isEmpty() || helpRequested) { + printUsage(); + return helpRequested ? EXIT_SUCCESS : EXIT_FAILURE; + } + + // Process files + const QStringList files = args; foreach (const QString &fileName, files) { - QFile file(fileName); + if (! QFile::exists(fileName)) { + std::cerr << "Error: File \"" << qPrintable(fileName) << "\" does not exist." + << std::endl; + exit(EXIT_FAILURE); + } + + // Run the preprocessor + const QString fileNamePreprocessed = fileName + QLatin1String(".preprocessed"); + CplusplusToolsUtils::SystemPreprocessor preprocessor(optionVerbose); + preprocessor.preprocessFile(fileName, fileNamePreprocessed); + + // Convert to dot + QFile file(fileNamePreprocessed); if (! file.open(QFile::ReadOnly)) { - std::cerr << "Cannot open \"" << qPrintable(fileName) - << "\", skipping it." << std::endl; - continue; + std::cerr << "Error: Could not open file \"" << qPrintable(fileNamePreprocessed) + << "\"" << std::endl; + exit(EXIT_FAILURE); } const QByteArray source = file.readAll(); @@ -373,7 +468,6 @@ int main(int argc, char *argv[]) doc->control()->setDiagnosticClient(0); doc->setUtf8Source(source); doc->parse(); - doc->check(); ASTDump dump(doc->translationUnit()); @@ -381,6 +475,18 @@ int main(int argc, char *argv[]) SymbolDump dump2(doc->translationUnit()); dump2(doc->globalNamespace()); + + // Create images + typedef QPair Pair; + QList inputOutputFiles; + inputOutputFiles.append(qMakePair(QString(fileName + QLatin1String(".ast.dot")), + QString(fileName + QLatin1String(".ast.png")))); + inputOutputFiles.append(qMakePair(QString(fileName + QLatin1String(".symbols.dot")), + QString(fileName + QLatin1String(".symbols.png")))); + foreach (const Pair &pair, inputOutputFiles) { + createImageFromDot(pair.first, pair.second, optionVerbose); + std::cout << qPrintable(QDir::toNativeSeparators(pair.second)) << std::endl; + } } return EXIT_SUCCESS; diff --git a/tests/tools/cplusplus-ast2png/cplusplus-ast2png.pro b/tests/tools/cplusplus-ast2png/cplusplus-ast2png.pro new file mode 100644 index 00000000000..8a0fd726ad5 --- /dev/null +++ b/tests/tools/cplusplus-ast2png/cplusplus-ast2png.pro @@ -0,0 +1,12 @@ +QT = core gui +macx:CONFIG -= app_bundle +win32:CONFIG += console +TEMPLATE = app +TARGET = cplusplus-ast2png +DESTDIR = ./ + +include(../../../qtcreator.pri) +include(../../../src/libs/cplusplus/cplusplus-lib.pri) +include(../../../src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri) + +SOURCES += cplusplus-ast2png.cpp diff --git a/tests/tools/cplusplus-dump/dumpers.inc b/tests/tools/cplusplus-ast2png/dumpers.inc similarity index 100% rename from tests/tools/cplusplus-dump/dumpers.inc rename to tests/tools/cplusplus-ast2png/dumpers.inc diff --git a/tests/tools/cplusplus-dump/tests/templ01.cpp b/tests/tools/cplusplus-ast2png/tests/templ01.cpp similarity index 100% rename from tests/tools/cplusplus-dump/tests/templ01.cpp rename to tests/tools/cplusplus-ast2png/tests/templ01.cpp diff --git a/tests/tools/cplusplus-dump/c++ b/tests/tools/cplusplus-dump/c++ deleted file mode 100755 index a5908b79ff1..00000000000 --- a/tests/tools/cplusplus-dump/c++ +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -me=$(dirname $0) -${CPP-gcc} -U__BLOCKS__ -xc++ -E -include $me/conf.c++ $* > $me/file.i -$me/cplusplus0 $me/file.i - diff --git a/tests/tools/cplusplus-dump/conf.c++ b/tests/tools/cplusplus-dump/conf.c++ deleted file mode 100644 index 69bafe0459c..00000000000 --- a/tests/tools/cplusplus-dump/conf.c++ +++ /dev/null @@ -1,15 +0,0 @@ -#define __extension__ -#define __context__ -#define __range__ -#define __asm(a...) -#define __asm__(a...) -#define restrict -#define __restrict -#define __restrict__ -// #define __weak -#define __builtin_va_arg(a,b) ((b)0) -#define __stdcall -#define __fastcall -#define __imag__ -#define __real__ -#define __complex__ diff --git a/tests/tools/cplusplus-dump/cplusplus-dump.pro b/tests/tools/cplusplus-dump/cplusplus-dump.pro deleted file mode 100644 index cd6525119e7..00000000000 --- a/tests/tools/cplusplus-dump/cplusplus-dump.pro +++ /dev/null @@ -1,20 +0,0 @@ -QT = core gui -macx:CONFIG -= app_bundle -TARGET = cplusplus0 - -include(../../../qtcreator.pri) -include(../../../src/libs/cplusplus/cplusplus.pri) - -# Input -SOURCES += main.cpp - -unix { - debug:OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared - release:OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared - - debug:MOC_DIR = $${OUT_PWD}/.moc/debug-shared - release:MOC_DIR = $${OUT_PWD}/.moc/release-shared - - RCC_DIR = $${OUT_PWD}/.rcc/ - UI_DIR = $${OUT_PWD}/.uic/ -} diff --git a/tests/tools/tools.pro b/tests/tools/tools.pro index f8339cd1f8a..f54f92d40cc 100644 --- a/tests/tools/tools.pro +++ b/tests/tools/tools.pro @@ -1,5 +1,5 @@ TEMPLATE=subdirs SUBDIRS= \ -cplusplus-dump \ +cplusplus-ast2png \ qml-ast2dot From a9907960705572cff736585b3b04ca5d5932daca Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Thu, 22 Nov 2012 14:30:29 +0100 Subject: [PATCH 24/35] Creator Examples: prioritize default Qt version when searching examples Change-Id: Id287332535494dd51609178d429d58749b0c28d6 Reviewed-by: hjk --- src/plugins/qtsupport/exampleslistmodel.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 859acb271f4..b59733efee8 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -41,6 +41,8 @@ #include #include +#include +#include #include using QtSupport::QtVersionManager; @@ -344,9 +346,15 @@ QStringList ExamplesListModel::exampleSources(QString *examplesFallback, QString QString potentialSourceFallback; const QStringList pattern(QLatin1String("*.xml")); + // prioritize default qt version QtVersionManager *versionManager = QtVersionManager::instance(); + QList qtVersions = versionManager->validVersions(); + ProjectExplorer::Kit *defaultKit = ProjectExplorer::KitManager::instance()->defaultKit(); + BaseQtVersion *defaultVersion = QtKitInformation::qtVersion(defaultKit); + if (defaultVersion && qtVersions.contains(defaultVersion)) + qtVersions.move(qtVersions.indexOf(defaultVersion), 0); - foreach (BaseQtVersion *version, versionManager->validVersions()) { + foreach (BaseQtVersion *version, qtVersions) { // qt5 with examples OR demos manifest if (version->qtVersion().majorVersion == 5 && (version->hasExamples() || version->hasDemos())) { // examples directory in Qt5 is under the qtbase submodule, @@ -367,9 +375,7 @@ QStringList ExamplesListModel::exampleSources(QString *examplesFallback, QString return sources; } } - } - foreach (BaseQtVersion *version, versionManager->validVersions()) { QFileInfoList fis; if (version->hasExamples()) fis << QDir(version->examplesPath()).entryInfoList(pattern); From a1dbe9a3c788c9a7029c602f92b4e04c9713c6c4 Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Thu, 22 Nov 2012 12:43:59 +0100 Subject: [PATCH 25/35] QML Debugging: Qt Quick 2 Application Wizard QML debugging is enabled by default for applications created with the Qt Quick 2 application wizard. Task-number: QTCREATORBUG-8208 Change-Id: I1869649ce88c35e2d8d4a6677b1d257f7454f223 Reviewed-by: Kai Koehne --- src/plugins/projectexplorer/runconfiguration.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 0ec71ee0838..64c70597871 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -158,9 +158,15 @@ bool DebuggerRunConfigurationAspect::useCppDebugger() const static bool isQtQuickAppProject(Project *project) { - const QString filePath = project->projectDirectory() + const QString projectDirectory = project->projectDirectory(); + // Qt Quick 1 wizard generated file + const QString qq1FilePath = projectDirectory + QLatin1String("/qmlapplicationviewer/qmlapplicationviewer.pri"); - return project->files(Project::ExcludeGeneratedFiles).contains(filePath); + // Qt Quick 2 wizard generated file + const QString qq2FilePath = projectDirectory + + QLatin1String("/qtquick2applicationviewer/qtquick2applicationviewer.pri"); + const QStringList projectFiles = project->files(Project::ExcludeGeneratedFiles); + return projectFiles.contains(qq1FilePath) || projectFiles.contains(qq2FilePath); } bool DebuggerRunConfigurationAspect::useQmlDebugger() const From 1678b5e59e35fa87499ea2b7fdf7d9139d381363 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 22 Nov 2012 14:58:29 +0100 Subject: [PATCH 26/35] QtQuick wizards: Mark all wizards as either Qt Quick 1 or Qt Quick 2 Mark especially the import wizard as Qt Quick 1 only (we won't provide a Qt Quick 2 version at the moment, and will most likely remove it completely in 2.7) Task-number: QTCREATORBUG-8313 Change-Id: I2dc0d4055a7e174d3d92525189c0d98e3b1f8860 Reviewed-by: Alessandro Portale Reviewed-by: Leena Miettinen --- .../qt4projectmanager/wizards/qtquickappwizard.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp b/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp index 41902dbe3ab..bf0c3c1ebac 100644 --- a/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp @@ -135,7 +135,7 @@ void QtQuickAppWizard::createInstances(ExtensionSystem::IPlugin *plugin) QList list; Core::BaseFileWizardParameters parameter; - const QString basicDescription = tr("Creates a Qt Quick application project that can contain " + const QString basicDescription = tr("Creates a Qt Quick 1 application project that can contain " "both QML and C++ code and includes a QDeclarativeView.\n\n"); Core::FeatureSet basicFeatures; @@ -151,7 +151,7 @@ void QtQuickAppWizard::createInstances(ExtensionSystem::IPlugin *plugin) parameter = base; parameter.setDisplayName(tr("Qt Quick 2 Application (Built-in Elements)")); - parameter.setDescription(tr("Creates a Qt Quick application project that can contain " + parameter.setDescription(tr("Creates a Qt Quick 2 application project that can contain " "both QML and C++ code and includes a QQuickView.\n\n" "The built-in elements in the QtQuick 2 namespace allow " "you to write cross-platform applications with " @@ -160,7 +160,7 @@ void QtQuickAppWizard::createInstances(ExtensionSystem::IPlugin *plugin) list << parameter; parameter = base; - parameter.setDisplayName(tr("Qt Quick Application for MeeGo Harmattan")); + parameter.setDisplayName(tr("Qt Quick 1 Application for MeeGo Harmattan")); parameter.setDescription(basicDescription + tr("The Qt Quick Components for MeeGo Harmattan are " "a set of ready-made components that are designed " "with specific native appearance for the MeeGo Harmattan " @@ -171,7 +171,7 @@ void QtQuickAppWizard::createInstances(ExtensionSystem::IPlugin *plugin) list << parameter; parameter = base; - parameter.setDisplayName(tr("Qt Quick Application (from Existing QML File)")); + parameter.setDisplayName(tr("Qt Quick 1 Application (from Existing QML File)")); parameter.setDescription(basicDescription + tr("Creates a deployable Qt Quick application from " "existing QML files. All files and directories that " "reside in the same directory as the main .qml file " From bc012ec709c965157567f38202f34c5946d0ff5d Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Thu, 22 Nov 2012 14:47:35 +0100 Subject: [PATCH 27/35] Kits: Allow autodetected kits to become default Allow autodetected kits to be set as default kit. That was not possible via the UI so far. Change-Id: I6dac210d8390e6ab25cf8f022e5ae8293115cacf Reviewed-by: Daniel Teske --- src/plugins/projectexplorer/kitmodel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/kitmodel.cpp b/src/plugins/projectexplorer/kitmodel.cpp index 9131ba19d66..de7d9ff30cc 100644 --- a/src/plugins/projectexplorer/kitmodel.cpp +++ b/src/plugins/projectexplorer/kitmodel.cpp @@ -279,7 +279,9 @@ void KitModel::apply() } // Update kits: - foreach (KitNode *n, m_manualRoot->childNodes) { + nodes = m_autoRoot->childNodes; // These can be dirty due to being made default! + nodes.append(m_manualRoot->childNodes); + foreach (KitNode *n, nodes) { Q_ASSERT(n); Q_ASSERT(n->widget); if (n->widget->isDirty()) { From adc8dc7bfb2ed8bc1d28cbbcb5e0a67f18fc6f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Tue, 20 Nov 2012 10:49:58 +0100 Subject: [PATCH 28/35] Fix regression: Windows SDK 7.1 compiler detection setenv.cmd from Windows SDk 7.1 automatically maps to a cross-compiler and does not know /amd64. Nothing to do for Windows SDK 8: "...the Windows SDK no longer ships the following components: Windows SDK Platform Toolset Visual C++ Compilers and C Runtime (CRT) Windows SDK Configuration Tool" Change-Id: Iade79631c4fd30f376c08b6dd9b47d174c0d9059 Reviewed-by: Friedemann Kleint Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/msvctoolchain.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index 5785398a784..a47d1039e05 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -467,19 +467,19 @@ QList MsvcToolChainFactory::autoDetect() tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::x86), findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::x86, version), fi.absoluteFilePath(), QLatin1String("/x86"), true)); - // Add all platforms + // Add all platforms, cross-compiler is automatically selected by SetEnv.cmd if needed tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::amd64), findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::amd64, version), - fi.absoluteFilePath(), QLatin1String("/amd64"), true)); + fi.absoluteFilePath(), QLatin1String("/x64"), true)); tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::x86_amd64), findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::x86_amd64, version), - fi.absoluteFilePath(), QLatin1String("/x86_amd64"), true)); + fi.absoluteFilePath(), QLatin1String("/x64"), true)); tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::ia64), findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::ia64, version), fi.absoluteFilePath(), QLatin1String("/ia64"), true)); tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::x86_ia64), findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::x86_ia64, version), - fi.absoluteFilePath(), QLatin1String("/x86_ia64"), true)); + fi.absoluteFilePath(), QLatin1String("/ia64"), true)); // Make sure the default is front. if (folder == defaultSdkPath) results = tmp + results; From 56966f3712b9ec2d790b7185d230d3193f261a62 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gorszkowski Date: Wed, 21 Nov 2012 09:56:31 +0100 Subject: [PATCH 29/35] C++: Fix code completion for Qt containers This change solves only problem with Qt containers. stl containers need separate change. Problem was with predeclaration of template class after declaration of this template class. (there is unit test added which shows the problem). Task-number: QTCREATORBUG-8228 (cover only Qt containers) Change-Id: If1f76c88c955b7b55347d302b353f5cd52b244a4 Reviewed-by: Erik Verbruggen Conflicts: src/plugins/cpptools/cppcompletion_test.cpp Change-Id: I9f665276926f2e440ad0c92e94dd1aeee89005b3 Reviewed-by: Eike Ziller --- src/libs/cplusplus/LookupContext.cpp | 2 +- src/plugins/cpptools/cppcompletion_test.cpp | 39 +++++++++++++++++++++ src/plugins/cpptools/cpptoolsplugin.h | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index c2c7b5c5993..4f56c5180a8 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -730,7 +730,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac return reference; const TemplateNameId *templId = name->asTemplateNameId(); - if (_alreadyConsideredClasses.contains(referenceClass) || + if ((! templId && _alreadyConsideredClasses.contains(referenceClass)) || (templId && _alreadyConsideredTemplates.contains(templId))) { return reference; diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index f36ac54a6c4..8dce2e5db13 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -370,6 +370,45 @@ void CppToolsPlugin::test_completion_template_5() QVERIFY(completions.contains("b")); } +void CppToolsPlugin::test_completion_template_6() +{ + TestData data; + data.srcText = "\n" + "class Item\n" + "{\n" + " int i;\n" + "};\n" + "\n" + "template \n" + "class Container\n" + "{\n" + " T get();\n" + "};\n" + "\n" + "template class Container;\n" + "\n" + "class ItemContainer: public Container\n" + "{};\n" + "ItemContainer container;\n" + "@\n" + ; + + setup(&data); + + Utils::ChangeSet change; + QString txt = QLatin1String("container.get()."); + change.insert(data.pos, txt); + QTextCursor cursor(data.doc); + change.apply(&cursor); + data.pos += txt.length(); + + QStringList completions = getCompletions(data); + + QCOMPARE(completions.size(), 2); + QVERIFY(completions.contains("Item")); + QVERIFY(completions.contains("i")); +} + void CppToolsPlugin::test_completion() { QFETCH(QByteArray, code); diff --git a/src/plugins/cpptools/cpptoolsplugin.h b/src/plugins/cpptools/cpptoolsplugin.h index 4bfafddb318..597a6ab27c4 100644 --- a/src/plugins/cpptools/cpptoolsplugin.h +++ b/src/plugins/cpptools/cpptoolsplugin.h @@ -96,6 +96,7 @@ private slots: void test_completion_template_3(); void test_completion_template_4(); void test_completion_template_5(); + void test_completion_template_6(); void test_completion_template_as_base(); void test_completion_template_as_base_data(); void test_completion_use_global_identifier_as_base_class(); From cab6ed5e5133c1adf7f796254d7db5736215c217 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Mon, 19 Nov 2012 11:20:11 +0100 Subject: [PATCH 30/35] Fix: no scope walking for name resolving after MemAccess operator Change-Id: Ic093079fa65d8d749911fd9f5b0f629e9fe68a1e Reviewed-by: Nikolai Kosjar Conflicts: tests/auto/cplusplus/findusages/tst_findusages.cpp Change-Id: I87d305e2d68582aa00b92f9599368615cd76ec74 Reviewed-by: Eike Ziller --- src/libs/cplusplus/LookupContext.h | 1 + src/libs/cplusplus/ResolveExpression.cpp | 2 +- src/plugins/cpptools/cppcompletion_test.cpp | 2 - .../cplusplus/findusages/tst_findusages.cpp | 65 +++++++++++++++++++ 4 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h index 5d42f9a070c..e72c8fd3f92 100644 --- a/src/libs/cplusplus/LookupContext.h +++ b/src/libs/cplusplus/LookupContext.h @@ -145,6 +145,7 @@ private: AlreadyConsideredClassContainer _alreadyConsideredTemplates; #ifdef DEBUG_LOOKUP +public: const Name *_name; #endif // DEBUG_LOOKUP diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index dfa634d799b..65908254da2 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -806,7 +806,7 @@ bool ResolveExpression::visit(MemberAccessAST *ast) const int accessOp = tokenKind(ast->access_token); if (ClassOrNamespace *binding = baseExpression(baseResults, accessOp)) - addResults(binding->lookup(memberName)); + addResults(binding->find(memberName)); return false; } diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index 8dce2e5db13..33dc05aa5c9 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -997,7 +997,6 @@ void CppToolsPlugin::test_completion_cyclic_inheritance_data() "};\n" "\n" "Class c;\n" - "c.\n" "@\n" ; completions.append("Class"); @@ -1007,5 +1006,4 @@ void CppToolsPlugin::test_completion_cyclic_inheritance_data() completions.append("class_recurse_t"); QTest::newRow("case: direct cyclic inheritance with templates, more complex situation") << code << completions; - } diff --git a/tests/auto/cplusplus/findusages/tst_findusages.cpp b/tests/auto/cplusplus/findusages/tst_findusages.cpp index f9b82adadfa..dc1f765ee7a 100644 --- a/tests/auto/cplusplus/findusages/tst_findusages.cpp +++ b/tests/auto/cplusplus/findusages/tst_findusages.cpp @@ -77,6 +77,8 @@ class tst_FindUsages: public QObject private Q_SLOTS: void inlineMethod(); + void shadowedNames_1(); + void shadowedNames_2(); // Qt keywords void qproperty_1(); @@ -123,6 +125,69 @@ void tst_FindUsages::inlineMethod() QCOMPARE(findUsages.references().size(), 2); } +void tst_FindUsages::shadowedNames_1() +{ + const QByteArray src = "\n" + "int a();\n" + "struct X{ int a(); };\n" + "int X::a() {}\n" + "void f(X x) { x.a(); }\n" + "void g() { a(); }\n" + ; + + Document::Ptr doc = Document::create("shadowedNames_1"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QCOMPARE(doc->globalSymbolCount(), 5U); + + Snapshot snapshot; + snapshot.insert(doc); + + Declaration *d = doc->globalSymbolAt(0)->asDeclaration(); + QVERIFY(d); + QCOMPARE(d->name()->identifier()->chars(), "a"); + + FindUsages findUsages(src, doc, snapshot); + findUsages(d); + QCOMPARE(findUsages.usages().size(), 2); +} + +void tst_FindUsages::shadowedNames_2() +{ + const QByteArray src = "\n" + "int a();\n" + "struct X{ int a(); };\n" + "int X::a() {}\n" + "void f(X x) { x.a(); }\n" + "void g() { a(); }\n"; + + Document::Ptr doc = Document::create("shadowedNames_2"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QCOMPARE(doc->globalSymbolCount(), 5U); + + Snapshot snapshot; + snapshot.insert(doc); + + Class *c = doc->globalSymbolAt(1)->asClass(); + QVERIFY(c); + QCOMPARE(c->name()->identifier()->chars(), "X"); + QCOMPARE(c->memberCount(), 1U); + Declaration *d = c->memberAt(0)->asDeclaration(); + QVERIFY(d); + QCOMPARE(d->name()->identifier()->chars(), "a"); + + FindUsages findUsages(src, doc, snapshot); + findUsages(d); + QCOMPARE(findUsages.usages().size(), 3); +} + #if 0 @interface Clazz {} +(void)method:(int)arg; @end @implementation Clazz +(void)method:(int)arg { From 4930fbcc1e0693e2bc891f047150a06fb687eaf4 Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Wed, 21 Nov 2012 17:46:58 +0100 Subject: [PATCH 31/35] QML Debugging: Qt 5 CONFIG+=declarative_debug qml_debug Pass both arguments to qmake. The assumption being that most projects will not mix both Qt Quick 1 and Qt Quick 2. In the case of others, debugging will be enabled only for the first debugging client that is enabled. This is inline with the current behaviour where debugging multiple engines is not supported. Change-Id: I90cd6c6ff559a3a7519ee3ee10690c0e8135c97b Reviewed-by: hjk Reviewed-by: Kai Koehne --- src/plugins/debugger/qml/qmlinspectoradapter.cpp | 3 ++- src/plugins/qt4projectmanager/qmakestep.cpp | 9 ++++++--- src/plugins/qt4projectmanager/qt4buildconfiguration.cpp | 4 ++-- .../qt4projectmanager/qt4projectmanagerconstants.h | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/plugins/debugger/qml/qmlinspectoradapter.cpp b/src/plugins/debugger/qml/qmlinspectoradapter.cpp index e48c3392b39..164d77258c3 100644 --- a/src/plugins/debugger/qml/qmlinspectoradapter.cpp +++ b/src/plugins/debugger/qml/qmlinspectoradapter.cpp @@ -251,7 +251,8 @@ void QmlInspectorAdapter::engineClientStatusChanged(QmlDebug::ClientStatus statu BaseEngineDebugClient *client = qobject_cast(sender()); - if (status == QmlDebug::Enabled) { + if (status == QmlDebug::Enabled && !m_engineClientConnected) { + // We accept the first client that is enabled and reject the others. QTC_ASSERT(client, return); setActiveEngineClient(client); } else if (m_engineClientConnected && client == m_engineClient) { diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp index 26e4eefb7cb..310759593e2 100644 --- a/src/plugins/qt4projectmanager/qmakestep.cpp +++ b/src/plugins/qt4projectmanager/qmakestep.cpp @@ -201,9 +201,12 @@ QStringList QMakeStep::deducedArguments() if (!version->needsQmlDebuggingLibrary()) { // This Qt version has the QML debugging services built in, however // they still need to be enabled at compile time - arguments << (version->qtVersion().majorVersion >= 5 ? - QLatin1String(Constants::QMAKEVAR_DECLARATIVE_DEBUG5) : - QLatin1String(Constants::QMAKEVAR_DECLARATIVE_DEBUG4)); + // TODO: For Qt5, we can pass both arguments as there can be Qt Quick 1/2 projects. + // Currently there is no support for debugging multiple engines. + arguments << QLatin1String(Constants::QMAKEVAR_QUICK1_DEBUG); + if (version->qtVersion().majorVersion >= 5) { + arguments << QLatin1String(Constants::QMAKEVAR_QUICK2_DEBUG); + } } else { const QString qmlDebuggingHelperLibrary = version->qmlDebuggingHelperLibrary(true); if (!qmlDebuggingHelperLibrary.isEmpty()) { diff --git a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp index a17fa4d4b6b..5b2b8f247f7 100644 --- a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp @@ -436,8 +436,8 @@ bool Qt4BuildConfiguration::removeQMLInspectorFromArguments(QString *args) for (Utils::QtcProcess::ArgIterator ait(args); ait.next(); ) { const QString arg = ait.value(); if (arg.contains(QLatin1String(Constants::QMAKEVAR_QMLJSDEBUGGER_PATH)) - || arg.contains(QLatin1String(Constants::QMAKEVAR_DECLARATIVE_DEBUG4)) - || arg.contains(QLatin1String(Constants::QMAKEVAR_DECLARATIVE_DEBUG5))) { + || arg.contains(QLatin1String(Constants::QMAKEVAR_QUICK1_DEBUG)) + || arg.contains(QLatin1String(Constants::QMAKEVAR_QUICK2_DEBUG))) { ait.deleteArg(); removedArgument = true; } diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h index 1710c0bfb27..ebb77f1789d 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h +++ b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h @@ -89,8 +89,8 @@ const char ICON_HTML5_APP[] = ":/wizards/images/html5app.png"; // Env variables const char QMAKEVAR_QMLJSDEBUGGER_PATH[] = "QMLJSDEBUGGER_PATH"; -const char QMAKEVAR_DECLARATIVE_DEBUG4[] = "CONFIG+=declarative_debug"; -const char QMAKEVAR_DECLARATIVE_DEBUG5[] = "CONFIG+=qml_debug"; +const char QMAKEVAR_QUICK1_DEBUG[] = "CONFIG+=declarative_debug"; +const char QMAKEVAR_QUICK2_DEBUG[] = "CONFIG+=qml_debug"; // Unconfigured Panel const char UNCONFIGURED_PANEL_PAGE_ID[] = "UnconfiguredPanel"; From 5bd251e8052a262e30d4a6fced86d5217c455a5e Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 21 Nov 2012 16:04:48 +0100 Subject: [PATCH 32/35] Win: Do fail less often when adding mingw Qt versions Task-number: QTCREATORBUG-8225 Change-Id: I7b5db59ef7967a074e07ae87deff90235190aaa9 Reviewed-by: Daniel Teske Reviewed-by: Friedemann Kleint --- src/plugins/qtsupport/baseqtversion.cpp | 80 +++++++++++++++---------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 2869a769c88..ec781d717ad 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -1185,49 +1185,69 @@ bool BaseQtVersion::queryQMakeVariables(const Utils::FileName &binary, QHash *versionInfo, bool *qmakeIsExecutable) { - const int timeOutMS = 30000; // Might be slow on some machines. const QFileInfo qmake = binary.toFileInfo(); *qmakeIsExecutable = qmake.exists() && qmake.isExecutable() && !qmake.isDir(); if (!*qmakeIsExecutable) return false; - QProcess process; - Utils::Environment env = Utils::Environment::systemEnvironment(); + QByteArray output; + output = runQmakeQuery(binary, Utils::Environment::systemEnvironment(), qmakeIsExecutable); -#ifdef Q_OS_WIN - // Add tool chain environment. This is necessary for non-static qmakes e.g. using mingw on windows - // We can not just add all the environments of all tool chains since that will make PATH too long - // which in turn will trigger a crash when parsing the results of vcvars.bat of MSVC. - QList abiList = ProjectExplorer::Abi::abisOfBinary(binary); - QList tcList = ProjectExplorer::ToolChainManager::instance()->toolChains(); - foreach (ProjectExplorer::ToolChain *tc, tcList) { - if (abiList.contains(tc->targetAbi())) + if (output.isNull() && !qmakeIsExecutable) { + // Note: Don't rerun if we were able to execute the binary before. + + // Try running qmake with all kinds of tool chains set up in the environment. + // This is required to make non-static qmakes work on windows where every tool chain + // tries to be incompatible with any other. + QList abiList = ProjectExplorer::Abi::abisOfBinary(binary); + QList tcList = ProjectExplorer::ToolChainManager::instance()->toolChains(); + foreach (ProjectExplorer::ToolChain *tc, tcList) { + if (!abiList.contains(tc->targetAbi())) + continue; + Utils::Environment env = Utils::Environment::systemEnvironment(); tc->addToEnvironment(env); + output = runQmakeQuery(binary, env, qmakeIsExecutable); + if (qmakeIsExecutable) + break; + } } -#endif - process.setEnvironment(env.toStringList()); - process.start(qmake.absoluteFilePath(), QStringList(QLatin1String("-query")), QIODevice::ReadOnly); + if (output.isNull()) + return false; - if (!process.waitForStarted()) { - *qmakeIsExecutable = false; - qWarning("Cannot start '%s': %s", qPrintable(binary.toUserOutput()), qPrintable(process.errorString())); - return false; - } - if (!process.waitForFinished(timeOutMS)) { - Utils::SynchronousProcess::stopProcess(process); - qWarning("Timeout running '%s' (%dms).", qPrintable(binary.toUserOutput()), timeOutMS); - return false; - } - if (process.exitStatus() != QProcess::NormalExit) { - *qmakeIsExecutable = false; - qWarning("'%s' crashed.", qPrintable(binary.toUserOutput())); - return false; - } - QByteArray output = process.readAllStandardOutput(); QTextStream stream(&output); while (!stream.atEnd()) { const QString line = stream.readLine(); From 8d825b5b09775f5938c1d63355d7e65e1bba5ed7 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 23 Nov 2012 12:46:43 +0100 Subject: [PATCH 33/35] Wizards.QmlProject: Creating a Qt Quick 2.0 file The reference to Maemo does not make sense anymore. Change-Id: Ic7f8245912d200397e7dcc20e69ee42eed2939dc Reviewed-by: hjk --- .../qmlprojectmanager/qmlprojectapplicationwizard.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmlprojectmanager/qmlprojectapplicationwizard.cpp b/src/plugins/qmlprojectmanager/qmlprojectapplicationwizard.cpp index 15a83b926be..99d593e5083 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectapplicationwizard.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectapplicationwizard.cpp @@ -79,7 +79,7 @@ Core::BaseFileWizardParameters QmlProjectApplicationWizard::parameters() "QML file that contains the main view.\n\n" "You can review Qt Quick UI projects in the QML Viewer and you need not build them. " "You do not need to have the development environment installed " - "on your computer to create and run this type of projects.\n\nRequires Qt 4.7.4 or newer.")); + "on your computer to create and run this type of projects.\n\nRequires Qt 5.0 or newer.")); parameters.setCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY)); parameters.setDisplayCategory(QT_TRANSLATE_NOOP("ProjectExplorer", "Qt Application")); return parameters; @@ -119,8 +119,7 @@ Core::GeneratedFiles QmlProjectApplicationWizard::generateFiles(const QWizard *w QTextStream out(&contents); out - << "// import QtQuick 1.0 // to target Maemo 5" << endl - << "import QtQuick 1.1" << endl + << "import QtQuick 2.0" << endl << endl << "Rectangle {" << endl << " width: 360" << endl From 32a0afb9df4971aa433428340b30d773cae464f7 Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Fri, 23 Nov 2012 17:15:29 +0100 Subject: [PATCH 34/35] Inspector: Fetch objects lazily QML objects are fetched lazily when constructing the object tree. Incase parents have not been previously fetched, we fetch the required data to construct only the relevant branch of the tree. Task-number: QTCREATORBUG-8246 Change-Id: Id529c3b2334d33ff4eb46b14f50cf042ad2960e2 Reviewed-by: hjk --- .../debugger/qml/qmlinspectoragent.cpp | 69 +++++++++++++++---- src/plugins/debugger/qml/qmlinspectoragent.h | 2 +- src/plugins/debugger/watchhandler.cpp | 5 ++ src/plugins/debugger/watchhandler.h | 1 + 4 files changed, 62 insertions(+), 15 deletions(-) diff --git a/src/plugins/debugger/qml/qmlinspectoragent.cpp b/src/plugins/debugger/qml/qmlinspectoragent.cpp index a1098b9fd6c..1573a9cdb0b 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.cpp +++ b/src/plugins/debugger/qml/qmlinspectoragent.cpp @@ -62,6 +62,7 @@ QmlInspectorAgent::QmlInspectorAgent(DebuggerEngine *engine, QObject *parent) , m_objectToSelect(-1) , m_newObjectsCreated(false) { + m_debugIdToIname.insert(-1, QByteArray("inspect")); connect(debuggerCore()->action(ShowQmlObjectTree), SIGNAL(valueChanged(QVariant)), SLOT(updateStatus())); m_delayQueryTimer.setSingleShot(true); @@ -452,17 +453,17 @@ void QmlInspectorAgent::onResult(quint32 queryId, const QVariant &value, } if (m_objectTreeQueryIds.contains(queryId)) { + m_objectTreeQueryIds.removeOne(queryId); if (value.type() == QVariant::List) { QVariantList objList = value.toList(); foreach (QVariant var, objList) { // TODO: check which among the list is the actual // object that needs to be selected. - insertObjectInTree(qvariant_cast(var)); + verifyAndInsertObjectInTree(qvariant_cast(var)); } } else { - insertObjectInTree(qvariant_cast(value)); + verifyAndInsertObjectInTree(qvariant_cast(value)); } - m_objectTreeQueryIds.removeOne(queryId); } else if (queryId == m_engineQueryId) { m_engineQueryId = 0; QList engines = qvariant_cast >(value); @@ -608,13 +609,13 @@ void QmlInspectorAgent::updateObjectTree(const ContextReference &context) return; foreach (const ObjectReference & obj, context.objects()) - insertObjectInTree(obj); + verifyAndInsertObjectInTree(obj); foreach (const ContextReference &child, context.contexts()) updateObjectTree(child); } -void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object) +void QmlInspectorAgent::verifyAndInsertObjectInTree(const ObjectReference &object) { if (debug) qDebug() << __FUNCTION__ << '(' << object << ')'; @@ -622,17 +623,56 @@ void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object) if (!object.isValid()) return; + // Find out the correct position in the tree + // Objects are inserted to the tree if they satisfy one of the two conditions. + // Condition 1: Object is a root object i.e. parentId == -1. + // Condition 2: Object has an expanded parent i.e. siblings are known. + // If the two conditions are not met then we push the object to a stack and recursively + // fetch parents till we find a previously expanded parent. + + WatchHandler *handler = m_debuggerEngine->watchHandler(); + const int parentId = object.parentId(); + const int objectDebugId = object.debugId(); + if (m_debugIdToIname.contains(parentId)) { + QByteArray parentIname = m_debugIdToIname.value(parentId); + if (parentId != -1 && !handler->isExpandedIName(parentIname)) { + m_objectStack.push(object); + handler->model()->fetchMore(handler->watchDataIndex(parentIname)); + return; // recursive + } + insertObjectInTree(object); + + } else { + m_objectStack.push(object); + fetchObject(parentId); + return; // recursive + } + if (!m_objectStack.isEmpty()) { + const ObjectReference &top = m_objectStack.top(); + // We want to expand only a particular branch and not the whole tree. Hence, we do not + // expand siblings. + if (object.children().contains(top)) { + QByteArray objectIname = m_debugIdToIname.value(objectDebugId); + if (!handler->isExpandedIName(objectIname)) { + handler->model()->fetchMore(handler->watchDataIndex(objectIname)); + } else { + verifyAndInsertObjectInTree(m_objectStack.pop()); + return; // recursive + } + } + } +} + +void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object) +{ + if (debug) + qDebug() << __FUNCTION__ << '(' << object << ')'; + + const int objectDebugId = object.debugId(); + const int parentId = parentIdForIname(m_debugIdToIname.value(objectDebugId)); + QElapsedTimer timeElapsed; - // sync tree with watchhandler QList watchData; - int objectDebugId = object.debugId(); - - // When root items are inserted in the object tree, m_objectTreeQueryIds = 0 - if (!m_debugIdToIname.contains(objectDebugId) && m_objectTreeQueryIds.count()) - return; - - int parentId = parentIdForIname(m_debugIdToIname.value(objectDebugId)); - if (debug) timeElapsed.start(); watchData.append(buildWatchData(object, m_debugIdToIname.value(parentId), true)); @@ -829,6 +869,7 @@ void QmlInspectorAgent::clearObjectTree() m_debugIdHash.clear(); m_debugIdHash.reserve(old_count + 1); m_debugIdToIname.clear(); + m_debugIdToIname.insert(-1, QByteArray("inspect")); m_objectStack.clear(); // reset only for qt > 4.8.3. if (m_engineClient->objectName() != QLatin1String(QDECLARATIVE_ENGINE)) diff --git a/src/plugins/debugger/qml/qmlinspectoragent.h b/src/plugins/debugger/qml/qmlinspectoragent.h index d83f79b5b3e..7f60e5cd8f3 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.h +++ b/src/plugins/debugger/qml/qmlinspectoragent.h @@ -110,7 +110,7 @@ private slots: private: void updateObjectTree(const QmlDebug::ContextReference &context); - + void verifyAndInsertObjectInTree(const QmlDebug::ObjectReference &object); void insertObjectInTree(const QmlDebug::ObjectReference &result); void buildDebugIdHashRecursive(const QmlDebug::ObjectReference &ref); diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 8b1d3a6583c..58fa111b319 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -1807,6 +1807,11 @@ const WatchData *WatchHandler::watchData(const QModelIndex &idx) const return m_model->watchItem(idx); } +const QModelIndex WatchHandler::watchDataIndex(const QByteArray &iname) const +{ + return m_model->watchIndex(m_model->findItem(iname)); +} + const WatchData *WatchHandler::findData(const QByteArray &iname) const { return m_model->findItem(iname); diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index b5d8622c9e1..a7c1c6d3b61 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -85,6 +85,7 @@ public: void showEditValue(const WatchData &data); const WatchData *watchData(const QModelIndex &) const; + const QModelIndex watchDataIndex(const QByteArray &iname) const; const WatchData *findData(const QByteArray &iname) const; const WatchData *findCppLocalVariable(const QString &name) const; QString displayForAutoTest(const QByteArray &iname) const; From 9820278a708024cc1ae01372dfafabe4ff295b88 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Mon, 26 Nov 2012 08:54:22 +0100 Subject: [PATCH 35/35] Fix building against Qt5 on MacOS. Qt5 will set the mmacosx-version-min to either 10.6 or 10.7, depending on the mkspec used. These lines resulted in two mmacosx-version-min flags, when libc++ is used (macx-clang-libc++ mkspec), this leads to compiler errors. As Qt/qmake already adds the flag, there should not be a need to set it in the .pri/.pro files. Change-Id: Ib8cc59d2b064737aa0b5a889b2b3183eceaea1f3 Reviewed-by: Eike Ziller --- qtcreator.pri | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/qtcreator.pri b/qtcreator.pri index 977f47ef1fc..ed620d1ced0 100644 --- a/qtcreator.pri +++ b/qtcreator.pri @@ -127,9 +127,12 @@ macx { IDE_BIN_PATH = $$IDE_APP_PATH/$${IDE_APP_TARGET}.app/Contents/MacOS copydata = 1 isEmpty(TIGER_COMPAT_MODE):TIGER_COMPAT_MODE=$$(QTC_TIGER_COMPAT) - isEmpty(TIGER_COMPAT_MODE) { - QMAKE_CXXFLAGS *= -mmacosx-version-min=10.5 - QMAKE_LFLAGS *= -mmacosx-version-min=10.5 + !isEqual(QT_MAJOR_VERSION, 5) { + # Qt5 doesn't support 10.5, and will set the minimum version correctly to 10.6 or 10.7. + isEmpty(TIGER_COMPAT_MODE) { + QMAKE_CXXFLAGS *= -mmacosx-version-min=10.5 + QMAKE_LFLAGS *= -mmacosx-version-min=10.5 + } } } else { contains(TEMPLATE, vc.*):vcproj = 1