forked from qt-creator/qt-creator
Merge branch 'master' of ssh://codereview.qt-project.org/qt-creator/qt-creator
This commit is contained in:
@@ -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<PPToken> 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);
|
||||
|
137
src/libs/utils/basetreeview.cpp
Normal file
137
src/libs/utils/basetreeview.cpp
Normal file
@@ -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 <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
|
||||
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
|
76
src/libs/utils/basetreeview.h
Normal file
76
src/libs/utils/basetreeview.h
Normal file
@@ -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 <QTreeView>
|
||||
|
||||
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
|
@@ -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 \
|
||||
|
@@ -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);
|
||||
|
@@ -40,9 +40,6 @@
|
||||
#include <find/treeviewfind.h>
|
||||
#include <utils/savedaction.h>
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QDebug>
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@@ -33,39 +33,18 @@
|
||||
#ifndef DEBUGGER_BASEWINDOW_H
|
||||
#define DEBUGGER_BASEWINDOW_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include <utils/basetreeview.h>
|
||||
|
||||
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
|
||||
|
@@ -166,7 +166,6 @@ public:
|
||||
RegisterTreeView::RegisterTreeView(QWidget *parent)
|
||||
: BaseTreeView(parent)
|
||||
{
|
||||
setAlwaysAdjustColumnsAction(debuggerCore()->action(UseAlternatingRowColors));
|
||||
setItemDelegate(new RegisterDelegate(this));
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#define PROPERTYINSPECTOR_H
|
||||
|
||||
#include <qmljsprivateapi.h>
|
||||
#include <QTreeView>
|
||||
#include <utils/basetreeview.h>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <QDialog>
|
||||
@@ -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 &);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
};
|
||||
|
||||
|
@@ -257,5 +257,9 @@ QtcPlugin {
|
||||
"tooltip/tooltip.cpp",
|
||||
"tooltip/tooltip.h"
|
||||
]
|
||||
ProductModule {
|
||||
Depends { name: "Find" }
|
||||
Depends { name: "Locator" }
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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<MacroArgumentReference> &/*actuals*/
|
||||
= QVector<MacroArgumentReference>()) {}
|
||||
= QVector<MacroArgumentReference>())
|
||||
{
|
||||
m_expandedMacros.append(originalText);
|
||||
m_expandedMacrosOffset.append(offset);
|
||||
}
|
||||
|
||||
virtual void stopExpandingMacro(unsigned /*offset*/,
|
||||
const Macro &/*macro*/) {}
|
||||
@@ -206,6 +214,18 @@ public:
|
||||
QList<Include> recordedIncludes() const
|
||||
{ return m_recordedIncludes; }
|
||||
|
||||
QList<QByteArray> expandedMacros() const
|
||||
{ return m_expandedMacros; }
|
||||
|
||||
QList<unsigned> expandedMacrosOffset() const
|
||||
{ return m_expandedMacrosOffset; }
|
||||
|
||||
QList<QByteArray> definedMacros() const
|
||||
{ return m_definedMacros; }
|
||||
|
||||
QList<unsigned> definedMacrosLine() const
|
||||
{ return m_definedMacrosLine; }
|
||||
|
||||
private:
|
||||
Environment *m_env;
|
||||
QByteArray *m_output;
|
||||
@@ -214,8 +234,37 @@ private:
|
||||
unsigned m_includeDepth;
|
||||
QList<Block> m_skippedBlocks;
|
||||
QList<Include> m_recordedIncludes;
|
||||
QList<QByteArray> m_expandedMacros;
|
||||
QList<unsigned> m_expandedMacrosOffset;
|
||||
QList<QByteArray> m_definedMacros;
|
||||
QList<unsigned> m_definedMacrosLine;
|
||||
};
|
||||
|
||||
namespace QTest {
|
||||
template<> char *toString(const QList<unsigned> &list)
|
||||
{
|
||||
QByteArray ba = "QList<unsigned>(";
|
||||
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<QByteArray> &list)
|
||||
{
|
||||
QByteArray ba = "QList<QByteArray>(";
|
||||
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<QByteArray> lines = buf.split('\n');
|
||||
foreach (QByteArray line, lines)
|
||||
if (!line.startsWith('#')) {
|
||||
out.append(' ');
|
||||
out.append(line);
|
||||
}
|
||||
|
||||
out = out.simplified();
|
||||
for (int i=1; i<out.length()-1; ) {
|
||||
if (out.at(i).isSpace() && !(out.at(i-1).isLetterOrNumber() && out.at(i+1).isLetterOrNumber()))
|
||||
out.remove(i,1);
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void tst_Preprocessor::va_args()
|
||||
{
|
||||
Client *client = 0; // no client.
|
||||
@@ -268,9 +347,7 @@ void tst_Preprocessor::va_args()
|
||||
|
||||
preprocessed = preprocessed.simplified();
|
||||
// DUMP_OUTPUT(preprocessed);
|
||||
QVERIFY(preprocessed.contains("int f();"));
|
||||
QVERIFY(preprocessed.contains("int f( int a );"));
|
||||
QVERIFY(preprocessed.contains("int f( int a, int b );"));
|
||||
QCOMPARE(simplified(preprocessed), QString("int f();int f(int a);int f(int a,int b);"));
|
||||
}
|
||||
|
||||
void tst_Preprocessor::named_va_args()
|
||||
@@ -287,9 +364,7 @@ void tst_Preprocessor::named_va_args()
|
||||
true, false);
|
||||
|
||||
preprocessed = preprocessed.simplified();
|
||||
QVERIFY(preprocessed.contains("int f();"));
|
||||
QVERIFY(preprocessed.contains("int f( int a );"));
|
||||
QVERIFY(preprocessed.contains("int f( int a, int b );"));
|
||||
QCOMPARE(simplified(preprocessed), QString("int f();int f(int a);int f(int a,int b);"));
|
||||
}
|
||||
|
||||
void tst_Preprocessor::first_empty_macro_arg()
|
||||
@@ -307,9 +382,7 @@ void tst_Preprocessor::first_empty_macro_arg()
|
||||
|
||||
preprocessed = preprocessed.simplified();
|
||||
// DUMP_OUTPUT(preprocessed);
|
||||
QVERIFY(preprocessed.contains("const int cVal ;"));
|
||||
QVERIFY(preprocessed.contains("int Val ;"));
|
||||
QVERIFY(preprocessed.contains("int Val2 ;"));
|
||||
QCOMPARE(simplified(preprocessed), QString("const int cVal;int Val;int Val2;"));
|
||||
}
|
||||
|
||||
void tst_Preprocessor::invalid_param_count()
|
||||
@@ -328,6 +401,57 @@ void tst_Preprocessor::invalid_param_count()
|
||||
// do not verify the output: it's illegal, so anything might be outputted.
|
||||
}
|
||||
|
||||
void tst_Preprocessor::param_expanding_as_multiple_params()
|
||||
{
|
||||
Client *client = 0; // no client.
|
||||
Environment env;
|
||||
|
||||
Preprocessor preprocess(client, &env);
|
||||
QByteArray preprocessed = preprocess(QLatin1String("<stdin>"),
|
||||
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("<stdin>"),
|
||||
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("<stdin>"), buffer);
|
||||
QCOMPARE(simplified(preprocessed), QString("void test(){int x=8;int y=9;}"));
|
||||
QCOMPARE(client.expandedMacros(), QList<QByteArray>() << QByteArray("FOO") << QByteArray("BAR"));
|
||||
QCOMPARE(client.expandedMacrosOffset(), QList<unsigned>() << buffer.indexOf("FOO;") << buffer.indexOf("BAR;"));
|
||||
QCOMPARE(client.definedMacros(), QList<QByteArray>() << QByteArray("FOO") << QByteArray("BAR"));
|
||||
QCOMPARE(client.definedMacrosLine(), QList<unsigned>() << 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("<stdin>"),
|
||||
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 \"<stdin>\"\nint f"));
|
||||
|
||||
preprocessed = preprocess(QLatin1String("<stdin>"),
|
||||
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 \"<stdin>\"\nint f"));
|
||||
|
||||
preprocessed = preprocess(QLatin1String("<stdin>"),
|
||||
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 \"<stdin>\"\nint f"));
|
||||
|
||||
preprocessed = preprocess(QLatin1String("<stdin>"),
|
||||
QByteArray("#define foo int f\n"
|
||||
"foo;\n"));
|
||||
QVERIFY(preprocessed.contains("#gen true\n# 2 "));
|
||||
QVERIFY(preprocessed.contains("#gen true\n# 2 \"<stdin>\"\nint f"));
|
||||
|
||||
preprocessed = preprocess(QLatin1String("<stdin>"),
|
||||
QByteArray("#define foo int f\n"
|
||||
"foo\n"
|
||||
";\n"));
|
||||
QVERIFY(preprocessed.contains("#gen true\n# 2 "));
|
||||
QVERIFY(preprocessed.contains("#gen true\n# 2 \"<stdin>\"\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("<stdin>"),
|
||||
QByteArray("\n#define bar(a,b) a + b"
|
||||
"\n#define foo bar"
|
||||
"\nfoo(1, 2)\n"));
|
||||
|
||||
QVERIFY(client.expandedMacros() == (QList<QByteArray>() << QByteArray("foo")));
|
||||
}
|
||||
|
||||
void tst_Preprocessor::macro_arguments_notificatin()
|
||||
{
|
||||
QByteArray output;
|
||||
Environment env;
|
||||
MockClient client(&env, &output);
|
||||
|
||||
Preprocessor preprocess(&client, &env);
|
||||
QByteArray preprocessed = preprocess(QLatin1String("<stdin>"),
|
||||
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>() << QByteArray("foo")
|
||||
<< QByteArray("arg")
|
||||
<< QByteArray("value")));
|
||||
}
|
||||
|
||||
void tst_Preprocessor::unfinished_function_like_macro_call()
|
||||
|
Reference in New Issue
Block a user