aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp3
-rw-r--r--src/plugins/debugger/cdb/cdbdebugengine.cpp6
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp4
-rw-r--r--src/plugins/git/gitclient.cpp8
-rw-r--r--src/plugins/projectexplorer/environmenteditmodel.cpp16
-rw-r--r--src/plugins/qtscripteditor/qtscripteditor.cpp6
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp8
-rw-r--r--src/plugins/texteditor/fontsettingspage.cpp19
-rw-r--r--src/shared/cplusplus/AST.cpp18
-rw-r--r--src/tools/qtcdebugger/main.cpp139
10 files changed, 199 insertions, 28 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 28c9e1a40ec..a62d33ea4b8 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -380,7 +380,8 @@ void CPPEditor::createToolBar(CPPEditorEditable *editable)
QToolBar *toolBar = editable->toolBar();
QList<QAction*> actions = toolBar->actions();
- toolBar->insertWidget(actions.first(), m_methodCombo);
+ QWidget *w = toolBar->widgetForAction(actions.first());
+ static_cast<QHBoxLayout*>(w->layout())->insertWidget(0, m_methodCombo, 1);
}
int CPPEditor::previousBlockState(QTextBlock block) const
diff --git a/src/plugins/debugger/cdb/cdbdebugengine.cpp b/src/plugins/debugger/cdb/cdbdebugengine.cpp
index 20f93aff20b..e6243a56c15 100644
--- a/src/plugins/debugger/cdb/cdbdebugengine.cpp
+++ b/src/plugins/debugger/cdb/cdbdebugengine.cpp
@@ -760,6 +760,12 @@ void CdbDebugEnginePrivate::endDebugging(EndDebuggingMode em)
}
setDebuggeeHandles(0, 0);
m_engine->killWatchTimer();
+
+ // Clean up resources (open files, etc.)
+ hr = m_cif.debugClient->EndSession(DEBUG_END_PASSIVE);
+ if (FAILED(hr))
+ errorMessage += msgComFailed("EndSession", hr);
+
if (!errorMessage.isEmpty()) {
errorMessage = QString::fromLatin1("There were errors trying to end debugging: %1").arg(errorMessage);
m_debuggerManagerAccess->showDebuggerOutput(QLatin1String("error"), errorMessage);
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index edb1d9986ff..e4f90707f61 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -1210,7 +1210,9 @@ void DebuggerPlugin::startExternalApplication()
setConfigValue(_("LastExternalExecutableArguments"),
dlg.executableArguments());
sp->executable = dlg.executableFile();
- sp->processArgs = dlg.executableArguments().split(QLatin1Char(' '));
+ if (!dlg.executableArguments().isEmpty())
+ sp->processArgs = dlg.executableArguments().split(QLatin1Char(' '));
+
if (dlg.breakAtMain())
m_manager->breakByFunctionMain();
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 7eabc65001e..e862ef95c36 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -546,7 +546,13 @@ bool GitClient::synchronousGit(const QString &workingDirectory,
environment.set(QLatin1String("PATH"), m_settings.path);
process.setEnvironment(environment.toStringList());
- process.start(m_binaryPath, arguments);
+#ifdef Q_OS_WIN
+ QStringList args;
+ args << "/c" << m_binaryPath << arguments;
+ process.start(QLatin1String("cmd.exe"), args);
+#else
+ process.start(m_binaryPath, arguments);
+#endif
process.closeWriteChannel();
if (!process.waitForFinished()) {
diff --git a/src/plugins/projectexplorer/environmenteditmodel.cpp b/src/plugins/projectexplorer/environmenteditmodel.cpp
index 36cb7a3aa61..0a2ceb20fdd 100644
--- a/src/plugins/projectexplorer/environmenteditmodel.cpp
+++ b/src/plugins/projectexplorer/environmenteditmodel.cpp
@@ -55,7 +55,7 @@ void EnvironmentModel::updateResultEnvironment()
m_resultEnvironment.modify(m_items);
foreach (const EnvironmentItem &item, m_items) {
if (item.unset) {
- m_resultEnvironment.set(item.name, "<UNSET>");
+ m_resultEnvironment.set(item.name, QLatin1String("<UNSET>"));
}
}
}
@@ -127,7 +127,7 @@ QVariant EnvironmentModel::data(const QModelIndex &index, int role) const
return m_resultEnvironment.value(m_resultEnvironment.constBegin() + index.row());
} else {
if (m_items.at(index.row()).unset)
- return "<UNSET>";
+ return QLatin1String("<UNSET>");
else
return m_items.at(index.row()).value;
}
@@ -285,7 +285,7 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
QModelIndex EnvironmentModel::addVariable()
{
- const QString &name = "<VARIABLE>";
+ const QString &name = QLatin1String("<VARIABLE>");
if (m_mergedEnvironments) {
int i = findInResult(name);
if (i != -1)
@@ -296,7 +296,7 @@ QModelIndex EnvironmentModel::addVariable()
return index(i, 0, QModelIndex());
}
// Don't exist, really add them
- return addVariable(EnvironmentItem(name, "<VALUE>"));
+ return addVariable(EnvironmentItem(name, QLatin1String("<VALUE>")));
}
QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
@@ -442,21 +442,21 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent)
QVBoxLayout *verticalLayout_2 = new QVBoxLayout();
m_editButton = new QPushButton(this);
- m_editButton->setText("&Edit");
+ m_editButton->setText(tr("&Edit"));
verticalLayout_2->addWidget(m_editButton);
m_addButton = new QPushButton(this);
- m_addButton->setText("&Add");
+ m_addButton->setText(tr("&Add"));
verticalLayout_2->addWidget(m_addButton);
m_removeButton = new QPushButton(this);
m_removeButton->setEnabled(false);
- m_removeButton->setText("&Reset");
+ m_removeButton->setText(tr("&Reset"));
verticalLayout_2->addWidget(m_removeButton);
m_unsetButton = new QPushButton(this);
m_unsetButton->setEnabled(false);
- m_unsetButton->setText("&Unset");
+ m_unsetButton->setText(tr("&Unset"));
verticalLayout_2->addWidget(m_unsetButton);
QSpacerItem *verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
diff --git a/src/plugins/qtscripteditor/qtscripteditor.cpp b/src/plugins/qtscripteditor/qtscripteditor.cpp
index 16244140235..47f7386ba75 100644
--- a/src/plugins/qtscripteditor/qtscripteditor.cpp
+++ b/src/plugins/qtscripteditor/qtscripteditor.cpp
@@ -52,8 +52,9 @@
#include <QtCore/QTimer>
#include <QtCore/QtDebug>
-#include <QtGui/QMenu>
#include <QtGui/QComboBox>
+#include <QtGui/QHBoxLayout>
+#include <QtGui/QMenu>
enum {
UPDATE_DOCUMENT_DEFAULT_INTERVAL = 100
@@ -386,7 +387,8 @@ void ScriptEditor::createToolBar(ScriptEditorEditable *editable)
QToolBar *toolBar = editable->toolBar();
QList<QAction*> actions = toolBar->actions();
- toolBar->insertWidget(actions.first(), m_methodCombo);
+ QWidget *w = toolBar->widgetForAction(actions.first());
+ static_cast<QHBoxLayout*>(w->layout())->insertWidget(0, m_methodCombo, 1);
}
void ScriptEditor::contextMenuEvent(QContextMenuEvent *e)
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 53be7c83acb..6acbb670614 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -2775,6 +2775,13 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
}
}
+ // Set whether the mouse cursor is a hand or normal arrow
+ if (e->type() == QEvent::MouseMove) {
+ bool hand = (e->pos().x() <= markWidth);
+ if (hand != (d->m_extraArea->cursor().shape() == Qt::PointingHandCursor))
+ d->m_extraArea->setCursor(hand ? Qt::PointingHandCursor : Qt::ArrowCursor);
+ }
+
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) {
if (e->button() == Qt::LeftButton) {
int boxWidth = collapseBoxWidth(fontMetrics());
@@ -4094,6 +4101,7 @@ BaseTextEditorEditable::BaseTextEditorEditable(BaseTextEditor *editor)
QWidget *w = new QWidget;
l->setMargin(0);
l->setContentsMargins(5, 0, 5, 0);
+ l->addStretch(0);
l->addWidget(m_cursorPositionLabel);
w->setLayout(l);
diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp
index 740740443c0..cb199388281 100644
--- a/src/plugins/texteditor/fontsettingspage.cpp
+++ b/src/plugins/texteditor/fontsettingspage.cpp
@@ -143,10 +143,23 @@ QString FormatDescription::trName() const
QColor FormatDescription::foreground() const
{
- if (m_name == QLatin1String(Constants::C_LINE_NUMBER))
- return QApplication::palette().dark().color();
- if (m_name == QLatin1String(Constants::C_PARENTHESES))
+ if (m_name == QLatin1String(Constants::C_LINE_NUMBER)) {
+ const QColor bg = QApplication::palette().background().color();
+ if (bg.value() < 128) {
+ return QApplication::palette().foreground().color();
+ } else {
+ return QApplication::palette().dark().color();
+ }
+ } else if (m_name == QLatin1String(Constants::C_CURRENT_LINE_NUMBER)) {
+ const QColor bg = QApplication::palette().background().color();
+ if (bg.value() < 128) {
+ return QApplication::palette().foreground().color();
+ } else {
+ return m_format.foreground();
+ }
+ } else if (m_name == QLatin1String(Constants::C_PARENTHESES)) {
return QColor(Qt::red);
+ }
return m_format.foreground();
}
diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp
index 77461d53d9d..97121d3c7e0 100644
--- a/src/shared/cplusplus/AST.cpp
+++ b/src/shared/cplusplus/AST.cpp
@@ -843,15 +843,23 @@ void DeclaratorListAST::accept0(ASTVisitor *visitor)
unsigned DeclaratorListAST::firstToken() const
{
+ if (comma_token)
+ return comma_token;
+
return declarator->firstToken();
}
unsigned DeclaratorListAST::lastToken() const
{
for (const DeclaratorListAST *it = this; it; it = it->next) {
- if (! it->next)
- return it->declarator->lastToken();
+ if (! it->next) {
+ if (it->declarator)
+ return it->declarator->lastToken();
+ else if (it->comma_token)
+ return it->comma_token + 1;
+ }
}
+
return 0;
}
@@ -2033,10 +2041,8 @@ unsigned SimpleDeclarationAST::lastToken() const
if (semicolon_token)
return semicolon_token + 1;
- for (DeclaratorListAST *it = declarators; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (declarators)
+ return declarators->lastToken();
for (SpecifierAST *it = decl_specifier_seq; it; it = it->next) {
if (! it->next)
diff --git a/src/tools/qtcdebugger/main.cpp b/src/tools/qtcdebugger/main.cpp
index 2f1e648647a..80c39de8edf 100644
--- a/src/tools/qtcdebugger/main.cpp
+++ b/src/tools/qtcdebugger/main.cpp
@@ -51,6 +51,7 @@ enum { debug = 0 };
static const char *titleC = "Qt Creator Debugger";
static const char *organizationC = "Nokia";
+static const char *applicationFileC = "qtcdebugger";
static const WCHAR *debuggerRegistryKeyC = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug";
// Optional
@@ -67,7 +68,7 @@ static inline QString wCharToQString(const WCHAR *w) { return QString::fromUtf16
#endif
-enum Mode { HelpMode, PromptMode, ForceCreatorMode, ForceDefaultMode };
+enum Mode { HelpMode, InstallMode, UninstallMode, PromptMode, ForceCreatorMode, ForceDefaultMode };
Mode optMode = PromptMode;
bool optIsWow = false;
@@ -112,6 +113,10 @@ static bool parseArguments(const QStringList &args, QString *errorMessage)
optMode = ForceCreatorMode;
} else if (arg == QLatin1String("default")) {
optMode = ForceDefaultMode;
+ } else if (arg == QLatin1String("install")) {
+ optMode = InstallMode;
+ } else if (arg == QLatin1String("uninstall")) {
+ optMode = UninstallMode;
} else if (arg == QLatin1String("wow")) {
optIsWow = true;
} else {
@@ -134,9 +139,16 @@ static bool parseArguments(const QStringList &args, QString *errorMessage)
}
}
}
- if (optMode != HelpMode && argProcessId == 0) {
- *errorMessage = QString::fromLatin1("Please specify the process-id.");
- return false;
+ switch (optMode) {
+ case HelpMode:
+ case InstallMode:
+ case UninstallMode:
+ break;
+ default:
+ if (argProcessId == 0) {
+ *errorMessage = QString::fromLatin1("Please specify the process-id.");
+ return false;
+ }
}
return true;
}
@@ -154,10 +166,12 @@ static void usage(const QString &binary, const QString &message = QString())
str << "<b>" << message << "</b>";
}
str << "<pre>"
- << "Usage: " << QFileInfo(binary).baseName() << "[-wow] [-help|-?|qtcreator|default] &lt;process-id> &lt;event-id>\n"
+ << "Usage: " << QFileInfo(binary).baseName() << "[-wow] [-help|-?|qtcreator|default|install|uninstall] &lt;process-id> &lt;event-id>\n"
<< "Options: -help, -? Display this help\n"
<< " -qtcreator Launch Qt Creator without prompting\n"
<< " -default Launch Default handler without prompting\n"
+ << " -install Install itself (requires administrative privileges)\n"
+ << " -uninstall Uninstall itself (requires administrative privileges)\n"
<< " -wow Indicates Wow32 call\n"
<< "</pre>"
<< "<p>To install, modify the registry key <i>HKEY_LOCAL_MACHINE\\" << wCharToQString(debuggerRegistryKeyC)
@@ -169,6 +183,8 @@ static void usage(const QString &binary, const QString &message = QString())
<< "</ul>"
<< "<p>On 64-bit systems, do the same for the key <i>HKEY_LOCAL_MACHINE\\" << wCharToQString(debuggerWow32RegistryKeyC) << "</i>, "
<< "setting the new value to <pre>\"" << QDir::toNativeSeparators(binary) << "\" -wow %ld %ld</pre></p>"
+ << "<p>How to run a command with administrative privileges:</p>"
+ << "<pre>runas /env /noprofile /user:Administrator \"command arguments\"</pre>"
<< "</body></html>";
QMessageBox msgBox(QMessageBox::Information, QLatin1String(titleC), msg, QMessageBox::Ok);
@@ -296,6 +312,18 @@ static inline bool registryReplaceStringKey(HKEY rootHandle, // HKEY_LOCAL_MACHI
return rc;
}
+static inline bool registryDeleteValue(HKEY handle,
+ const WCHAR *valueName,
+ QString *errorMessage)
+{
+ const LONG rc = RegDeleteValue(handle, valueName);
+ if (rc != ERROR_SUCCESS) {
+ *errorMessage = msgFunctionFailed("RegDeleteValue", rc);
+ return false;
+ }
+ return true;
+}
+
static QString getProcessBaseName(DWORD pid)
{
QString rc;
@@ -331,7 +359,7 @@ bool startCreatorAsDebugger(const QApplication &a, QString *errorMessage)
return true;
}
-bool startDefaultDebugger(const QApplication &a, QString *errorMessage)
+bool startDefaultDebugger(const QApplication & /*a*/, QString *errorMessage)
{
// Read out default value
HKEY handle;
@@ -385,6 +413,99 @@ bool chooseDebugger(const QApplication &a, QString *errorMessage)
return true;
}
+// Installation helpers: Format the debugger call with placeholders for PID and event
+// '"[path]\qtcdebugger" [-wow] %ld %ld'.
+
+static QString debuggerCall(const QApplication &a, const QString &additionalOption = QString())
+{
+ QString rc;
+ QTextStream str(&rc);
+ str << '"' << QDir::toNativeSeparators(a.applicationFilePath()) << '"';
+ if (!additionalOption.isEmpty())
+ str << ' ' << additionalOption;
+ str << " %ld %ld";
+ return rc;
+}
+
+// Installation helper: Register ourselves in a debugger registry key.
+// Make a copy of the old value as "Debugger.Default" and have the
+// "Debug" key point to us.
+
+static bool registerDebuggerKey(const WCHAR *key,
+ const QString &call,
+ QString *errorMessage)
+{
+ HKEY handle = 0;
+ bool success = false;
+ do {
+ if (!openRegistryKey(HKEY_LOCAL_MACHINE, key, true, &handle, errorMessage))
+ break;
+ QString oldDebugger;
+ if (!registryReadStringKey(handle, debuggerRegistryValueNameC, &oldDebugger, errorMessage))
+ break;
+ if (oldDebugger.contains(QLatin1String(applicationFileC), Qt::CaseInsensitive)) {
+ *errorMessage = QLatin1String("The program is already installed.");
+ return false;
+ }
+ if (!registryWriteStringKey(handle, debuggerRegistryDefaultValueNameC, oldDebugger, errorMessage))
+ break;
+ if (debug)
+ qDebug() << "registering self as " << call;
+ if (!registryWriteStringKey(handle, debuggerRegistryValueNameC, call, errorMessage))
+ break;
+ success = true;
+ } while (false);
+ if (handle)
+ RegCloseKey(handle);
+ return success;
+}
+
+bool install(const QApplication &a, QString *errorMessage)
+{
+ if (!registerDebuggerKey(debuggerRegistryKeyC, debuggerCall(a), errorMessage))
+ return false;
+#ifdef Q_OS_WIN64
+ if (!registerDebuggerKey(debuggerWow32RegistryKeyC, debuggerCall(a, QLatin1String("-wow")), errorMessage))
+ return false;
+#endif
+ return true;
+}
+
+// Uninstall helper: Restore the original debugger key
+static bool unregisterDebuggerKey(const WCHAR *key, QString *errorMessage)
+{
+ HKEY handle = 0;
+ bool success = false;
+ do {
+ if (!openRegistryKey(HKEY_LOCAL_MACHINE, key, true, &handle, errorMessage))
+ break;
+ QString oldDebugger;
+ if (!registryReadStringKey(handle, debuggerRegistryDefaultValueNameC, &oldDebugger, errorMessage))
+ break;
+ if (!registryWriteStringKey(handle, debuggerRegistryValueNameC, oldDebugger, errorMessage))
+ break;
+ if (!registryDeleteValue(handle, debuggerRegistryDefaultValueNameC, errorMessage))
+ break;
+ success = true;
+ } while (false);
+ if (handle)
+ RegCloseKey(handle);
+ return success;
+}
+
+
+bool uninstall(const QApplication & /*a*/, QString *errorMessage)
+{
+ if (!unregisterDebuggerKey(debuggerRegistryKeyC, errorMessage))
+ return false;
+#ifdef Q_OS_WIN64
+ if (!unregisterDebuggerKey(debuggerWow32RegistryKeyC, errorMessage))
+ return false;
+#endif
+ return true;
+}
+
+
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
@@ -413,6 +534,12 @@ int main(int argc, char *argv[])
case PromptMode:
ex = chooseDebugger(a, &errorMessage) ? 0 : -1;
break;
+ case InstallMode:
+ ex = install(a, &errorMessage) ? 0 : -1;
+ break;
+ case UninstallMode:
+ ex = uninstall(a, &errorMessage) ? 0 : -1;
+ break;
}
if (ex && !errorMessage.isEmpty()) {
qWarning("%s\n", qPrintable(errorMessage));