From 252a3f89c61ae9a14427f66788b26597e6d24a6c Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 8 Aug 2016 15:32:56 +0200 Subject: [PATCH 1/2] Fix wrong code in list/table model templates rowCount should return 0 if the parent *is* valid, and return the actual number of rows when queried with an invalid index. Change-Id: I00e3d4ea79e1aaf0be1974da876c5a871d3924e6 Reviewed-by: Alessandro Portale --- .../templates/wizards/classes/itemmodel/listmodel.cpp | 2 +- .../templates/wizards/classes/itemmodel/tablemodel.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp index 5d7fa72875f..2881513ab68 100644 --- a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp +++ b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp @@ -28,7 +28,7 @@ bool %{CN}::setHeaderData(int section, Qt::Orientation orientation, const QVaria int %{CN}::rowCount(const QModelIndex &parent) const { - if (!parent.isValid()) + if (parent.isValid()) return 0; // FIXME: Implement me! diff --git a/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp b/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp index fb452feace5..80bedf58990 100644 --- a/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp +++ b/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp @@ -29,7 +29,7 @@ bool %{CN}::setHeaderData(int section, Qt::Orientation orientation, const QVaria int %{CN}::rowCount(const QModelIndex &parent) const { - if (!parent.isValid()) + if (parent.isValid()) return 0; // FIXME: Implement me! @@ -37,7 +37,7 @@ int %{CN}::rowCount(const QModelIndex &parent) const int %{CN}::columnCount(const QModelIndex &parent) const { - if (!parent.isValid()) + if (parent.isValid()) return 0; // FIXME: Implement me! From e84abe3af1335c000b8f581c351b5e387101ea8f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 3 Aug 2016 16:27:22 +0200 Subject: [PATCH 2/2] Debugger: Only use random QML port if none was given This is a cherry-pick of 20db17e4f07c298874f01eb0f9ebeb26a7887fdd from 4.1. The problem also occurs in 4.0 and as another version of 4.0 might be released, we should fix it there, too. Change-Id: I3cf42abfa9d0ea5812495be6e2728264dc115ba9 Task-number: QTCREATORBUG-16708 Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggerruncontrol.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 9f077c46527..e925f7896fa 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -450,15 +450,18 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const if (m_rp.languages & QmlLanguage) { if (m_rp.device && m_rp.device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { - QTcpServer server; - const bool canListen = server.listen(QHostAddress::LocalHost) - || server.listen(QHostAddress::LocalHostIPv6); - if (!canListen) { - m_errors.append(DebuggerPlugin::tr("Not enough free ports for QML debugging.") + QLatin1Char(' ')); - return; + if (m_rp.qmlServerAddress.isEmpty() || m_rp.qmlServerPort == InvalidPort) { + QTcpServer server; + const bool canListen = server.listen(QHostAddress::LocalHost) + || server.listen(QHostAddress::LocalHostIPv6); + if (!canListen) { + m_errors.append(DebuggerPlugin::tr("Not enough free ports for QML debugging.") + + QLatin1Char(' ')); + return; + } + m_rp.qmlServerAddress = server.serverAddress().toString(); + m_rp.qmlServerPort = server.serverPort(); } - m_rp.qmlServerAddress = server.serverAddress().toString(); - m_rp.qmlServerPort = server.serverPort(); // Makes sure that all bindings go through the JavaScript engine, so that // breakpoints are actually hit!