Commit c8bb7e17 authored by con's avatar con
Browse files

Merge commit 'origin/1.3'

Conflicts:
	src/plugins/qt4projectmanager/qt4project.cpp
parents fa348475 2a7439cd
......@@ -27,9 +27,8 @@ qch_docs.depends += html_docs
qch_docs.files = $$QCH_FILE
unix:!macx {
system("mkdir -p `dirname $$QCH_FILE` && touch $$QCH_FILE")
qch_docs.path = /share/doc/qtcreator
qch_docs.CONFIG += no_check_exist
INSTALLS += qch_docs
}
......
......@@ -1639,7 +1639,7 @@ static void qDumpQList(QDumper &d)
}
qCheckAccess(pdata);
d.putItemCount("value", n);
d.putItemCount("value", nn);
d.putItem("valueeditable", "false");
d.putItem("numchild", n);
if (d.dumpChildren) {
......
......@@ -152,6 +152,25 @@ ClassBinding *NamespaceBinding::findClassBinding(Name *name, QSet<Binding *> *pr
if (processed->contains(this))
return 0;
if (const QualifiedNameId *q = name->asQualifiedNameId()) {
Binding *current = this;
for (unsigned i = 0; i < q->nameCount(); ++i) {
Identifier *nameId = q->nameAt(i)->identifier();
if (! nameId)
return 0;
QSet<Binding *> visited;
Binding *binding = current->findClassOrNamespaceBinding(nameId, &visited); // ### TODO: check recursion.
if (! binding)
return 0;
current = binding;
}
return current->asClassBinding();
}
processed->insert(this);
Identifier *id = name->identifier();
......
......@@ -59,6 +59,7 @@ void FindUsages::setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBi
QList<int> FindUsages::operator()(Symbol *symbol, Identifier *id, AST *ast)
{
_processed.clear();
_references.clear();
_declSymbol = symbol;
_id = id;
......@@ -92,6 +93,9 @@ QString FindUsages::matchingLine(const Token &tk) const
void FindUsages::reportResult(unsigned tokenIndex, const QList<Symbol *> &candidates)
{
if (_processed.contains(tokenIndex))
return;
const bool isStrongResult = checkCandidates(candidates);
if (isStrongResult)
......@@ -100,6 +104,11 @@ void FindUsages::reportResult(unsigned tokenIndex, const QList<Symbol *> &candid
void FindUsages::reportResult(unsigned tokenIndex)
{
if (_processed.contains(tokenIndex))
return;
_processed.insert(tokenIndex);
const Token &tk = tokenAt(tokenIndex);
const QString lineText = matchingLine(tk);
......
......@@ -114,6 +114,7 @@ private:
QList<int> _references;
LookupContext _previousContext;
int _inSimpleDeclaration;
QSet<unsigned> _processed;
};
} // end of namespace CPlusPlus
......
......@@ -57,17 +57,22 @@ void ProgressManagerPrivate::init()
void ProgressManagerPrivate::cancelTasks(const QString &type)
{
bool found = false;
QMap<QFutureWatcher<void> *, QString>::iterator task = m_runningTasks.begin();
while (task != m_runningTasks.end()) {
if (task.value() != type) {
++task;
continue;
}
found = true;
disconnect(task.key(), SIGNAL(finished()), this, SLOT(taskFinished()));
task.key()->cancel();
delete task.key();
task = m_runningTasks.erase(task);
}
if (found) {
emit allTasksFinished(type);
}
}
void ProgressManagerPrivate::cancelAllRunningTasks()
......@@ -88,6 +93,7 @@ FutureProgress *ProgressManagerPrivate::addTask(const QFuture<void> &future, con
m_runningTasks.insert(watcher, type);
connect(watcher, SIGNAL(finished()), this, SLOT(taskFinished()));
watcher->setFuture(future);
emit taskStarted(type);
return m_progressView->addTask(future, title, type, persistency);
}
......@@ -101,6 +107,11 @@ void ProgressManagerPrivate::taskFinished()
QObject *taskObject = sender();
QTC_ASSERT(taskObject, return);
QFutureWatcher<void> *task = static_cast<QFutureWatcher<void> *>(taskObject);
QString type = m_runningTasks.value(task);
m_runningTasks.remove(task);
delete task;
if (!m_runningTasks.values().contains(type)) {
emit allTasksFinished(type);
}
}
......@@ -51,6 +51,10 @@ public:
public slots:
virtual void cancelTasks(const QString &type) = 0;
signals:
void taskStarted(const QString &type);
void allTasksFinished(const QString &type);
};
} // namespace Core
......
......@@ -68,6 +68,7 @@ CodepasterPlugin::CodepasterPlugin()
CodepasterPlugin::~CodepasterPlugin()
{
qDeleteAll(m_protocols);
}
bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_message)
......
......@@ -43,6 +43,7 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <texteditor/completionsupport.h>
#include <texteditor/fontsettings.h>
#include <texteditor/storagesettings.h>
......@@ -55,7 +56,6 @@
#include <QtCore/QFileInfo>
#include <QtCore/QSettings>
#include <QtGui/QMenu>
#include <QtGui/QAction>
using namespace CppEditor::Internal;
......@@ -211,18 +211,18 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
QAction *findUsagesAction = new QAction(tr("Find Usages"), this);
cmd = am->registerAction(findUsagesAction, Constants::FIND_USAGES, context);
m_findUsagesAction = new QAction(tr("Find Usages"), this);
cmd = am->registerAction(m_findUsagesAction, Constants::FIND_USAGES, context);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
connect(findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages()));
connect(m_findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages()));
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
QAction *renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol under Cursor"), this);
cmd = am->registerAction(renameSymbolUnderCursorAction,
m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol under Cursor"), this);
cmd = am->registerAction(m_renameSymbolUnderCursorAction,
Constants::RENAME_SYMBOL_UNDER_CURSOR, context);
cmd->setDefaultKeySequence(QKeySequence("CTRL+SHIFT+R"));
connect(renameSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(renameSymbolUnderCursor()));
connect(m_renameSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(renameSymbolUnderCursor()));
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
......@@ -244,7 +244,10 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
contextMenu->addAction(cmd);
connect(core->progressManager(), SIGNAL(taskStarted(QString)),
this, SLOT(onTaskStarted(QString)));
connect(core->progressManager(), SIGNAL(allTasksFinished(QString)),
this, SLOT(onAllTasksFinished(QString)));
readSettings();
return true;
}
......@@ -300,4 +303,20 @@ void CppPlugin::findUsages()
editor->findUsages();
}
void CppPlugin::onTaskStarted(const QString &type)
{
if (type == CppTools::Constants::TASK_INDEX) {
m_renameSymbolUnderCursorAction->setEnabled(false);
m_findUsagesAction->setEnabled(false);
}
}
void CppPlugin::onAllTasksFinished(const QString &type)
{
if (type == CppTools::Constants::TASK_INDEX) {
m_renameSymbolUnderCursorAction->setEnabled(true);
m_findUsagesAction->setEnabled(true);
}
}
Q_EXPORT_PLUGIN(CppPlugin)
......@@ -30,12 +30,13 @@
#ifndef CPPPLUGIN_H
#define CPPPLUGIN_H
#include <QtCore/QtPlugin>
#include <QtCore/QStringList>
#include <extensionsystem/iplugin.h>
#include <coreplugin/editormanager/ieditorfactory.h>
#include <QtCore/QtPlugin>
#include <QtCore/QStringList>
#include <QtGui/QAction>
namespace TextEditor {
class TextEditorActionHandler;
} // namespace TextEditor
......@@ -74,6 +75,8 @@ private slots:
void switchDeclarationDefinition();
void jumpToDefinition();
void renameSymbolUnderCursor();
void onTaskStarted(const QString &type);
void onAllTasksFinished(const QString &type);
void findUsages();
private:
......@@ -85,6 +88,8 @@ private:
TextEditor::TextEditorActionHandler *m_actionHandler;
bool m_sortedMethodOverview;
QAction *m_renameSymbolUnderCursorAction;
QAction *m_findUsagesAction;
};
class CppEditorFactory : public Core::IEditorFactory
......
......@@ -1124,14 +1124,6 @@ bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &ba
m_completionOperator,
&replacedDotOperator);
if (replacedDotOperator) {
// Replace . with ->
int length = m_editor->position() - m_startPosition + 1;
m_editor->setCurPos(m_startPosition - 1);
m_editor->replace(length, QLatin1String("->"));
++m_startPosition;
}
QList<Symbol *> classObjectCandidates;
foreach (const TypeOfExpression::Result &r, classObjectResults) {
FullySpecifiedType ty = r.first.simplified();
......@@ -1150,6 +1142,14 @@ bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &ba
}
}
if (replacedDotOperator && ! classObjectCandidates.isEmpty()) {
// Replace . with ->
int length = m_editor->position() - m_startPosition + 1;
m_editor->setCurPos(m_startPosition - 1);
m_editor->replace(length, QLatin1String("->"));
++m_startPosition;
}
completeClass(classObjectCandidates, context, /*static lookup = */ false);
if (! m_completions.isEmpty())
return true;
......
......@@ -62,7 +62,8 @@ using namespace CppTools::Internal;
using namespace CPlusPlus;
CppFindReferences::CppFindReferences(CppTools::CppModelManagerInterface *modelManager)
: _modelManager(modelManager),
: QObject(modelManager),
_modelManager(modelManager),
_resultWindow(ExtensionSystem::PluginManager::instance()->getObject<Find::SearchResultWindow>())
{
m_watcher.setPendingResultsLimit(1);
......@@ -249,7 +250,21 @@ static void applyChanges(QTextDocument *doc, const QString &text, const QList<Fi
foreach (const Find::SearchResultItem &item, items) {
const int blockNumber = item.lineNumber - 1;
QTextCursor tc(doc->findBlockByNumber(blockNumber));
tc.setPosition(tc.position() + item.searchTermStart);
const int cursorPosition = tc.position() + item.searchTermStart;
int cursorIndex = 0;
for (; cursorIndex < cursors.size(); ++cursorIndex) {
const QTextCursor &tc = cursors.at(cursorIndex);
if (tc.position() == cursorPosition)
break;
}
if (cursorIndex != cursors.size())
continue; // skip this change.
tc.setPosition(cursorPosition);
tc.setPosition(tc.position() + item.searchTermLength,
QTextCursor::KeepAnchor);
cursors.append(tc);
......@@ -335,6 +350,7 @@ void CppFindReferences::displayResult(int index)
void CppFindReferences::searchFinished()
{
_resultWindow->finishSearch();
emit changed();
}
......
......@@ -195,8 +195,12 @@ DisassemblerViewAgent::~DisassemblerViewAgent()
if (d->editor)
d->editor->deleteLater();
d->editor = 0;
delete d->locationMark;
d->locationMark = 0;
delete d;
d = 0;
delete d->locationMark;
d->locationMark = 0;
}
void DisassemblerViewAgent::cleanup()
......
......@@ -193,6 +193,11 @@ GdbEngine::GdbEngine(DebuggerManager *manager) :
m_trkOptions->fromSettings(Core::ICore::instance()->settings());
m_gdbAdapter = 0;
m_commandTimer = new QTimer(this);
m_commandTimer->setSingleShot(true);
m_commandTimer->setInterval(COMMAND_TIMEOUT);
connect(m_commandTimer, SIGNAL(timeout()), SLOT(commandTimeout()));
// Needs no resetting in initializeVariables()
m_busy = false;
......@@ -606,6 +611,9 @@ void GdbEngine::readGdbStandardError()
void GdbEngine::readGdbStandardOutput()
{
if (m_commandTimer->isActive())
m_commandTimer->start(); // Retrigger
int newstart = 0;
int scan = m_inbuffer.size();
......@@ -734,7 +742,7 @@ void GdbEngine::postCommandHelper(const GdbCommand &cmd)
}
if ((cmd.flags & NeedsStop) || !m_commandsToRunOnTemporaryBreak.isEmpty()) {
if (state() == InferiorStopped
if (state() == InferiorStopped || state() == InferiorUnrunnable
|| state() == InferiorStarting || state() == AdapterStarted) {
// Can be safely sent now.
flushCommand(cmd);
......@@ -796,10 +804,27 @@ void GdbEngine::flushCommand(const GdbCommand &cmd0)
m_gdbAdapter->write(cmd.command.toLatin1() + "\r\n");
m_commandTimer->start();
if (cmd.flags & LosesChild)
setState(InferiorShuttingDown);
}
void GdbEngine::commandTimeout()
{
// FIXME this needs a proper message box
debugMessage(_("TIMED OUT WAITING FOR GDB REPLY. COMMANDS STILL IN PROGRESS:"));
QList<int> keys = m_cookieForToken.keys();
qSort(keys);
foreach (int key, keys) {
const GdbCommand &cmd = m_cookieForToken[key];
debugMessage(_(" %1: %2 => %3").arg(key).arg(cmd.command).arg(_(cmd.callbackName)));
}
// This is an entirely undefined state, so we just pull the emergency brake.
setState(EngineShuttingDown, true);
m_gdbProc.kill();
}
void GdbEngine::handleResultRecord(GdbResponse *response)
{
//qDebug() << "TOKEN:" << response.token
......@@ -927,6 +952,9 @@ void GdbEngine::handleResultRecord(GdbResponse *response)
} else {
PENDING_DEBUG("MISSING TOKENS: " << m_cookieForToken.keys());
}
if (m_cookieForToken.isEmpty())
m_commandTimer->stop();
}
void GdbEngine::executeDebuggerCommand(const QString &command)
......@@ -1426,7 +1454,6 @@ void GdbEngine::shutdown()
m_gdbAdapter->shutdown();
// fall-through
case AdapterStartFailed: // Adapter "did something", but it did not help
// FIXME set some timeout?
if (m_gdbProc.state() == QProcess::Running) {
postCommand(_("-gdb-exit"), GdbEngine::ExitRequest, CB(handleGdbExit));
} else {
......@@ -1437,7 +1464,6 @@ void GdbEngine::shutdown()
case InferiorRunning:
case InferiorStopping:
case InferiorStopped:
// FIXME set some timeout?
postCommand(_(m_gdbAdapter->inferiorShutdownCommand()),
NeedsStop | LosesChild, CB(handleInferiorShutdown));
break;
......@@ -1446,7 +1472,6 @@ void GdbEngine::shutdown()
case InferiorShutDown:
case InferiorShutdownFailed: // Whatever
case InferiorUnrunnable:
// FIXME set some timeout?
postCommand(_("-gdb-exit"), GdbEngine::ExitRequest, CB(handleGdbExit));
setState(EngineShuttingDown); // Do it after posting the command!
break;
......@@ -3246,23 +3271,13 @@ void GdbEngine::handleVarCreate(const GdbResponse &response)
if (response.resultClass == GdbResultDone) {
data.variable = data.iname;
setWatchDataType(data, response.data.findChild("type"));
if (hasDebuggingHelperForType(data.type)) {
// we do not trust gdb if we have a custom dumper
if (response.data.findChild("children").isValid())
data.setChildrenUnneeded();
else if (manager()->watchHandler()->isExpandedIName(data.iname))
data.setChildrenNeeded();
insertData(data);
} else {
if (response.data.findChild("children").isValid())
data.setChildrenUnneeded();
else if (manager()->watchHandler()->isExpandedIName(data.iname))
data.setChildrenNeeded();
setWatchDataChildCount(data, response.data.findChild("numchild"));
//if (data.isValueNeeded() && data.childCount > 0)
// data.setValue(QString());
insertData(data);
}
if (manager()->watchHandler()->isExpandedIName(data.iname)
&& !response.data.findChild("children").isValid())
data.setChildrenNeeded();
else
data.setChildrenUnneeded();
setWatchDataChildCount(data, response.data.findChild("numchild"));
insertData(data);
} else {
data.setError(QString::fromLocal8Bit(response.data.findChild("msg").data()));
if (data.isWatcher()) {
......@@ -3707,7 +3722,8 @@ void GdbEngine::insertData(const WatchData &data0)
void GdbEngine::handleVarListChildrenHelper(const GdbMi &item,
const WatchData &parent)
{
//qDebug() << "VAR_LIST_CHILDREN: APPENDEE" << data.toString();
//qDebug() << "VAR_LIST_CHILDREN: PARENT" << parent.toString();
//qDebug() << "VAR_LIST_CHILDREN: ITEM" << item.toString();
QByteArray exp = item.findChild("exp").data();
QByteArray name = item.findChild("name").data();
if (isAccessSpecifier(_(exp))) {
......@@ -4243,6 +4259,9 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb, const QStr
m_gdbProc.disconnect(); // From any previous runs
QString location = gdb;
const QByteArray env = qgetenv("QTC_DEBUGGER_PATH");
if (!env.isEmpty())
location = QString::fromLatin1(env);
if (location.isEmpty())
location = theDebuggerStringSetting(GdbLocation);
QStringList gdbArgs;
......
......@@ -49,6 +49,7 @@
QT_BEGIN_NAMESPACE
class QAction;
class QAbstractItemModel;
class QTimer;
class QWidget;
class QMainWindow;
QT_END_NAMESPACE
......@@ -228,9 +229,12 @@ private: ////////// Gdb Command Management //////////
const QVariant &cookie = QVariant());
void postCommandHelper(const GdbCommand &cmd);
void flushQueuedCommands();
Q_SLOT void commandTimeout();
void setTokenBarrier();
QHash<int, GdbCommand> m_cookieForToken;
QTimer *m_commandTimer;
enum { COMMAND_TIMEOUT = 20000 };
QByteArray m_pendingConsoleStreamOutput;
QByteArray m_pendingLogStreamOutput;
......
......@@ -73,6 +73,12 @@ StackWindow::StackWindow(DebuggerManager *manager, QWidget *parent)
this, SLOT(showAddressColumn(bool)));
}
StackWindow::~StackWindow()
{
// FIXME: leak
//delete m_disassemblerAgent;
}
void StackWindow::showAddressColumn(bool on)
{
setColumnHidden(4, !on);
......
......@@ -50,6 +50,7 @@ class StackWindow : public QTreeView
public:
StackWindow(DebuggerManager *manager, QWidget *parent = 0);
~StackWindow();
signals:
void frameActivated(int);
......
......@@ -41,6 +41,7 @@
#include <QtCore/QDebug>
#include <QtCore/QEvent>
#include <QtCore/QtAlgorithms>
#include <QtCore/QTextStream>
#include <QtCore/QTimer>
......@@ -361,6 +362,11 @@ WatchModel::WatchModel(WatchHandler *handler, WatchType type)
}
}
WatchModel::~WatchModel()
{
delete m_root;
}
WatchItem *WatchModel::rootItem() const
{
return m_root;
......@@ -420,7 +426,7 @@ void WatchModel::removeOutdated()
void WatchModel::removeOutdatedHelper(WatchItem *item)
{
if (item->generation < generationCounter) {
removeItem(item);
destroyItem(item);
} else {
foreach (WatchItem *child, item->children)
removeOutdatedHelper(child);
......@@ -428,7 +434,7 @@ void WatchModel::removeOutdatedHelper(WatchItem *item)
}
}
void WatchModel::removeItem(WatchItem *item)
void WatchModel::destroyItem(WatchItem *item)
{
WatchItem *parent = item->parent;
QModelIndex index = watchIndex(parent);
......@@ -437,6 +443,7 @@ void WatchModel::removeItem(WatchItem *item)
beginRemoveRows(index, n, n);
parent->children.removeAt(n);
endRemoveRows();
delete item;
}
static QString parentName(const QString &iname)
......@@ -1187,7 +1194,7 @@ void WatchHandler::removeData(const QString &iname)
return;
WatchItem *item = model->findItem(iname, model->m_root);
if (item)
model->removeItem(item);
model->destroyItem(item);
}
void WatchHandler::watchExpression()
......@@ -1302,7 +1309,7 @@ void WatchHandler::removeWatchExpression(const QString &exp)
m_watcherNames.remove(exp);
foreach (WatchItem *item, m_watchers->rootItem()->children) {
if (item->exp == exp) {
m_watchers->removeItem(item);
m_watchers->destroyItem(item);
saveWatchers();
break;
}
......
......@@ -180,6 +180,7 @@ class WatchModel : public QAbstractItemModel
private:
explicit WatchModel(WatchHandler *handler, WatchType type);
virtual ~WatchModel();
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
......@@ -209,7 +210,7 @@ private:
void removeOutdated();
void removeOutdatedHelper(WatchItem *item);
WatchItem *rootItem() const;
void removeItem(WatchItem *item);
void destroyItem(WatchItem *item);
void emitDataChanged(int column,
const QModelIndex &parentIndex = QModelIndex());
......
......@@ -53,7 +53,8 @@ static const QString SETTINGSKEYEXPANDRESULTS("ExpandResults");