diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index e8c425e284f..d92edb2115b 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -800,14 +800,17 @@ bool Preprocessor::handleIdentifier(PPToken *tk) return false; // qDebug() << "expanding" << macro->name() << "on line" << tk->lineno; - if (m_client) + if (m_client && !tk->generated()) m_client->startExpandingMacro(tk->offset, *macro, macroName); QVector body = macro->definitionTokens(); if (macro->isFunctionLike()) { - if (!expandMacros() || !handleFunctionLikeMacro(tk, macro, body, !m_state.m_inDefine)) + if (!expandMacros() || !handleFunctionLikeMacro(tk, macro, body, !m_state.m_inDefine)) { // the call is not function like or expandMacros() returns false, so stop + if (m_client && !tk->generated()) + m_client->stopExpandingMacro(tk->offset, *macro); return false; + } } @@ -829,7 +832,7 @@ bool Preprocessor::handleIdentifier(PPToken *tk) m_state.pushTokenBuffer(body.begin(), body.end(), macro); - if (m_client) + if (m_client && !tk->generated()) m_client->stopExpandingMacro(tk->offset, *macro); return true; @@ -1186,7 +1189,7 @@ void Preprocessor::handleDefineDirective(PPToken *tk) Macro macro; macro.setFileName(m_env->currentFile); - macro.setLine(m_env->currentLine); + macro.setLine(tk->lineno); QByteArray macroName = tk->asByteArrayRef().toByteArray(); macro.setName(macroName); macro.setOffset(tk->offset); diff --git a/src/libs/utils/basetreeview.cpp b/src/libs/utils/basetreeview.cpp new file mode 100644 index 00000000000..b1307bc0083 --- /dev/null +++ b/src/libs/utils/basetreeview.cpp @@ -0,0 +1,137 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#include "basetreeview.h" + +#include +#include +#include + +namespace Utils { + +BaseTreeView::BaseTreeView(QWidget *parent) + : QTreeView(parent) +{ + setAttribute(Qt::WA_MacShowFocusRect, false); + setFrameStyle(QFrame::NoFrame); + setRootIsDecorated(false); + setIconSize(QSize(10, 10)); + setSelectionMode(QAbstractItemView::ExtendedSelection); + setUniformRowHeights(true); + + header()->setDefaultAlignment(Qt::AlignLeft); + header()->setClickable(true); + + connect(this, SIGNAL(activated(QModelIndex)), + SLOT(rowActivatedHelper(QModelIndex))); + connect(header(), SIGNAL(sectionClicked(int)), + SLOT(headerSectionClicked(int))); + + m_adjustColumnsAction = new QAction(tr("Adjust Column Widths to Contents"), 0); + m_alwaysAdjustColumnsAction = 0; +} + +void BaseTreeView::setAlwaysAdjustColumnsAction(QAction *action) +{ + m_alwaysAdjustColumnsAction = action; + connect(action, SIGNAL(toggled(bool)), + SLOT(setAlwaysResizeColumnsToContents(bool))); +} + +void BaseTreeView::addBaseContextActions(QMenu *menu) +{ + menu->addSeparator(); + if (m_alwaysAdjustColumnsAction) + menu->addAction(m_alwaysAdjustColumnsAction); + menu->addAction(m_adjustColumnsAction); + menu->addSeparator(); +} + +bool BaseTreeView::handleBaseContextAction(QAction *act) +{ + if (act == 0) + return true; + if (act == m_adjustColumnsAction) { + resizeColumnsToContents(); + return true; + } + if (act == m_alwaysAdjustColumnsAction) { + if (act->isChecked()) + resizeColumnsToContents(); + // Action triggered automatically. + return true; + } + return false; +} + +void BaseTreeView::setModel(QAbstractItemModel *model) +{ + QTreeView::setModel(model); + if (header() && m_alwaysAdjustColumnsAction) + setAlwaysResizeColumnsToContents(m_alwaysAdjustColumnsAction->isChecked()); +} + +void BaseTreeView::mousePressEvent(QMouseEvent *ev) +{ + QTreeView::mousePressEvent(ev); + if (!indexAt(ev->pos()).isValid()) + resizeColumnsToContents(); +} + +void BaseTreeView::resizeColumnsToContents() +{ + const int columnCount = model()->columnCount(); + for (int c = 0 ; c != columnCount; ++c) + resizeColumnToContents(c); +} + +void BaseTreeView::setAlwaysResizeColumnsToContents(bool on) +{ + QHeaderView::ResizeMode mode = on + ? QHeaderView::ResizeToContents : QHeaderView::Interactive; + header()->setResizeMode(0, mode); +} + +void BaseTreeView::headerSectionClicked(int logicalIndex) +{ + resizeColumnToContents(logicalIndex); +} + +void BaseTreeView::reset() +{ + QTreeView::reset(); + if (header() && m_alwaysAdjustColumnsAction + && m_alwaysAdjustColumnsAction->isChecked()) + resizeColumnsToContents(); +} + +} // namespace Utils diff --git a/src/libs/utils/basetreeview.h b/src/libs/utils/basetreeview.h new file mode 100644 index 00000000000..c78860ebd0f --- /dev/null +++ b/src/libs/utils/basetreeview.h @@ -0,0 +1,76 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#ifndef BASETREEVIEW_H +#define BASETREEVIEW_H + +#include "utils_global.h" + +#include + +namespace Utils { + +class QTCREATOR_UTILS_EXPORT BaseTreeView : public QTreeView +{ + Q_OBJECT + +public: + BaseTreeView(QWidget *parent = 0); + + void setAlwaysAdjustColumnsAction(QAction *action); + virtual void addBaseContextActions(QMenu *menu); + bool handleBaseContextAction(QAction *action); + + void setModel(QAbstractItemModel *model); + virtual void rowActivated(const QModelIndex &) {} + void mousePressEvent(QMouseEvent *ev); + +public slots: + void resizeColumnsToContents(); + void setAlwaysResizeColumnsToContents(bool on); + void reset(); + +protected slots: + void setAlternatingRowColorsHelper(bool on) { setAlternatingRowColors(on); } + +private slots: + void rowActivatedHelper(const QModelIndex &index) { rowActivated(index); } + void headerSectionClicked(int logicalIndex); + +private: + QAction *m_alwaysAdjustColumnsAction; + QAction *m_adjustColumnsAction; +}; + +} // namespace Utils + +#endif // BASETREEVIEW_H diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri index 152c0ad47d9..6327f3fbdcc 100644 --- a/src/libs/utils/utils-lib.pri +++ b/src/libs/utils/utils-lib.pri @@ -97,7 +97,8 @@ SOURCES += $$PWD/environment.cpp \ $$PWD/json.cpp \ $$PWD/portlist.cpp \ $$PWD/tcpportsgatherer.cpp \ - $$PWD/appmainwindow.cpp + $$PWD/appmainwindow.cpp \ + $$PWD/basetreeview.cpp win32 { SOURCES += \ @@ -211,7 +212,8 @@ HEADERS += \ $$PWD/runextensions.h \ $$PWD/portlist.h \ $$PWD/tcpportsgatherer.h \ - $$PWD/appmainwindow.h + $$PWD/appmainwindow.h \ + $$PWD/basetreeview.h FORMS += $$PWD/filewizardpage.ui \ $$PWD/projectintropage.ui \ diff --git a/src/libs/zeroconf/embed/dnssd_clientstub.c b/src/libs/zeroconf/embed/dnssd_clientstub.c index 7c6d9eaf0ba..1f57a520efd 100644 --- a/src/libs/zeroconf/embed/dnssd_clientstub.c +++ b/src/libs/zeroconf/embed/dnssd_clientstub.c @@ -220,8 +220,8 @@ static int read_all(dnssd_sock_t sd, char *buf, int len) while (len) { timeval timeout; - timeout.tv_sec = 0; - timeout.tv_usec = 100000; + timeout.tv_sec = 1; + timeout.tv_usec = 0; fd_set readFds, writeFds, exceptFds; memset(&readFds,0,sizeof(readFds)); memset(&writeFds,0,sizeof(writeFds)); @@ -233,7 +233,7 @@ static int read_all(dnssd_sock_t sd, char *buf, int len) int nVal=select(sd+1, &readFds, &writeFds, &exceptFds, &timeout); if (nVal < 1 || !FD_ISSET(sd, &readFds)) { ++nErr; - if (nErr < 5) // wait max 0.5s without reading + if (nErr < 6) // wait max 6s without reading continue; } else { num_read = recv(sd, buf, len, 0); diff --git a/src/plugins/debugger/basewindow.cpp b/src/plugins/debugger/basewindow.cpp index bf77f3f37d8..92fdcd0d913 100644 --- a/src/plugins/debugger/basewindow.cpp +++ b/src/plugins/debugger/basewindow.cpp @@ -40,9 +40,6 @@ #include #include -#include -#include -#include #include #include @@ -50,107 +47,20 @@ namespace Debugger { namespace Internal { BaseTreeView::BaseTreeView(QWidget *parent) - : QTreeView(parent) + : Utils::BaseTreeView(parent) { QAction *act = debuggerCore()->action(UseAlternatingRowColors); - - setAttribute(Qt::WA_MacShowFocusRect, false); - setFrameStyle(QFrame::NoFrame); setAlternatingRowColors(act->isChecked()); - setRootIsDecorated(false); - setIconSize(QSize(10, 10)); - setSelectionMode(QAbstractItemView::ExtendedSelection); - setUniformRowHeights(true); - - header()->setDefaultAlignment(Qt::AlignLeft); - header()->setClickable(true); - connect(act, SIGNAL(toggled(bool)), - SLOT(setAlternatingRowColorsHelper(bool))); - connect(this, SIGNAL(activated(QModelIndex)), - SLOT(rowActivatedHelper(QModelIndex))); - connect(header(), SIGNAL(sectionClicked(int)), - SLOT(headerSectionClicked(int))); - - m_adjustColumnsAction = new QAction(tr("Adjust Column Widths to Contents"), 0); - m_alwaysAdjustColumnsAction = 0; -} - -void BaseTreeView::setAlwaysAdjustColumnsAction(QAction *action) -{ - m_alwaysAdjustColumnsAction = action; - connect(action, SIGNAL(toggled(bool)), - SLOT(setAlwaysResizeColumnsToContents(bool))); + SLOT(setAlternatingRowColorsHelper(bool))); } void BaseTreeView::addBaseContextActions(QMenu *menu) { - menu->addSeparator(); - if (m_alwaysAdjustColumnsAction) - menu->addAction(m_alwaysAdjustColumnsAction); - menu->addAction(m_adjustColumnsAction); - menu->addSeparator(); + Utils::BaseTreeView::addBaseContextActions(menu); menu->addAction(debuggerCore()->action(SettingsDialog)); } -bool BaseTreeView::handleBaseContextAction(QAction *act) -{ - if (act == 0) - return true; - if (act == m_adjustColumnsAction) { - resizeColumnsToContents(); - return true; - } - if (act == m_alwaysAdjustColumnsAction) { - if (act->isChecked()) - resizeColumnsToContents(); - // Action triggered automatically. - return true; - } - return false; -} - -void BaseTreeView::setModel(QAbstractItemModel *model) -{ - QTreeView::setModel(model); - if (header() && m_alwaysAdjustColumnsAction) - setAlwaysResizeColumnsToContents(m_alwaysAdjustColumnsAction->isChecked()); -} - -void BaseTreeView::mousePressEvent(QMouseEvent *ev) -{ - QTreeView::mousePressEvent(ev); - if (!indexAt(ev->pos()).isValid()) - resizeColumnsToContents(); -} - -void BaseTreeView::resizeColumnsToContents() -{ - const int columnCount = model()->columnCount(); - for (int c = 0 ; c != columnCount; ++c) - resizeColumnToContents(c); -} - -void BaseTreeView::setAlwaysResizeColumnsToContents(bool on) -{ - QHeaderView::ResizeMode mode = on - ? QHeaderView::ResizeToContents : QHeaderView::Interactive; - header()->setResizeMode(0, mode); -} - -void BaseTreeView::headerSectionClicked(int logicalIndex) -{ - resizeColumnToContents(logicalIndex); -} - -void BaseTreeView::reset() -{ - QTreeView::reset(); - if (header() && m_alwaysAdjustColumnsAction - && m_alwaysAdjustColumnsAction->isChecked()) - resizeColumnsToContents(); -} - BaseWindow::BaseWindow(QTreeView *treeView, QWidget *parent) : QWidget(parent), m_treeView(treeView) { diff --git a/src/plugins/debugger/basewindow.h b/src/plugins/debugger/basewindow.h index f4f79f7e329..4a0b95d8b86 100644 --- a/src/plugins/debugger/basewindow.h +++ b/src/plugins/debugger/basewindow.h @@ -33,39 +33,18 @@ #ifndef DEBUGGER_BASEWINDOW_H #define DEBUGGER_BASEWINDOW_H -#include +#include namespace Debugger { namespace Internal { -class BaseTreeView : public QTreeView +class BaseTreeView : public Utils::BaseTreeView { Q_OBJECT public: - BaseTreeView(QWidget *parent = 0); - - void setAlwaysAdjustColumnsAction(QAction *action); + explicit BaseTreeView(QWidget *parent = 0); void addBaseContextActions(QMenu *menu); - bool handleBaseContextAction(QAction *action); - - void setModel(QAbstractItemModel *model); - virtual void rowActivated(const QModelIndex &) {} - void mousePressEvent(QMouseEvent *ev); - -public slots: - void resizeColumnsToContents(); - void setAlwaysResizeColumnsToContents(bool on); - -private slots: - void setAlternatingRowColorsHelper(bool on) { setAlternatingRowColors(on); } - void rowActivatedHelper(const QModelIndex &index) { rowActivated(index); } - void headerSectionClicked(int logicalIndex); - void reset(); - -private: - QAction *m_alwaysAdjustColumnsAction; - QAction *m_adjustColumnsAction; }; class BaseWindow : public QWidget diff --git a/src/plugins/debugger/registerwindow.cpp b/src/plugins/debugger/registerwindow.cpp index 4314cf6fbd6..bf796bb43dd 100644 --- a/src/plugins/debugger/registerwindow.cpp +++ b/src/plugins/debugger/registerwindow.cpp @@ -166,7 +166,6 @@ public: RegisterTreeView::RegisterTreeView(QWidget *parent) : BaseTreeView(parent) { - setAlwaysAdjustColumnsAction(debuggerCore()->action(UseAlternatingRowColors)); setItemDelegate(new RegisterDelegate(this)); } diff --git a/src/plugins/qmljsinspector/qmljspropertyinspector.cpp b/src/plugins/qmljsinspector/qmljspropertyinspector.cpp index 36d2db1bcc8..9f4c325c48c 100644 --- a/src/plugins/qmljsinspector/qmljspropertyinspector.cpp +++ b/src/plugins/qmljsinspector/qmljspropertyinspector.cpp @@ -292,28 +292,13 @@ bool QmlJSPropertyInspectorModel::contentsValid() const } QmlJSPropertyInspector::QmlJSPropertyInspector(QWidget *parent) - : QTreeView(parent) + : Utils::BaseTreeView(parent) { - setAttribute(Qt::WA_MacShowFocusRect, false); - setFrameStyle(QFrame::NoFrame); - setExpandsOnDoubleClick(true); - - header()->setDefaultAlignment(Qt::AlignLeft); - header()->setClickable(true); - setRootIsDecorated(false); - setItemDelegateForColumn(PROPERTY_VALUE_COLUMN, new PropertyEditDelegate(this)); setModel(&m_model); //Add an empty Row to make the headers visible! addRow(QString(), QString(), QString(), -1, false); - connect(header(), SIGNAL(sectionClicked(int)), - SLOT(headerSectionClicked(int))); -} - -void QmlJSPropertyInspector::headerSectionClicked(int logicalIndex) -{ - resizeColumnToContents(logicalIndex); } void QmlJSPropertyInspector::clear() @@ -491,8 +476,6 @@ void QmlJSPropertyInspector::contextMenuEvent(QContextMenuEvent *ev) { QMenu menu; QModelIndex itemIndex = indexAt(ev->pos()); - if (!itemIndex.isValid()) - return; bool isEditable = false; bool isColor = false; if (itemIndex.isValid()) { @@ -507,6 +490,7 @@ void QmlJSPropertyInspector::contextMenuEvent(QContextMenuEvent *ev) QAction colorAction(tr("Choose color"), this); if (isColor) menu.addAction(&colorAction); + addBaseContextActions(&menu); QAction *action = menu.exec(ev->globalPos()); if (action == 0) @@ -516,6 +500,7 @@ void QmlJSPropertyInspector::contextMenuEvent(QContextMenuEvent *ev) openExpressionEditor(itemIndex); if (action == &colorAction) openColorSelector(itemIndex); + handleBaseContextAction(action); } void QmlJSPropertyInspector::openExpressionEditor(const QModelIndex &itemIndex) diff --git a/src/plugins/qmljsinspector/qmljspropertyinspector.h b/src/plugins/qmljsinspector/qmljspropertyinspector.h index 568f28624bb..3080c646527 100644 --- a/src/plugins/qmljsinspector/qmljspropertyinspector.h +++ b/src/plugins/qmljsinspector/qmljspropertyinspector.h @@ -33,7 +33,7 @@ #define PROPERTYINSPECTOR_H #include -#include +#include #include #include @@ -108,7 +108,7 @@ private: bool m_contentsValid; }; -class QmlJSPropertyInspector : public QTreeView +class QmlJSPropertyInspector : public Utils::BaseTreeView { Q_OBJECT public: @@ -138,9 +138,6 @@ public slots: void openExpressionEditor(const QModelIndex &itemIndex); void openColorSelector(const QModelIndex &itemIndex); -private slots: - void headerSectionClicked(int logicalIndex); - private: friend class PropertyEditDelegate; void buildPropertyTree(const QmlDebugObjectReference &); diff --git a/src/plugins/qmljstools/qmljsfindexportedcpptypes.cpp b/src/plugins/qmljstools/qmljsfindexportedcpptypes.cpp index 1f064dc6aca..9f9f66f373f 100644 --- a/src/plugins/qmljstools/qmljsfindexportedcpptypes.cpp +++ b/src/plugins/qmljstools/qmljsfindexportedcpptypes.cpp @@ -143,7 +143,12 @@ protected: if (!templateIdentifier) return false; const QString callName = QString::fromUtf8(templateIdentifier->chars()); - if (callName != QLatin1String("qmlRegisterType")) + int argCount = 0; + if (callName == QLatin1String("qmlRegisterType")) + argCount = 4; + else if (callName == QLatin1String("qmlRegisterUncreatableType")) + argCount = 5; + else return false; // must have a single typeid template argument @@ -154,16 +159,21 @@ protected: if (!typeId) return false; - // must have four arguments + // must have four arguments for qmlRegisterType and five for qmlRegisterUncreatableType if (!ast->expression_list || !ast->expression_list->value || !ast->expression_list->next || !ast->expression_list->next->value || !ast->expression_list->next->next || !ast->expression_list->next->next->value || !ast->expression_list->next->next->next - || !ast->expression_list->next->next->next->value - || ast->expression_list->next->next->next->next) + || !ast->expression_list->next->next->next->value) + return false; + if (argCount == 4 && ast->expression_list->next->next->next->next) + return false; + if (argCount == 5 && (!ast->expression_list->next->next->next->next + || !ast->expression_list->next->next->next->next->value + || ast->expression_list->next->next->next->next->next)) return false; - // last argument must be a string literal + // 4th argument must be a string literal const StringLiteral *nameLit = 0; if (StringLiteralAST *nameAst = skipStringCall(ast->expression_list->next->next->next->value)->asStringLiteral()) nameLit = translationUnit()->stringLiteral(nameAst->literal_token); @@ -748,11 +758,16 @@ bool FindExportedCppTypes::maybeExportsTypes(const Document::Ptr &document) if (!document->control()) return false; const QByteArray qmlRegisterTypeToken("qmlRegisterType"); + const QByteArray qmlRegisterUncreatableTypeToken("qmlRegisterUncreatableType"); const QByteArray setContextPropertyToken("setContextProperty"); if (document->control()->findIdentifier( qmlRegisterTypeToken.constData(), qmlRegisterTypeToken.size())) { return true; } + if (document->control()->findIdentifier( + qmlRegisterUncreatableTypeToken.constData(), qmlRegisterUncreatableTypeToken.size())) { + return true; + } if (document->control()->findIdentifier( setContextPropertyToken.constData(), setContextPropertyToken.size())) { return true; diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 49c6c447082..f4c6854eda7 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -755,16 +755,7 @@ BaseQtVersion::QmakeBuildConfigs BaseQtVersion::defaultBuildConfig() const QString BaseQtVersion::qtVersionString() const { - if (!m_qtVersionString.isNull()) - return m_qtVersionString; - m_qtVersionString.clear(); - if (m_qmakeIsExecutable) { - const QString qmake = qmakeCommand().toString(); - m_qtVersionString = - ProjectExplorer::DebuggingHelperLibrary::qtVersionForQMake(qmake, &m_qmakeIsExecutable); - } else { - qWarning("Cannot determine the Qt version: %s cannot be run.", qPrintable(qmakeCommand().toString())); - } + updateVersionInfo(); return m_qtVersionString; } @@ -844,6 +835,7 @@ void BaseQtVersion::updateVersionInfo() const if (fi.exists()) m_hasDemos = true; } + m_qtVersionString = m_versionInfo.value(QLatin1String("QT_VERSION"), QString()); m_versionInfoUpToDate = true; } diff --git a/src/plugins/remotelinux/linuxdeviceconfiguration.h b/src/plugins/remotelinux/linuxdeviceconfiguration.h index 58c9d11e8d2..c03b29bef11 100644 --- a/src/plugins/remotelinux/linuxdeviceconfiguration.h +++ b/src/plugins/remotelinux/linuxdeviceconfiguration.h @@ -72,16 +72,18 @@ public: void fromMap(const QVariantMap &map); ProjectExplorer::IDevice::Ptr clone() const; -private: + +protected: LinuxDeviceConfiguration(); LinuxDeviceConfiguration(const QString &name, const QString &type, MachineType machineType, Origin origin, const QString &fingerprint); - LinuxDeviceConfiguration(const LinuxDeviceConfiguration &other); - LinuxDeviceConfiguration &operator=(const LinuxDeviceConfiguration &); QVariantMap toMap() const; +private: + LinuxDeviceConfiguration &operator=(const LinuxDeviceConfiguration &); + Internal::LinuxDeviceConfigurationPrivate *d; }; diff --git a/src/plugins/texteditor/texteditor.qbs b/src/plugins/texteditor/texteditor.qbs index c12adef8c5e..752535cfbf5 100644 --- a/src/plugins/texteditor/texteditor.qbs +++ b/src/plugins/texteditor/texteditor.qbs @@ -257,5 +257,9 @@ QtcPlugin { "tooltip/tooltip.cpp", "tooltip/tooltip.h" ] + ProductModule { + Depends { name: "Find" } + Depends { name: "Locator" } + } } diff --git a/src/tools/mdnssd/mDNSPosix.c b/src/tools/mdnssd/mDNSPosix.c index a1868709dbe..682dc3a28c1 100755 --- a/src/tools/mdnssd/mDNSPosix.c +++ b/src/tools/mdnssd/mDNSPosix.c @@ -1441,6 +1441,12 @@ mDNSexport void mDNSPosixGetFDSet(mDNS *m, int *nfds, fd_set *readfds, struct ti if (timeout->tv_sec > interval.tv_sec || (timeout->tv_sec == interval.tv_sec && timeout->tv_usec > interval.tv_usec)) *timeout = interval; + // cope well with vey large changes in time (for example after sleep) + if (timeout->tv_sec > 1000) timeout->tv_sec = 1000; + if (timeout->tv_usec > 999999) timeout->tv_usec = 999999; + // should not happen, but let's be paranoid... + if (timeout->tv_sec < 0) timeout->tv_sec = 0; + if (timeout->tv_usec < 0) timeout->tv_usec = 1000; } mDNSexport void mDNSPosixProcessFDSet(mDNS *const m, fd_set *readfds) diff --git a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp index aa063e034a9..95e41111534 100644 --- a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp +++ b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp @@ -104,16 +104,24 @@ public: virtual ~MockClient() {} - virtual void macroAdded(const Macro &/*macro*/) {} + virtual void macroAdded(const Macro & macro) + { + m_definedMacros.append(macro.name()); + m_definedMacrosLine.append(macro.line()); + } virtual void passedMacroDefinitionCheck(unsigned /*offset*/, const Macro &/*macro*/) {} virtual void failedMacroDefinitionCheck(unsigned /*offset*/, const QByteArray &/*name*/) {} - virtual void startExpandingMacro(unsigned /*offset*/, + virtual void startExpandingMacro(unsigned offset, const Macro &/*macro*/, - const QByteArray &/*originalText*/, + const QByteArray &originalText, const QVector &/*actuals*/ - = QVector()) {} + = QVector()) + { + m_expandedMacros.append(originalText); + m_expandedMacrosOffset.append(offset); + } virtual void stopExpandingMacro(unsigned /*offset*/, const Macro &/*macro*/) {} @@ -206,6 +214,18 @@ public: QList recordedIncludes() const { return m_recordedIncludes; } + QList expandedMacros() const + { return m_expandedMacros; } + + QList expandedMacrosOffset() const + { return m_expandedMacrosOffset; } + + QList definedMacros() const + { return m_definedMacros; } + + QList definedMacrosLine() const + { return m_definedMacrosLine; } + private: Environment *m_env; QByteArray *m_output; @@ -214,8 +234,37 @@ private: unsigned m_includeDepth; QList m_skippedBlocks; QList m_recordedIncludes; + QList m_expandedMacros; + QList m_expandedMacrosOffset; + QList m_definedMacros; + QList m_definedMacrosLine; }; +namespace QTest { + template<> char *toString(const QList &list) + { + QByteArray ba = "QList("; + foreach (const unsigned& item, list) { + ba += QTest::toString(item); + ba += ','; + } + if (!list.isEmpty()) + ba[ba.size() - 1] = ')'; + return qstrdup(ba.data()); + } + template<> char *toString(const QList &list) + { + QByteArray ba = "QList("; + foreach (const QByteArray& item, list) { + ba += QTest::toString(item); + ba += ','; + } + if (!list.isEmpty()) + ba[ba.size() - 1] = ')'; + return qstrdup(ba.data()); + } +} + QDebug &operator<<(QDebug& d, const MockClient::Block &b) { d << '[' << b.start << ',' << b.end << ']'; return d; } class tst_Preprocessor: public QObject @@ -231,15 +280,21 @@ protected: client.sourceNeeded("data/" + fileName, nolines); return output; } + static QString simplified(QByteArray buf); private /* not corrected yet */: void macro_definition_lineno(); + void param_expanding_as_multiple_params(); + void macro_argument_expansion(); private slots: void va_args(); void named_va_args(); void first_empty_macro_arg(); void invalid_param_count(); + void objmacro_expanding_as_fnmacro_notification(); + void macro_uses(); + void macro_arguments_notificatin(); void unfinished_function_like_macro_call(); void nasty_macro_expansion(); void tstst(); @@ -252,6 +307,30 @@ private slots: void comparisons(); }; +// Remove all #... lines, and 'simplify' string, to allow easily comparing the result +// Also, remove all unneeded spaces: keep only to ensure identifiers are separated. +// NOTE: may not correctly handle underscore in identifiers +QString tst_Preprocessor::simplified(QByteArray buf) +{ + QString out; + QList lines = buf.split('\n'); + foreach (QByteArray line, lines) + if (!line.startsWith('#')) { + out.append(' '); + out.append(line); + } + + out = out.simplified(); + for (int i=1; i"), + QByteArray("\n#define foo(a,b) int f(a,b);" + "\n#define ARGS(t) t a,t b" + "\nfoo(ARGS(int))")); + QCOMPARE(simplified(preprocessed), QString("int f(int a,int b);")); +} + +void tst_Preprocessor::macro_argument_expansion() //QTCREATORBUG-7225 +{ + Client *client = 0; // no client. + Environment env; + + Preprocessor preprocess(client, &env); + QByteArray preprocessed = preprocess(QLatin1String(""), + QByteArray("\n#define BAR1 2,3,4" + "\n#define FOO1(a,b,c) a+b+c" + "\nvoid test2(){" + "\nint x=FOO1(BAR1);" + "\n}")); + QCOMPARE(simplified(preprocessed), QString("void test2(){int x=2+3+4;}")); + +} + +void tst_Preprocessor::macro_uses() +{ + QByteArray buffer = QByteArray("\n#define FOO 8" + "\n#define BAR 9" + "\nvoid test(){" + "\n\tint x=FOO;" + "\n\tint y=BAR;" + "\n}"); + + QByteArray output; + Environment env; + MockClient client(&env, &output); + + Preprocessor preprocess(&client, &env); + QByteArray preprocessed = preprocess(QLatin1String(""), buffer); + QCOMPARE(simplified(preprocessed), QString("void test(){int x=8;int y=9;}")); + QCOMPARE(client.expandedMacros(), QList() << QByteArray("FOO") << QByteArray("BAR")); + QCOMPARE(client.expandedMacrosOffset(), QList() << buffer.indexOf("FOO;") << buffer.indexOf("BAR;")); + QCOMPARE(client.definedMacros(), QList() << QByteArray("FOO") << QByteArray("BAR")); + QCOMPARE(client.definedMacrosLine(), QList() << 2 << 3); +} + void tst_Preprocessor::macro_definition_lineno() { Client *client = 0; // no client. @@ -336,30 +460,63 @@ void tst_Preprocessor::macro_definition_lineno() QByteArray preprocessed = preprocess(QLatin1String(""), QByteArray("#define foo(ARGS) int f(ARGS)\n" "foo(int a);\n")); - QVERIFY(preprocessed.contains("#gen true\n# 2 ")); + QVERIFY(preprocessed.contains("#gen true\n# 2 \"\"\nint f")); preprocessed = preprocess(QLatin1String(""), QByteArray("#define foo(ARGS) int f(ARGS)\n" "foo(int a)\n" ";\n")); - QVERIFY(preprocessed.contains("#gen true\n# 2 ")); + QVERIFY(preprocessed.contains("#gen true\n# 2 \"\"\nint f")); preprocessed = preprocess(QLatin1String(""), QByteArray("#define foo(ARGS) int f(ARGS)\n" "foo(int \n" " a);\n")); - QVERIFY(preprocessed.contains("#gen true\n# 2 ")); + QVERIFY(preprocessed.contains("#gen true\n# 2 \"\"\nint f")); preprocessed = preprocess(QLatin1String(""), QByteArray("#define foo int f\n" "foo;\n")); - QVERIFY(preprocessed.contains("#gen true\n# 2 ")); + QVERIFY(preprocessed.contains("#gen true\n# 2 \"\"\nint f")); preprocessed = preprocess(QLatin1String(""), QByteArray("#define foo int f\n" "foo\n" ";\n")); - QVERIFY(preprocessed.contains("#gen true\n# 2 ")); + QVERIFY(preprocessed.contains("#gen true\n# 2 \"\"\nint f")); +} + +void tst_Preprocessor::objmacro_expanding_as_fnmacro_notification() +{ + QByteArray output; + Environment env; + MockClient client(&env, &output); + + Preprocessor preprocess(&client, &env); + QByteArray preprocessed = preprocess(QLatin1String(""), + QByteArray("\n#define bar(a,b) a + b" + "\n#define foo bar" + "\nfoo(1, 2)\n")); + + QVERIFY(client.expandedMacros() == (QList() << QByteArray("foo"))); +} + +void tst_Preprocessor::macro_arguments_notificatin() +{ + QByteArray output; + Environment env; + MockClient client(&env, &output); + + Preprocessor preprocess(&client, &env); + QByteArray preprocessed = preprocess(QLatin1String(""), + QByteArray("\n#define foo(a,b) a + b" + "\n#define arg(a) a" + "\n#define value 2" + "\nfoo(arg(1), value)\n")); + + QVERIFY(client.expandedMacros() == (QList() << QByteArray("foo") + << QByteArray("arg") + << QByteArray("value"))); } void tst_Preprocessor::unfinished_function_like_macro_call()