From 55b4e6d383d7d88ce32cf19ec87d85864ddb15fd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 13 Jan 2010 10:36:37 +0100 Subject: [PATCH 1/9] Debugger/CDB: Increase limits on string size in watch data. Introduce truncation in item view instead (full value visible in ToolTip). Reviewed-by: hjk Task-number: QTCREATORBUG-305 --- .../debugger/cdb/cdbsymbolgroupcontext.cpp | 12 ++++++------ src/plugins/debugger/watchhandler.cpp | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp b/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp index b37c8218890..72f7a59e84d 100644 --- a/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp +++ b/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp @@ -750,9 +750,10 @@ static inline bool getUnsignedHexValue(CIDebugSymbolGroup *sg, int index, quint6 return getUnsignedHexValue(stringValue, value); } +enum { maxStringLength = 4096 }; + int CdbSymbolGroupContext::dumpQString(CIDebugDataSpaces *ds, WatchData *wd) { - const int maxLength = 40; QString errorMessage; unsigned long stringIndex; if (!lookupPrefix(wd->iname, &stringIndex)) @@ -774,9 +775,9 @@ int CdbSymbolGroupContext::dumpQString(CIDebugDataSpaces *ds, WatchData *wd) if (!getUnsignedHexValue(m_symbolGroup, arrayIndex, &array)) return 5; // Fetch - const bool truncated = size > maxLength; + const bool truncated = size > maxStringLength; if (truncated) - size = maxLength; + size = maxStringLength; const QChar doubleQuote = QLatin1Char('"'); QString value; if (size > 0) { @@ -808,7 +809,6 @@ int CdbSymbolGroupContext::dumpQString(CIDebugDataSpaces *ds, WatchData *wd) int CdbSymbolGroupContext::dumpStdString(WatchData *wd) { - const int maxLength = 40; QString errorMessage; unsigned long stringIndex; if (!lookupPrefix(wd->iname, &stringIndex)) @@ -835,8 +835,8 @@ int CdbSymbolGroupContext::dumpStdString(WatchData *wd) if (quotePos == -1) return 1; bufValue.remove(0, quotePos); - if (bufValue.size() > maxLength) { - bufValue.truncate(maxLength); + if (bufValue.size() > maxStringLength) { + bufValue.truncate(maxStringLength); bufValue += QLatin1String("...\""); } wd->setValue(bufValue); diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 3723d5b6278..661df2cc8ab 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -727,6 +727,18 @@ void WatchModel::emitDataChanged(int column, const QModelIndex &parentIndex) emitDataChanged(column, index(i, 0, parentIndex)); } +// Truncate value for item view, maintaining quotes +static inline QString truncateValue(QString v) +{ + enum { maxLength = 512 }; + if (v.size() < maxLength) + return v; + const bool isQuoted = v.endsWith(QLatin1Char('"')); // check for 'char* "Hallo"' + v.truncate(maxLength); + v += isQuoted ? QLatin1String("...\"") : QLatin1String("..."); + return v; +} + QVariant WatchModel::data(const QModelIndex &idx, int role) const { const WatchItem &data = *watchItem(idx); @@ -735,9 +747,9 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const case Qt::DisplayRole: { switch (idx.column()) { case 0: return data.name; - case 1: return formattedValue(data, + case 1: return truncateValue(formattedValue(data, m_handler->m_individualFormats.value(data.iname, -1), - m_handler->m_typeFormats.value(data.type, -1)); + m_handler->m_typeFormats.value(data.type, -1))); case 2: if (!data.displayedType.isEmpty()) return data.displayedType; From 232db42069cc6da3c8e89d0a37c155ee43888a27 Mon Sep 17 00:00:00 2001 From: con Date: Wed, 13 Jan 2010 11:02:10 +0100 Subject: [PATCH 2/9] Fixes: Not able to set breakpoints in running application. Regression introduced by the gdb startup speedup. Reviewed-by: hjk --- src/plugins/debugger/gdb/gdbengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 0e8439e515b..2aa844bd651 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1948,7 +1948,7 @@ void GdbEngine::sendInsertBreakpoint(int index) void GdbEngine::reloadBreakListInternal() { m_breakListUpdating = true; - postCommand(_("-break-list"), CB(handleBreakList)); + postCommand(_("-break-list"), NeedsStop, CB(handleBreakList)); } void GdbEngine::handleBreakList(const GdbResponse &response) From 87a7ed94a3e5d57c02cfc68a8be87a76109bdb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 13 Jan 2010 14:45:32 +0100 Subject: [PATCH 3/9] Fixed an issue with keeping a shipped color scheme selected When the path to the shipped color schemes changes, Qt Creator was unable to load the chosen color scheme. Now, when it can't find the color scheme, it will look for it in the default color scheme path. Reviewed-by: con --- src/plugins/texteditor/colorscheme.cpp | 2 -- src/plugins/texteditor/fontsettings.cpp | 26 +++++++++++++++++++------ src/plugins/texteditor/fontsettings.h | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/plugins/texteditor/colorscheme.cpp b/src/plugins/texteditor/colorscheme.cpp index 87ab6efe0cb..545702efcc7 100644 --- a/src/plugins/texteditor/colorscheme.cpp +++ b/src/plugins/texteditor/colorscheme.cpp @@ -145,8 +145,6 @@ bool ColorScheme::save(const QString &fileName) const if (!m_name.isEmpty()) w.writeAttribute(QLatin1String("name"), m_name); - Format textFormat = formatFor(QLatin1String(Constants::C_TEXT)); - QMapIterator i(m_formats); while (i.hasNext()) { const Format &format = i.next().value(); diff --git a/src/plugins/texteditor/fontsettings.cpp b/src/plugins/texteditor/fontsettings.cpp index 8631645a485..f7718344713 100644 --- a/src/plugins/texteditor/fontsettings.cpp +++ b/src/plugins/texteditor/fontsettings.cpp @@ -33,6 +33,8 @@ #include #include +#include +#include #include #include #include @@ -114,8 +116,10 @@ bool FontSettings::fromSettings(const QString &category, if (s->contains(group + QLatin1String(schemeFileNameKey))) { // Load the selected color scheme - loadColorScheme(s->value(group + QLatin1String(schemeFileNameKey), defaultSchemeFileName()).toString(), - descriptions); + QString scheme = s->value(group + QLatin1String(schemeFileNameKey)).toString(); + if (scheme.isEmpty() || !QFile::exists(scheme)) + scheme = defaultSchemeFileName(QFileInfo(scheme).fileName()); + loadColorScheme(scheme, descriptions); } else { // Load color scheme from ini file foreach (const FormatDescription &desc, descriptions) { @@ -316,11 +320,21 @@ int FontSettings::defaultFontSize() return DEFAULT_FONT_SIZE; } -QString FontSettings::defaultSchemeFileName() +/** + * Returns the default scheme file name, or the path to a shipped scheme when + * one exists with the given \a fileName. + */ +QString FontSettings::defaultSchemeFileName(const QString &fileName) { - QString fileName = Core::ICore::instance()->resourcePath(); - fileName += QLatin1String("/styles/default.xml"); - return fileName; + QString defaultScheme = Core::ICore::instance()->resourcePath(); + defaultScheme += QLatin1String("/styles/"); + + if (!fileName.isEmpty() && QFile::exists(defaultScheme + fileName)) + defaultScheme += fileName; + else + defaultScheme += QLatin1String("default.xml"); + + return defaultScheme; } } // namespace TextEditor diff --git a/src/plugins/texteditor/fontsettings.h b/src/plugins/texteditor/fontsettings.h index 38ffa2d66e2..71035b87315 100644 --- a/src/plugins/texteditor/fontsettings.h +++ b/src/plugins/texteditor/fontsettings.h @@ -100,7 +100,7 @@ public: static int defaultFontSize(); private: - static QString defaultSchemeFileName(); + static QString defaultSchemeFileName(const QString &fileName = QString()); QString m_family; QString m_schemeFileName; From c47f1e3a7f2a2dff6dfad86f1fb71a72ec661658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 13 Jan 2010 17:11:20 +0100 Subject: [PATCH 4/9] Made "All Files" filter always available Needed to be able to open text files with arbitrary or no extension. Previously, the "All Files" filter would disappear when there was no plugin with an empty filter string, like the BinEditor plugin. Reviewed-by: con --- .../editormanager/editormanager.cpp | 44 ++++++++----------- src/plugins/coreplugin/mimedatabase.cpp | 7 ++- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 21f032904c7..bd4286d38eb 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -385,7 +385,7 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) : cmd->setDefaultKeySequence(QKeySequence(tr("Alt+V,Alt+I"))); advancedMenu->addAction(cmd, Constants::G_EDIT_EDITOR); connect(m_d->m_openInExternalEditorAction, SIGNAL(triggered()), this, SLOT(openInExternalEditor())); - + // Connect to VariableManager for CURRENT_DOCUMENT variable setting VariableManager *vm = VariableManager::instance(); connect(this, SIGNAL(currentEditorChanged(Core::IEditor *)), @@ -1079,48 +1079,40 @@ QString EditorManager::getOpenWithEditorKind(const QString &fileName, static QString formatFileFilters(const Core::ICore *core, QString *selectedFilter) { QString rc; - // Compile list of filter strings. If we find a glob matching all files, - // put it last and set it as default selectedFilter. + + // Compile list of filter strings QStringList filters = core->mimeDatabase()->filterStrings(); filters.sort(); selectedFilter->clear(); if (filters.empty()) return rc; + const QString filterSeparator = QLatin1String(";;"); - bool hasAllFilter = false; - const int size = filters.size(); - for (int i = 0; i < size; i++) { - const QString &filterString = filters.at(i); - if (filterString.isEmpty()) { // binary editor - hasAllFilter = true; - } else { - if (!rc.isEmpty()) - rc += filterSeparator; - rc += filterString; - } - } - if (hasAllFilter) { - // prepend all files filter - // prepending instead of appending to work around a but in Qt/Mac - QString allFilesFilter = EditorManager::tr("All Files (*)"); + foreach (const QString &filterString, filters) { if (!rc.isEmpty()) - allFilesFilter += filterSeparator; - rc.prepend(allFilesFilter); - *selectedFilter = allFilesFilter; - } else { - *selectedFilter = filters.front(); + rc += filterSeparator; + rc += filterString; } + + // prepend all files filter + // prepending instead of appending to work around a bug in Qt/Mac + QString allFilesFilter = EditorManager::tr("All Files (*)"); + if (!rc.isEmpty()) + allFilesFilter += filterSeparator; + rc.prepend(allFilesFilter); + *selectedFilter = allFilesFilter; + return rc; } IEditor *EditorManager::openEditor(const QString &fileName, const QString &editorKind, - EditorManager::OpenEditorFlags flags) + OpenEditorFlags flags) { return openEditor(0, fileName, editorKind, flags); } IEditor *EditorManager::openEditor(Core::Internal::EditorView *view, const QString &fileName, - const QString &editorKind, EditorManager::OpenEditorFlags flags) + const QString &editorKind, OpenEditorFlags flags) { if (debugEditorManager) qDebug() << Q_FUNC_INFO << fileName << editorKind; diff --git a/src/plugins/coreplugin/mimedatabase.cpp b/src/plugins/coreplugin/mimedatabase.cpp index acfd1905a97..32ead14d95f 100644 --- a/src/plugins/coreplugin/mimedatabase.cpp +++ b/src/plugins/coreplugin/mimedatabase.cpp @@ -1086,8 +1086,11 @@ QStringList MimeDatabasePrivate::filterStrings() const { QStringList rc; const TypeMimeTypeMap::const_iterator cend = m_typeMimeTypeMap.constEnd(); - for (TypeMimeTypeMap::const_iterator it = m_typeMimeTypeMap.constBegin(); it != cend; ++it) - rc += it.value().type.filterString(); + for (TypeMimeTypeMap::const_iterator it = m_typeMimeTypeMap.constBegin(); it != cend; ++it) { + const QString filterString = it.value().type.filterString(); + if (!filterString.isEmpty()) + rc += filterString; + } return rc; } From 466571919497ad8f4b86097bd7fa270d3106730c Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Thu, 14 Jan 2010 13:07:05 +0100 Subject: [PATCH 5/9] qtcdebugger: Overwriting other versions when registering. Reviewed-by: Friedemann Kleint --- src/tools/qtcdebugger/main.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/tools/qtcdebugger/main.cpp b/src/tools/qtcdebugger/main.cpp index 8be595a0ce1..2d50f5fc289 100644 --- a/src/tools/qtcdebugger/main.cpp +++ b/src/tools/qtcdebugger/main.cpp @@ -456,11 +456,12 @@ static bool registerDebuggerKey(const WCHAR *key, // Save old key, which might be missing QString oldDebugger; registryReadStringKey(handle, debuggerRegistryValueNameC, &oldDebugger, errorMessage); - if (oldDebugger.contains(QLatin1String(applicationFileC), Qt::CaseInsensitive)) { + if (!oldDebugger.compare(call, Qt::CaseInsensitive)) { *errorMessage = QLatin1String("The program is already registered as post mortem debugger."); break; } - if (!registryWriteStringKey(handle, debuggerRegistryDefaultValueNameC, oldDebugger, errorMessage)) + if (!(oldDebugger.contains(QLatin1String(applicationFileC), Qt::CaseInsensitive) + || registryWriteStringKey(handle, debuggerRegistryDefaultValueNameC, oldDebugger, errorMessage))) break; if (debug) qDebug() << "registering self as " << call; @@ -485,7 +486,9 @@ bool install(QString *errorMessage) } // Unregister helper: Restore the original debugger key -static bool unregisterDebuggerKey(const WCHAR *key, QString *errorMessage) +static bool unregisterDebuggerKey(const WCHAR *key, + const QString &call, + QString *errorMessage) { HKEY handle = 0; bool success = false; @@ -494,8 +497,7 @@ static bool unregisterDebuggerKey(const WCHAR *key, QString *errorMessage) break; QString debugger; registryReadStringKey(handle, debuggerRegistryValueNameC, &debugger, errorMessage); - if (!(debugger.isEmpty() - || debugger.contains(QLatin1String(applicationFileC), Qt::CaseInsensitive))) { + if (!debugger.isEmpty() && debugger.compare(call, Qt::CaseInsensitive)) { *errorMessage = QLatin1String("The program is not registered as post mortem debugger."); break; } @@ -522,10 +524,10 @@ static bool unregisterDebuggerKey(const WCHAR *key, QString *errorMessage) bool uninstall(QString *errorMessage) { - if (!unregisterDebuggerKey(debuggerRegistryKeyC, errorMessage)) + if (!unregisterDebuggerKey(debuggerRegistryKeyC, debuggerCall(), errorMessage)) return false; #ifdef Q_OS_WIN64 - if (!unregisterDebuggerKey(debuggerWow32RegistryKeyC, errorMessage)) + if (!unregisterDebuggerKey(debuggerWow32RegistryKeyC, debuggerCall(QLatin1String("-wow")), errorMessage)) return false; #endif return true; From 1e8f335f012b676b7ae94900cfe6958b603c439e Mon Sep 17 00:00:00 2001 From: con Date: Thu, 14 Jan 2010 13:47:32 +0100 Subject: [PATCH 6/9] Missing entry in changelog --- dist/changes-1.3.1 | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/changes-1.3.1 b/dist/changes-1.3.1 index 210806f12e6..ce72934d788 100644 --- a/dist/changes-1.3.1 +++ b/dist/changes-1.3.1 @@ -36,6 +36,7 @@ Debugging * Ignore case of file name in breakpoint handling on Windows * Fixed problems with gdb timing out and debugging sessions unexpectedly finishing * Improved startup time of gdb sessions by not asking for all files known to gdb + * Mac: Fixed problems with locals and watchers not updating correctly on Snow Leopard Help * Don't switch to Help mode if help side bar is already visible From 2520d0c5d57e194a69918e70d8f24866966e1419 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Thu, 14 Jan 2010 15:51:31 +0100 Subject: [PATCH 7/9] Fixed translation. Reviewed-by: ossi --- share/qtcreator/translations/qtcreator_de.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/translations/qtcreator_de.ts b/share/qtcreator/translations/qtcreator_de.ts index 9b994868f8c..4468021ea16 100644 --- a/share/qtcreator/translations/qtcreator_de.ts +++ b/share/qtcreator/translations/qtcreator_de.ts @@ -2961,7 +2961,7 @@ Sollen sie überschrieben werden? Line - Datei + Zeile @@ -4637,7 +4637,7 @@ Es wird empfohlen, gdb 6.7 oder später zu benutzen. Line - Datei + Zeile From 1da2e9e8d8d1a4ce6ed894b0154112692a0d8de1 Mon Sep 17 00:00:00 2001 From: dt Date: Thu, 14 Jan 2010 17:26:18 +0100 Subject: [PATCH 8/9] Fix for wrong version in gdb substitute for qt path Reviewed-By: thorbjorn --- src/plugins/debugger/gdb/gdbengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 2aa844bd651..eaa4c6fd9bf 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4554,7 +4554,7 @@ void GdbEngine::handleInferiorPrepared() postCommand(_("set substitute-path %1 %2") .arg(qtBuildPath).arg(qtInstallPath)); #elif defined(Q_OS_UNIX) && !defined (Q_OS_MAC) - qtBuildPath = _("/var/tmp/qt-x11-src-4.6.0"); + qtBuildPath = _("/var/tmp/qt-x11-src-4.6.1"); postCommand(_("set substitute-path %1 %2") .arg(qtBuildPath).arg(qtInstallPath)); #endif From cd8bc8a207fce7c019facbd26bbbbb818116b821 Mon Sep 17 00:00:00 2001 From: con Date: Thu, 14 Jan 2010 17:49:29 +0100 Subject: [PATCH 9/9] Opening binary files leaves empty entries in open editors window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Leading to a crash when selecting the empty entry. The patch fixes a big memory leak with bin editors (neither the widget nor the IFile instance was deleted, the latter leading to the empty entry in the open editors window), and also puts a saveguard in the open editors window, so that empty entries are not shown any more. Task-number: QTCREATORBUG-571 Reviewed-by: Thorbjørn --- src/plugins/bineditor/bineditorplugin.cpp | 11 ++++++----- .../coreplugin/editormanager/openeditorswindow.cpp | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 04bf7642f9d..e0ffa6c20b9 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -297,12 +297,11 @@ class BinEditorInterface : public Core::IEditor { Q_OBJECT public: - BinEditorInterface(BinEditor *parent) - : Core::IEditor(parent) + BinEditorInterface(BinEditor *editor) { Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); - m_editor = parent; - m_file = new BinEditorFile(parent); + m_editor = editor; + m_file = new BinEditorFile(m_editor); m_context << uidm->uniqueIdentifier(Core::Constants::K_DEFAULT_BINARY_EDITOR); m_context << uidm->uniqueIdentifier(Constants::C_BINEDITOR); m_cursorPositionLabel = new Utils::LineColumnLabel; @@ -321,7 +320,9 @@ public: connect(m_editor, SIGNAL(cursorPositionChanged(int)), this, SLOT(updateCursorPosition(int))); } - ~BinEditorInterface() {} + ~BinEditorInterface() { + delete m_editor; + } QWidget *widget() { return m_editor; } diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp index 6079ee7e60c..885a6fcfe5f 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp @@ -32,6 +32,8 @@ #include "editormanager.h" #include "editorview.h" +#include + #include Q_DECLARE_METATYPE(Core::Internal::EditorView*) @@ -201,11 +203,10 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE foreach (const EditLocation &hi, view->editorHistory()) { if (hi.file.isNull() || filesDone.contains(hi.file)) continue; - filesDone.insert(hi.file.data()); - - QTreeWidgetItem *item = new QTreeWidgetItem(); - QString title = model->displayNameForFile(hi.file); + QTC_ASSERT(!title.isEmpty(), continue;) + filesDone.insert(hi.file.data()); + QTreeWidgetItem *item = new QTreeWidgetItem(); if (hi.file->isModified()) title += tr("*"); item->setIcon(0, hi.file->isReadOnly() ? lockedIcon : emptyIcon);