Commit 46e00dda authored by Daniel Molkentin's avatar Daniel Molkentin
Browse files

Merge branch 'master' of

parents 14276f72 3ce094e4
......@@ -53,6 +53,7 @@
\o \l{Build Settings}
\o \l{Qt Version Management}
\o \l{Writing a Simple Program with Qt Creator}
\o \l{Qt Creator and Version Control Systems}
\o \l{Navigating Quickly Around Your Code with Locator}
\o \l{Debugging with Qt Creator}
\o \l{Tips and Tricks}
......@@ -237,10 +238,14 @@
\i Indenting
\i Indenting Blocks
\i Commenting or Uncommenting
\i Commenting or Uncommenting Blocks
\i Switch between Header and Source
......@@ -265,6 +270,11 @@
\contentspage index.html
......@@ -758,6 +768,136 @@
\contentspage index.html
\previouspage creator-navigation.html
\page creator-version-control.html
\nextpage creator-debugging.html
\title Qt Creator and Version Control Systems
\caption Version control systems supported by Qt Creator
\i \bold{git}
\i \l{}
\i \bold{Subversion}
\i \l{}
\i \bold{Perforce}
\i \l{}
\section1 Setup
Qt Creator uses the version control system's command line clients to
access your repositories. To set it up, you must ensure that these command
line clients can be located via the \c{PATH} environment variable. You can
specify the path to the command line client's executable in the settings
pages that can be found under \gui{Options...} in the \gui{Tools} menu.
\section1 Usage
You can find the version control menu entires in a sub-menu of the
\gui{Tools} menu. The version control system displayed here is the system
that manages the current project.
Each version control system adds a pane to the \gui{Application Output}
panes within which it will log the commands it executes, prepended by a
timestamp and the relevant output.
\image qtcreator-vcs-pane.png
\section2 Addings Files
When you create a new file or a new project, the wizards will display page
requesting whether the files should be added to a version control system.
This depends on whether the parent directory or the project is already
under version control and the system supports the concept of adding files,
e.g., \bold{Perforce} and \bold{Subversion}. Alternatively, you can also
add files later on using the version control tool menus.
With \bold{git}, there is no concept of adding files. Instead, all modified
files must be \e{staged} for a commit.
\section2 Viewing Diff Output
All version control systems provide menu options to \e{diff} the current
file or project - comparing with the latest version stored in the
repository and displaying the differences. In Qt Creator, a diff is
displayed in a read-only editor. If the file is accessible, you can double
-click on a selected diff chunk and Qt Creator will open an editor
displaying the file, scrolled to the line in question.
\image qtcreator-vcs-diff.png
\section2 Viewing Versioning History and Change Details
The versioning history of a file can be displayed by selecting the
\gui{Log} (for \bold{git}) or \gui{Filelog (for \bold{Perforce} and
\bold{Subversion})} option. Typically, the log output will contain the
date, the commit message, and a change or revision identifier. If you
click on the identifier, a description of the change including the diff
will be displayed.
\image qtcreator-vcs-log.png
\image qtcreator-vcs-describe.png
\section2 Annotating Files
Annotation views are obtained by selecting \gui{Annotate} or \gui{Blame}.
This will display the lines of the file prepended by the change identifier
they originate from. Clicking on the change identifier shows a detailed
description of the file.
\section2 Committing Changes
Once you have finished making changes, you can submit them to the version
control system by choosing \gui{Commit} or \gui{Submit}. Qt Creator will
display a commit page containing a text editor, where you can enter your
commit message, and a checkable list of modified files to be included.
When you are done, click \gui{Commit} to start committing. In addition,
there is a \gui{Diff selected} button that brings up a diff view of the
files selected in the file list. Since the commit page is just another
editor, you can go back to it by closing the diff view. Alternatively, you
can view it from the editor combo box showing the \gui{Opened files}.
\image qtcreator-vcs-commit.png
\section2 Menu Entries Specific to git
The git sub-menu contains additional entries:
\i \gui{Stash}
\i Stash local changes prior to executing a \bold{pull}.
\i \gui{Pull}
\i Pull changes from the remote repository. If there are locally
modified files, you will be prompted to stash those changes.
\i \gui{Branches...}
\i Displays the branch dialog showing the local branches at the
top and remote branches at the bottom. To switch to the local
branch, simply double-click on it. Double-clicking on a remote
branch will first create a local branch with the same name that
tracks the remote branch, and then switch to it.
\image qtcreator-vcs-gitbranch.png
\contentspage index.html
......@@ -87,6 +87,7 @@ void CMakeProject::parseCMakeLists(const QDir &directory)
CMakeCbpParser cbpparser;
qDebug()<<"Parsing file "<<cbpFile;
if (cbpparser.parseCbpFile(cbpFile)) {
m_projectName = cbpparser.projectName();
qDebug()<<"Building Tree";
// TODO do a intelligent updating of the tree
buildTree(m_rootNode, cbpparser.fileList());
......@@ -200,8 +201,7 @@ ProjectExplorer::FolderNode *CMakeProject::findOrCreateFolder(CMakeProjectNode *
QString CMakeProject::name() const
return "";
return m_projectName;
Core::IFile *CMakeProject::file() const
......@@ -469,6 +469,8 @@ void CMakeCbpParser::parseProject()
if (isEndElement()) {
} else if (name() == "Option") {
} else if (name() == "Unit") {
} else if (name() == "Build") {
......@@ -537,6 +539,26 @@ void CMakeCbpParser::parseTargetOption()
QString CMakeCbpParser::projectName() const
return m_projectName;
void CMakeCbpParser::parseOption()
if (attributes().hasAttribute("title"))
m_projectName = attributes().value("title").toString();
while (!atEnd()) {
if (isEndElement()) {
} else if(isStartElement()) {
void CMakeCbpParser::parseMakeCommand()
while (!atEnd()) {
......@@ -118,6 +118,7 @@ private:
CMakeManager *m_manager;
QString m_fileName;
CMakeFile *m_file;
QString m_projectName;
// TODO probably need a CMake specific node structure
CMakeProjectNode* m_rootNode;
......@@ -137,10 +138,12 @@ public:
QList<ProjectExplorer::FileNode *> fileList();
QStringList includeFiles();
QList<CMakeTarget> targets();
QString projectName() const;
void parseCodeBlocks_project_file();
void parseProject();
void parseBuild();
void parseOption();
void parseTarget();
void parseTargetOption();
void parseMakeCommand();
......@@ -157,6 +160,7 @@ private:
CMakeTarget m_target;
bool m_targetType;
QList<CMakeTarget> m_targets;
QString m_projectName;
class CMakeFile : public Core::IFile
......@@ -30,6 +30,7 @@ HEADERS += attachexternaldialog.h \
imports.h \
moduleshandler.h \
moduleswindow.h \
outputcollector.h \
procinterrupt.h \
registerhandler.h \
registerwindow.h \
......@@ -40,7 +41,7 @@ HEADERS += attachexternaldialog.h \
threadswindow.h \
watchhandler.h \
SOURCES += attachexternaldialog.cpp \
attachremotedialog.cpp \
breakhandler.cpp \
......@@ -54,9 +55,9 @@ SOURCES += attachexternaldialog.cpp \
disassemblerwindow.cpp \
gdbengine.cpp \
gdbmi.cpp \
gdbengine.h \
moduleshandler.cpp \
moduleswindow.cpp \
outputcollector.cpp \
procinterrupt.cpp \
registerhandler.cpp \
registerwindow.cpp \
......@@ -94,7 +94,7 @@ DebuggerSettings::DebuggerSettings()
m_skipKnownFrames = false;
m_debugDumpers = false;
m_useToolTips = false;
m_useToolTips = false;
m_useTerminal = false;
m_useCustomDumpers = true;
......@@ -590,9 +590,9 @@ void DebuggerManager::notifyInferiorPidChanged(int pid)
emit inferiorPidChanged(pid);
void DebuggerManager::showApplicationOutput(const QString &prefix, const QString &str)
void DebuggerManager::showApplicationOutput(const QString &str)
emit applicationOutputAvailable(prefix, str);
emit applicationOutputAvailable(str);
void DebuggerManager::shutdown()
......@@ -166,7 +166,7 @@ private:
virtual ThreadsHandler *threadsHandler() = 0;
virtual WatchHandler *watchHandler() = 0;
virtual void showApplicationOutput(const QString &prefix, const QString &data) = 0;
virtual void showApplicationOutput(const QString &data) = 0;
//virtual QAction *useCustomDumpersAction() const = 0;
//virtual QAction *debugDumpersAction() const = 0;
virtual bool skipKnownFrames() const = 0;
......@@ -200,6 +200,7 @@ public:
bool m_debugDumpers;
bool m_useFastStart;
bool m_useToolTips;
bool m_useTerminal;
QString m_scriptFile;
......@@ -285,7 +286,7 @@ public slots:
private slots:
void showDebuggerOutput(const QString &prefix, const QString &msg);
void showDebuggerInput(const QString &prefix, const QString &msg);
void showApplicationOutput(const QString &prefix, const QString &msg);
void showApplicationOutput(const QString &data);
void reloadDisassembler();
void disassemblerDockToggled(bool on);
......@@ -365,7 +366,7 @@ signals:
void setSessionValueRequested(const QString &name, const QVariant &value);
void configValueRequested(const QString &name, QVariant *value);
void setConfigValueRequested(const QString &name, const QVariant &value);
void applicationOutputAvailable(const QString &prefix, const QString &msg);
void applicationOutputAvailable(const QString &output);
// FIXME: make private
......@@ -106,13 +106,7 @@ const char * const JUMP_TO_LINE = "Debugger.JumpToLine";
const char * const TOGGLE_BREAK = "Debugger.ToggleBreak";
const char * const BREAK_BY_FUNCTION = "Debugger.BreakByFunction";
const char * const BREAK_AT_MAIN = "Debugger.BreakAtMain";
const char * const DEBUG_DUMPERS = "Debugger.DebugDumpers";
const char * const ADD_TO_WATCH = "Debugger.AddToWatch";
const char * const USE_CUSTOM_DUMPERS = "Debugger.UseCustomDumpers";
const char * const USE_FAST_START = "Debugger.UseFastStart";
const char * const USE_TOOL_TIPS = "Debugger.UseToolTips";
const char * const SKIP_KNOWN_FRAMES = "Debugger.SkipKnownFrames";
const char * const DUMP_LOG = "Debugger.DumpLog";
#ifdef Q_OS_MAC
const char * const INTERRUPT_KEY = "Shift+F5";
......@@ -283,6 +277,7 @@ QWidget *GdbOptionPage::createPage(QWidget *parent)
#ifndef QT_DEBUG
#if 0
......@@ -291,10 +286,6 @@ QWidget *GdbOptionPage::createPage(QWidget *parent)
cmd = am->registerAction(m_manager->m_debugDumpersAction,
Constants::DEBUG_DUMPERS, debuggercontext);
......@@ -325,6 +316,7 @@ void GdbOptionPage::apply()
m_settings.m_useCustomDumpers = m_ui.checkBoxUseCustomDumpers->isChecked();
m_settings.m_useFastStart = m_ui.checkBoxFastStart->isChecked();
m_settings.m_useToolTips = m_ui.checkBoxUseToolTips->isChecked();
m_settings.m_useTerminal = m_ui.checkBoxUseTerminal->isChecked();
*m_plugin->m_manager->settings() = m_settings;
......@@ -907,6 +899,7 @@ void DebuggerPlugin::writeSettings() const
s->setValue("UseFastStart", m->m_useFastStart);
s->setValue("UseToolTips", m->m_useToolTips);
s->setValue("UseTerminal", m->m_useTerminal);
s->setValue("UseCustomDumpers", m->m_useCustomDumpers);
s->setValue("SkipKnowFrames", m->m_skipKnownFrames);
s->setValue("DebugDumpers", m->m_debugDumpers);
......@@ -940,6 +933,7 @@ void DebuggerPlugin::readSettings()
m->m_useCustomDumpers = s->value("UseCustomDupers", false).toBool();
m->m_useFastStart = s->value("UseFastStart", false).toBool();
m->m_useToolTips = s->value("UseToolTips", false).toBool();
m->m_useTerminal = s->value("UseTerminal", false).toBool();
......@@ -108,8 +108,8 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
connect(m_manager, SIGNAL(debuggingFinished()),
this, SLOT(debuggingFinished()));
connect(m_manager, SIGNAL(applicationOutputAvailable(QString, QString)),
this, SLOT(slotAddToOutputWindow(QString, QString)));
connect(m_manager, SIGNAL(applicationOutputAvailable(QString)),
this, SLOT(slotAddToOutputWindowInline(QString)));
connect(m_manager, SIGNAL(inferiorPidChanged(qint64)),
this, SLOT(bringApplicationToForeground(qint64)));
......@@ -138,12 +138,9 @@ void DebuggerRunControl::start()
void DebuggerRunControl::slotAddToOutputWindow(const QString &prefix, const QString &line)
void DebuggerRunControl::slotAddToOutputWindowInline(const QString &data)
foreach (const QString &l, line.split('\n'))
emit addToOutputWindow(this, prefix + Qt::escape(l));
//emit addToOutputWindow(this, prefix + Qt::escape(line));
emit addToOutputWindowInline(this, data);
void DebuggerRunControl::stop()
......@@ -84,7 +84,7 @@ public:
private slots:
void debuggingFinished();
void slotAddToOutputWindow(const QString &prefix, const QString &line);
void slotAddToOutputWindowInline(const QString &output);
DebuggerManager *m_manager;
......@@ -252,6 +252,7 @@ void GdbEngine::init()
m_pendingRequests = 0;
m_gdbVersion = 100;
m_shared = 0;
m_outputCodec = QTextCodec::codecForLocale();
m_oldestAcceptableToken = -1;
......@@ -266,6 +267,8 @@ void GdbEngine::init()
// Output
connect(&m_outputCollector, SIGNAL(byteDelivery(QByteArray)),
connect(this, SIGNAL(gdbResponseAvailable()),
this, SLOT(handleResponse()), Qt::QueuedConnection);
......@@ -275,8 +278,8 @@ void GdbEngine::init()
connect(this, SIGNAL(gdbInputAvailable(QString,QString)),
q, SLOT(showDebuggerInput(QString,QString)),
connect(this, SIGNAL(applicationOutputAvailable(QString,QString)),
q, SLOT(showApplicationOutput(QString,QString)),
connect(this, SIGNAL(applicationOutputAvailable(QString)),
q, SLOT(showApplicationOutput(QString)),
......@@ -355,6 +358,12 @@ static void skipTerminator(const char *&from, const char *to)
skipSpaces(from, to);
void GdbEngine::readDebugeeOutput(const QByteArray &data)
emit applicationOutputAvailable(m_outputCodec->toUnicode(
data.constData(), data.length(), &m_outputCodecState));
// called asyncronously as response to Gdb stdout output in
// gdbResponseAvailable()
void GdbEngine::handleResponse()
......@@ -407,22 +416,6 @@ void GdbEngine::handleResponse()
if (token == -1 && *from != '&' && *from != '~' && *from != '*') {
// FIXME: On Linux the application's std::out is merged in here.
// High risk of falsely interpreting this as MI output.
// We assume that we _always_ use tokens, so not finding a token
// is a positive indication for the presence of application output.
QString s;
while (from != to && *from != '\n')
s += *from++;
//s += '\n';
m_inbuffer = QByteArray(from, to - from);
emit applicationOutputAvailable("app-stdout: ", s);
// next char decides kind of record
const char c = *from++;
//qDebug() << "CODE:" << c;
......@@ -590,8 +583,7 @@ static void fixMac(QByteArray &out)
void GdbEngine::readGdbStandardError()
QByteArray err = m_gdbProc.readAllStandardError();
emit applicationOutputAvailable("app-stderr:", err);
qWarning() << "Unexpected gdb stderr:" << m_gdbProc.readAllStandardError();
void GdbEngine::readGdbStandardOutput()
......@@ -1078,7 +1070,7 @@ void GdbEngine::handleStreamOutput(const QString &data, char code)
// On Windows, the contents seem to depend on the debugger
// version and/or OS version used.
if (data.startsWith("warning:"))
qq->showApplicationOutput(QString(), data);
......@@ -1484,6 +1476,7 @@ void GdbEngine::exitDebugger()
m_dataDumperState = DataDumperUninitialized;
m_shared = 0;
//q->settings()->m_debugDumpers = false;
......@@ -1506,6 +1499,15 @@ bool GdbEngine::startDebugger()
return false;
if (!m_outputCollector.listen()) {
QMessageBox::critical(q->mainWindow(), tr("Debugger Startup Failure"),
tr("Cannot set up communication with child process: %1")
return false;
gdbArgs.prepend(QLatin1String("--tty=") + m_outputCollector.serverName());
......@@ -1530,8 +1532,12 @@ bool GdbEngine::startDebugger()
m_gdbProc.start(q->settings()->m_gdbCmd, gdbArgs);
if (m_gdbProc.state() != QProcess::Running)
if (m_gdbProc.state() != QProcess::Running) {
QMessageBox::critical(q->mainWindow(), tr("Debugger Startup Failure"),
tr("Cannot start debugger: %1").arg(m_gdbProc.errorString()));
return false;
q->showStatusMessage(tr("Gdb Running"));
......@@ -36,6 +36,7 @@
#include "idebuggerengine.h"
#include "gdbmi.h"
#include "outputcollector.h"
#include <QtCore/QByteArray>
#include <QtCore/QHash>
......@@ -43,6 +44,7 @@
#include <QtCore/QObject>
#include <QtCore/QProcess>
#include <QtCore/QPoint>
#include <QtCore/QTextCodec>
#include <QtCore/QVariant>
......@@ -93,7 +95,7 @@ signals:
void gdbResponseAvailable();
void gdbInputAvailable(const QString &prefix, const QString &msg);
void gdbOutputAvailable(const QString &prefix, const QString &msg);
void applicationOutputAvailable(const QString &prefix, const QString &msg);
void applicationOutputAvailable(const QString &output);
......@@ -173,6 +175,7 @@ private slots:
void gdbProcError(QProcess::ProcessError error);
void readGdbStandardOutput();
void readGdbStandardError();
void readDebugeeOutput(const QByteArray &data);
int terminationIndex(const QByteArray &buffer, int &length);
......@@ -190,6 +193,10 @@ private:
void handleQueryPwd(const GdbResultRecord &response);
void handleQuerySources(const GdbResultRecord &response);
OutputCollector m_outputCollector;
QTextCodec *m_outputCodec;
QTextCodec::ConverterState m_outputCodecState;
QByteArray m_inbuffer;
QProcess m_gdbProc;
......@@ -36,7 +36,7 @@
<widget class="QLineEdit" name="environmentEdit"/>
<item row="0" column="0">
<widget class="QLabel" name="labelGdbLocaltion">
<widget class="QLabel" name="labelGdbLocation">
<property name="toolTip">
<string>This is either a full abolute path leading to the gdb binary you intend to use or the name of a gdb binary that wiull be searched in your PATH.</string>
......@@ -84,6 +84,16 @@
<widget class="QCheckBox" name="checkBoxUseTerminal">
<property name="toolTip">
<string>Start debugged process in a separte terminal.</string>
<property name="text">
<string>Start in terminal</string>