From 23872bb9974778b6a5e44569129e5622d1fa804d Mon Sep 17 00:00:00 2001 From: mae Date: Tue, 9 Dec 2008 15:41:01 +0100 Subject: [PATCH 01/23] make indenting the selection a single undo/redo command --- src/plugins/texteditor/basetexteditor.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 82a4201b264..ff9be893a75 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -2751,7 +2751,9 @@ void BaseTextEditor::handleBackspaceKey() void BaseTextEditor::format() { QTextCursor cursor = textCursor(); + cursor.beginEditBlock(); indent(document(), cursor, QChar::Null); + cursor.endEditBlock(); } void BaseTextEditor::unCommentSelection() @@ -3319,16 +3321,13 @@ void BaseTextEditor::collapse() TextEditDocumentLayout *documentLayout = qobject_cast(doc->documentLayout()); Q_ASSERT(documentLayout); QTextBlock block = textCursor().block(); - qDebug() << "collapse at block" << block.blockNumber(); while (block.isValid()) { - qDebug() << "test block" << block.blockNumber(); if (TextBlockUserData::canCollapse(block) && block.next().isVisible()) { if ((block.next().userState()) >> 8 <= (textCursor().block().userState() >> 8)) break; } block = block.previous(); } - qDebug() << "found" << block.blockNumber(); if (block.isValid()) { TextBlockUserData::doCollapse(block, false); d->moveCursorVisible(); From 4c20a8afc756346b44e8f185974caf491631a012 Mon Sep 17 00:00:00 2001 From: mae Date: Tue, 9 Dec 2008 17:41:58 +0100 Subject: [PATCH 02/23] fix focus policy of the buttons so tab makes more sense --- src/plugins/find/findwidget.ui | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/find/findwidget.ui b/src/plugins/find/findwidget.ui index c85f3362997..f4b0c82ed25 100644 --- a/src/plugins/find/findwidget.ui +++ b/src/plugins/find/findwidget.ui @@ -56,6 +56,9 @@ + + Qt::NoFocus + Qt::LeftArrow @@ -66,6 +69,9 @@ + + Qt::NoFocus + Qt::RightArrow @@ -103,6 +109,9 @@ + + Qt::NoFocus + Qt::LeftArrow @@ -113,6 +122,9 @@ + + Qt::NoFocus + Qt::RightArrow From 98f35da62952bd7b4a4514b821395daa9b9f2bd2 Mon Sep 17 00:00:00 2001 From: mae Date: Tue, 9 Dec 2008 17:43:04 +0100 Subject: [PATCH 03/23] fix TabSettings::isIndentationClean(), it had false positives --- src/plugins/texteditor/tabsettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/texteditor/tabsettings.cpp b/src/plugins/texteditor/tabsettings.cpp index f87ab2ac8cf..19145a7cd97 100644 --- a/src/plugins/texteditor/tabsettings.cpp +++ b/src/plugins/texteditor/tabsettings.cpp @@ -132,7 +132,7 @@ bool TabSettings::isIndentationClean(const QString &text) const if (c == QLatin1Char(' ')) { ++spaceCount; - if (spaceCount == m_tabSize) + if (!m_spacesForTabs && spaceCount == m_tabSize) return false; } else if (c == QLatin1Char('\t')) { if (m_spacesForTabs || spaceCount != m_indentSize) From 1931304da1b59fcc396b3a550d0c9817ba73f8af Mon Sep 17 00:00:00 2001 From: mae Date: Tue, 9 Dec 2008 17:43:31 +0100 Subject: [PATCH 04/23] add explicit "Clean Whitespace" advanced action --- src/plugins/texteditor/basetextdocument.cpp | 12 ++++ src/plugins/texteditor/basetextdocument.h | 2 + src/plugins/texteditor/basetexteditor.cpp | 4 ++ src/plugins/texteditor/basetexteditor.h | 2 + .../texteditor/texteditoractionhandler.cpp | 65 ++++++------------- .../texteditor/texteditoractionhandler.h | 2 + src/plugins/texteditor/texteditorconstants.h | 1 + 7 files changed, 42 insertions(+), 46 deletions(-) diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index 0d5bd8c2dea..3758b133278 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -302,6 +302,18 @@ void BaseTextDocument::setSyntaxHighlighter(QSyntaxHighlighter *highlighter) m_highlighter->setDocument(m_document); } + + +void BaseTextDocument::cleanWhitespace() +{ + QTextCursor cursor(m_document); + cursor.beginEditBlock(); + cleanWhitespace(cursor, true); + if (m_storageSettings.m_addFinalNewLine) + ensureFinalNewLine(cursor); + cursor.endEditBlock(); +} + void BaseTextDocument::cleanWhitespace(QTextCursor& cursor, bool inEntireDocument) { diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h index ee8e5eb427a..b945129c474 100644 --- a/src/plugins/texteditor/basetextdocument.h +++ b/src/plugins/texteditor/basetextdocument.h @@ -118,6 +118,8 @@ public: void reload(QTextCodec *codec); + void cleanWhitespace(); + signals: void titleChanged(QString title); void changed(); diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index cb222dd9fd2..db5413c3446 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -685,6 +685,10 @@ void BaseTextEditor::selectBlockDown() } +void BaseTextEditor::cleanWhitespace() +{ + d->m_document->cleanWhitespace(); +} void BaseTextEditor::keyPressEvent(QKeyEvent *e) { diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 40454a9c7d4..1219439fc98 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -329,6 +329,8 @@ public slots: void selectBlockUp(); void selectBlockDown(); + void cleanWhitespace(); + signals: void changed(); diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 5ffd79e6d02..12fc7d1fac5 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -63,7 +63,7 @@ TextEditorActionHandler::TextEditorActionHandler(Core::ICore *core, { m_undoAction = m_redoAction = m_copyAction = m_cutAction = m_pasteAction = m_selectAllAction = m_gotoAction = m_printAction = m_formatAction - = m_visualizeWhitespaceAction = m_textWrappingAction + = m_visualizeWhitespaceAction = m_cleanWhitespaceAction = m_textWrappingAction = m_unCommentSelectionAction = m_unCollapseAllAction = m_collapseAction = m_expandAction = m_deleteLineAction = m_selectEncodingAction @@ -128,17 +128,23 @@ void TextEditorActionHandler::createActions() connect(m_formatAction, SIGNAL(triggered(bool)), this, SLOT(formatAction())); - m_visualizeWhitespaceAction = new QAction(tr("Visualize &Whitespace"), this); + m_visualizeWhitespaceAction = new QAction(tr("&Visualize Whitespace"), this); m_visualizeWhitespaceAction->setCheckable(true); command = am->registerAction(m_visualizeWhitespaceAction, TextEditor::Constants::VISUALIZE_WHITESPACE, m_contextId); #ifndef Q_OS_MAC command->setDefaultKeySequence(QKeySequence(tr("Ctrl+E, Ctrl+V"))); #endif - advancedMenu->addAction(command); connect(m_visualizeWhitespaceAction, SIGNAL(triggered(bool)), this, SLOT(setVisualizeWhitespace(bool))); + m_cleanWhitespaceAction = new QAction(tr("Clean Whitespace"), this); + command = am->registerAction(m_cleanWhitespaceAction, + TextEditor::Constants::CLEAN_WHITESPACE, m_contextId); + + advancedMenu->addAction(command); + connect(m_cleanWhitespaceAction, SIGNAL(triggered()), this, SLOT(cleanWhitespace())); + m_textWrappingAction = new QAction(tr("Enable Text &Wrapping"), this); m_textWrappingAction->setCheckable(true); command = am->registerAction(m_textWrappingAction, @@ -285,6 +291,7 @@ void TextEditorActionHandler::updateActions(UpdateMode um) m_visualizeWhitespaceAction->setEnabled(um != NoEditor); if (m_currentEditor) m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace); + m_cleanWhitespaceAction->setEnabled(um != NoEditor); if (m_textWrappingAction) { m_textWrappingAction->setEnabled(um != NoEditor); if (m_currentEditor) @@ -317,42 +324,6 @@ void TextEditorActionHandler::updateCopyAction() m_copyAction->setEnabled(hasCopyableText); } -void TextEditorActionHandler::undoAction() -{ - if (m_currentEditor) - m_currentEditor->undo(); -} - -void TextEditorActionHandler::redoAction() -{ - if (m_currentEditor) - m_currentEditor->redo(); -} - -void TextEditorActionHandler::copyAction() -{ - if (m_currentEditor) - m_currentEditor->copy(); -} - -void TextEditorActionHandler::cutAction() -{ - if (m_currentEditor) - m_currentEditor->cut(); -} - -void TextEditorActionHandler::pasteAction() -{ - if (m_currentEditor) - m_currentEditor->paste(); -} - -void TextEditorActionHandler::selectAllAction() -{ - if (m_currentEditor) - m_currentEditor->selectAll(); -} - void TextEditorActionHandler::gotoAction() { QuickOpen::QuickOpenManager *quickopen = QuickOpen::QuickOpenManager::instance(); @@ -367,13 +338,6 @@ void TextEditorActionHandler::printAction() m_currentEditor->print(m_core->printer()); } -void TextEditorActionHandler::formatAction() -{ - if (m_currentEditor) - m_currentEditor->format(); -} - - void TextEditorActionHandler::setVisualizeWhitespace(bool checked) { if (m_currentEditor) { @@ -403,6 +367,15 @@ void TextEditorActionHandler::setTextWrapping(bool checked) m_currentEditor->funcname2 ();\ } + +FUNCTION2(undoAction, undo) +FUNCTION2(redoAction, redo) +FUNCTION2(copyAction, copy) +FUNCTION2(cutAction, cut) +FUNCTION2(pasteAction, paste) +FUNCTION2(formatAction, format) +FUNCTION2(selectAllAction, selectAll) +FUNCTION(cleanWhitespace) FUNCTION(unCommentSelection) FUNCTION(deleteLine) FUNCTION(unCollapseAll) diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index 9a8c7b9f57c..520ae26ddf6 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -100,6 +100,7 @@ private slots: void printAction(); void formatAction(); void setVisualizeWhitespace(bool); + void cleanWhitespace(); void setTextWrapping(bool); void unCommentSelection(); void unCollapseAll(); @@ -128,6 +129,7 @@ private: QAction *m_printAction; QAction *m_formatAction; QAction *m_visualizeWhitespaceAction; + QAction *m_cleanWhitespaceAction; QAction *m_textWrappingAction; QAction *m_unCommentSelectionAction; QAction *m_unCollapseAllAction; diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 9ac9fdff0e4..192a07c257e 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -40,6 +40,7 @@ namespace Constants { const char * const C_TEXTEDITOR = "Text Editor"; const char * const COMPLETE_THIS = "TextEditor.CompleteThis"; const char * const VISUALIZE_WHITESPACE = "TextEditor.VisualizeWhitespace"; +const char * const CLEAN_WHITESPACE = "TextEditor.CleanWhitespace"; const char * const TEXT_WRAPPING = "TextEditor.TextWrapping"; const char * const UN_COMMENT_SELECTION = "TextEditor.UnCommentSelection"; const char * const COLLAPSE = "TextEditor.Collapse"; From 9c9308b91b116138ed5cc7753cf59eefd5a86db9 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 10 Dec 2008 10:47:26 +0100 Subject: [PATCH 05/23] QByteArray::toLong() does not auto-detect the base and also fixed a typo in the evaluator of bit-or expressions. --- src/libs/cplusplus/pp-engine.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index d2ed3ee73f3..83386e8079c 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -164,7 +164,15 @@ protected: bool process_primary() { if ((*_lex)->is(T_INT_LITERAL)) { - _value.set_long(tokenSpell().toLong()); + int base = 10; + const QByteArray spell = tokenSpell(); + if (spell.at(0) == '0') { + if (spell.size() > 1 && (spell.at(1) == 'x' || spell.at(1) == 'X')) + base = 16; + else + base = 8; + } + _value.set_long(tokenSpell().toLong(0, base)); ++(*_lex); return true; } else if (isTokenDefined()) { @@ -367,7 +375,7 @@ protected: { process_xor(); - while ((*_lex)->is(T_CARET)) { + while ((*_lex)->is(T_PIPE)) { const Token op = *(*_lex); ++(*_lex); From a6c6b2c4aeba6d87fc91e224223a81dd70b93bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 10 Dec 2008 11:58:25 +0100 Subject: [PATCH 06/23] Fixed macro tooltip overriding type information The macro tooltip is supposed to be a fallback, since otherwise you won't be able to see type information for macro parameters. Reviewed-by: Roberto Raggi --- src/plugins/cpptools/cpphoverhandler.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/plugins/cpptools/cpphoverhandler.cpp b/src/plugins/cpptools/cpphoverhandler.cpp index 1265ef9da7f..3cbb473e6df 100644 --- a/src/plugins/cpptools/cpphoverhandler.cpp +++ b/src/plugins/cpptools/cpphoverhandler.cpp @@ -175,15 +175,6 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in break; } } - - if (m_toolTip.isEmpty()) { - foreach (const Document::MacroUse use, doc->macroUses()) { - if (use.contains(pos)) { - m_toolTip = use.macro().toString(); - break; - } - } - } } if (m_toolTip.isEmpty()) { @@ -240,6 +231,15 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in } } + if (doc && m_toolTip.isEmpty()) { + foreach (const Document::MacroUse &use, doc->macroUses()) { + if (use.contains(pos)) { + m_toolTip = use.macro().toString(); + break; + } + } + } + if (m_helpEngineNeedsSetup && m_helpEngine->registeredDocumentations().count() > 0) { m_helpEngine->setupData(); @@ -248,7 +248,8 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in if (!m_helpId.isEmpty() && !m_helpEngine->linksForIdentifier(m_helpId).isEmpty()) { m_toolTip = QString(QLatin1String("" - "
%1
")).arg(Qt::escape(m_toolTip)); + "")) + .arg(Qt::escape(m_toolTip)); editor->setContextHelpId(m_helpId); } else if (!m_toolTip.isEmpty()) { m_toolTip = QString(QLatin1String("%1")).arg(Qt::escape(m_toolTip)); From 037a9bb57935dfa8ae825b6f0fb2800e3bd8a749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 10 Dec 2008 12:07:39 +0100 Subject: [PATCH 07/23] Set the help id for macros to their name Enables F1 for opening their help pages. Seems to work nicely. --- src/plugins/cpptools/cpphoverhandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/cpptools/cpphoverhandler.cpp b/src/plugins/cpptools/cpphoverhandler.cpp index 3cbb473e6df..338123bc5e6 100644 --- a/src/plugins/cpptools/cpphoverhandler.cpp +++ b/src/plugins/cpptools/cpphoverhandler.cpp @@ -235,6 +235,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in foreach (const Document::MacroUse &use, doc->macroUses()) { if (use.contains(pos)) { m_toolTip = use.macro().toString(); + m_helpId = use.macro().name; break; } } From fdd87280b2bcb4dee5f0575450591409bab48bf4 Mon Sep 17 00:00:00 2001 From: mae Date: Wed, 10 Dec 2008 12:11:57 +0100 Subject: [PATCH 08/23] rename visible parts of QuickOpen to "Type to locate", "Locate...", and "Locator", suggestion and request by the doc team. --- src/plugins/quickopen/quickopenconstants.h | 2 +- src/plugins/quickopen/quickopentoolwindow.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/quickopen/quickopenconstants.h b/src/plugins/quickopen/quickopenconstants.h index 8ae0380f371..9cce4268770 100644 --- a/src/plugins/quickopen/quickopenconstants.h +++ b/src/plugins/quickopen/quickopenconstants.h @@ -38,7 +38,7 @@ namespace QuickOpen { namespace Constants { const char * const FILTER_OPTIONS_PAGE = "Filters"; -const char * const QUICKOPEN_CATEGORY = "QuickOpen"; +const char * const QUICKOPEN_CATEGORY = "Locator"; const char * const TASK_INDEX = "QuickOpen.Task.Index"; } // namespace Constants diff --git a/src/plugins/quickopen/quickopentoolwindow.cpp b/src/plugins/quickopen/quickopentoolwindow.cpp index cd279fd7638..211947be8d0 100644 --- a/src/plugins/quickopen/quickopentoolwindow.cpp +++ b/src/plugins/quickopen/quickopentoolwindow.cpp @@ -264,7 +264,7 @@ QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) : // Explcitly hide the completion list popup. m_completionList->hide(); - setWindowTitle("Quick Open"); + setWindowTitle("Locate..."); resize(200, 90); QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); sizePolicy.setHorizontalStretch(0); @@ -281,7 +281,7 @@ QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) : QPixmap image(Core::Constants::ICON_MAGNIFIER); m_fileLineEdit->setPixmap(image); m_fileLineEdit->setUseLayoutDirection(true); - m_fileLineEdit->setHintText(tr("Type to QuickOpen")); + m_fileLineEdit->setHintText(tr("Type to locate")); m_fileLineEdit->setFocusPolicy(Qt::ClickFocus); m_fileLineEdit->installEventFilter(this); From 7a4ef123ef051c33c796199776bfab3bf37b6c75 Mon Sep 17 00:00:00 2001 From: con Date: Wed, 10 Dec 2008 12:27:08 +0100 Subject: [PATCH 09/23] Fixes: - tools->git->show commit dialog broken Task: - 237689 Details: - .git is a hidden file, so we need the QDir::Hidden flag as well --- src/plugins/git/changeselectiondialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp index 70004dbadfa..a8a706c8472 100644 --- a/src/plugins/git/changeselectiondialog.cpp +++ b/src/plugins/git/changeselectiondialog.cpp @@ -59,7 +59,7 @@ void ChangeSelectionDialog::selectWorkingDirectory() // the head directory of the repository. QDir repository(location); do { - if (repository.entryList(QDir::AllDirs).contains(QLatin1String(".git"))) { + if (repository.entryList(QDir::AllDirs|QDir::Hidden).contains(QLatin1String(".git"))) { m_ui.repositoryEdit->setText(repository.absolutePath()); return; } From 766ca41cec03acd9caf378483aa4dd56a0f812de Mon Sep 17 00:00:00 2001 From: con Date: Wed, 10 Dec 2008 12:36:02 +0100 Subject: [PATCH 10/23] Fixes: - Give show commit dialog a window title --- src/plugins/git/changeselectiondialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp index a8a706c8472..46eab385ac8 100644 --- a/src/plugins/git/changeselectiondialog.cpp +++ b/src/plugins/git/changeselectiondialog.cpp @@ -43,6 +43,7 @@ ChangeSelectionDialog::ChangeSelectionDialog(QWidget *parent) { m_ui.setupUi(this); connect(m_ui.repositoryButton, SIGNAL(clicked()), this, SLOT(selectWorkingDirectory())); + setWindowTitle(tr("Select a Git commit")); } void ChangeSelectionDialog::selectWorkingDirectory() From 824db4c6e70ad7b76662cd7e5d0bc7df14ad6628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 10 Dec 2008 12:33:14 +0100 Subject: [PATCH 11/23] Don't allow collapsing the settings pages It makes no sense. --- src/plugins/coreplugin/dialogs/settingsdialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp index 2d8531f3ed7..0f9758b1429 100644 --- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp @@ -47,6 +47,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory, setupUi(this); buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); + splitter->setCollapsible(1, false); pageTree->header()->setVisible(false); connect(pageTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), @@ -59,7 +60,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory, int index = 0; foreach (IOptionsPage *page, pages) { - QTreeWidgetItem *item = new QTreeWidgetItem(); + QTreeWidgetItem *item = new QTreeWidgetItem; item->setText(0, page->name()); item->setData(0, Qt::UserRole, index); From 65f07aa2de0fa24430a6deccc72334dfe883174f Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 10 Dec 2008 13:27:59 +0100 Subject: [PATCH 12/23] Implemented support for C++ and iso646 operators. --- shared/cplusplus/Keywords.cpp | 137 ++++++++++++++++++++++++++++++++++ shared/cplusplus/Lexer.cpp | 9 ++- shared/cplusplus/Lexer.h | 1 + shared/cplusplus/Token.h | 14 +++- 4 files changed, 158 insertions(+), 3 deletions(-) diff --git a/shared/cplusplus/Keywords.cpp b/shared/cplusplus/Keywords.cpp index 0e19b6b1d4f..d5ec6b5d432 100644 --- a/shared/cplusplus/Keywords.cpp +++ b/shared/cplusplus/Keywords.cpp @@ -1208,4 +1208,141 @@ int Lexer::classify(const char *s, int n, bool q) { } // switch } +static inline int classifyOperator2(const char *s) { + if (s[0] == 'o') { + if (s[1] == 'r') { + return T_OR; + } + } + return T_IDENTIFIER; +} + +static inline int classifyOperator3(const char *s) { + if (s[0] == 'a') { + if (s[1] == 'n') { + if (s[2] == 'd') { + return T_AND; + } + } + } + else if (s[0] == 'n') { + if (s[1] == 'o') { + if (s[2] == 't') { + return T_NOT; + } + } + } + else if (s[0] == 'x') { + if (s[1] == 'o') { + if (s[2] == 'r') { + return T_XOR; + } + } + } + return T_IDENTIFIER; +} + +static inline int classifyOperator5(const char *s) { + if (s[0] == 'b') { + if (s[1] == 'i') { + if (s[2] == 't') { + if (s[3] == 'o') { + if (s[4] == 'r') { + return T_BITOR; + } + } + } + } + } + else if (s[0] == 'c') { + if (s[1] == 'o') { + if (s[2] == 'm') { + if (s[3] == 'p') { + if (s[4] == 'l') { + return T_COMPL; + } + } + } + } + } + else if (s[0] == 'o') { + if (s[1] == 'r') { + if (s[2] == '_') { + if (s[3] == 'e') { + if (s[4] == 'q') { + return T_OR_EQ; + } + } + } + } + } + return T_IDENTIFIER; +} + +static inline int classifyOperator6(const char *s) { + if (s[0] == 'a') { + if (s[1] == 'n') { + if (s[2] == 'd') { + if (s[3] == '_') { + if (s[4] == 'e') { + if (s[5] == 'q') { + return T_AND_EQ; + } + } + } + } + } + } + else if (s[0] == 'b') { + if (s[1] == 'i') { + if (s[2] == 't') { + if (s[3] == 'a') { + if (s[4] == 'n') { + if (s[5] == 'd') { + return T_BITAND; + } + } + } + } + } + } + else if (s[0] == 'n') { + if (s[1] == 'o') { + if (s[2] == 't') { + if (s[3] == '_') { + if (s[4] == 'e') { + if (s[5] == 'q') { + return T_NOT_EQ; + } + } + } + } + } + } + else if (s[0] == 'x') { + if (s[1] == 'o') { + if (s[2] == 'r') { + if (s[3] == '_') { + if (s[4] == 'e') { + if (s[5] == 'q') { + return T_XOR_EQ; + } + } + } + } + } + } + return T_IDENTIFIER; +} + +int Lexer::classifyOperator(const char *s, int n) { + switch (n) { + case 2: return classifyOperator2(s); + case 3: return classifyOperator3(s); + case 5: return classifyOperator5(s); + case 6: return classifyOperator6(s); + default: return T_IDENTIFIER; + } // switch +} + CPLUSPLUS_END_NAMESPACE diff --git a/shared/cplusplus/Lexer.cpp b/shared/cplusplus/Lexer.cpp index af6f09f74d2..2e9ae98c1e0 100644 --- a/shared/cplusplus/Lexer.cpp +++ b/shared/cplusplus/Lexer.cpp @@ -589,8 +589,13 @@ void Lexer::scan_helper(Token *tok) tok->kind = classify(yytext, yylen, _qtMocRunEnabled); else tok->kind = T_IDENTIFIER; - if (tok->kind == T_IDENTIFIER && control()) - tok->identifier = control()->findOrInsertIdentifier(yytext, yylen); + + if (tok->kind == T_IDENTIFIER) { + tok->kind = classifyOperator(yytext, yylen); + + if (control()) + tok->identifier = control()->findOrInsertIdentifier(yytext, yylen); + } break; } else if (std::isdigit(ch)) { const char *yytext = _currentChar - 1; diff --git a/shared/cplusplus/Lexer.h b/shared/cplusplus/Lexer.h index 1d85a58eb9f..57f9d3e1362 100644 --- a/shared/cplusplus/Lexer.h +++ b/shared/cplusplus/Lexer.h @@ -112,6 +112,7 @@ private: void scan_helper(Token *tok); void setSource(const char *firstChar, const char *lastChar); static int classify(const char *string, int length, bool q); + static int classifyOperator(const char *string, int length); inline void yyinp() { diff --git a/shared/cplusplus/Token.h b/shared/cplusplus/Token.h index e172fea5680..f017bbc8e7e 100644 --- a/shared/cplusplus/Token.h +++ b/shared/cplusplus/Token.h @@ -209,7 +209,19 @@ enum Kind { T_LAST_KEYWORD = T_SLOTS, - // ### aliases + // aliases + T_OR = T_PIPE_PIPE, + T_AND = T_AMPER_AMPER, + T_NOT = T_EXCLAIM, + T_XOR = T_CARET, + T_BITOR = T_PIPE, + T_COMPL = T_TILDE, + T_OR_EQ = T_PIPE_EQUAL, + T_AND_EQ = T_AMPER_EQUAL, + T_BITAND = T_AMPER, + T_NOT_EQ = T_EXCLAIM_EQUAL, + T_XOR_EQ = T_CARET_EQUAL, + T___ASM = T_ASM, T___ASM__ = T_ASM, From 9c244bcbdebe00ce3b256308e36f441a227daf7f Mon Sep 17 00:00:00 2001 From: con Date: Wed, 10 Dec 2008 13:58:02 +0100 Subject: [PATCH 13/23] Fixes: - Warning about wrong connect Details: - Bookmarks plugin accidentally thought all editors are text editors. --- src/plugins/bookmarks/bookmarksplugin.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/bookmarks/bookmarksplugin.cpp b/src/plugins/bookmarks/bookmarksplugin.cpp index 83c8ec397ee..615ba5ec2ac 100644 --- a/src/plugins/bookmarks/bookmarksplugin.cpp +++ b/src/plugins/bookmarks/bookmarksplugin.cpp @@ -201,14 +201,18 @@ void BookmarksPlugin::updateActions(int state) void BookmarksPlugin::editorOpened(Core::IEditor *editor) { - connect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)), - this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*))); + if (qobject_cast(editor)) { + connect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)), + this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*))); + } } void BookmarksPlugin::editorAboutToClose(Core::IEditor *editor) { - disconnect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)), - this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*))); + if (qobject_cast(editor)) { + disconnect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)), + this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*))); + } } void BookmarksPlugin::requestContextMenu(TextEditor::ITextEditor *editor, From 94c613c9fe801da696df62ad3db56a08ee07003f Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Dec 2008 14:37:15 +0100 Subject: [PATCH 14/23] add custom dumpers for std::list --- bin/gdbmacros/gdbmacros.cpp | 73 +++++++++++++++ src/plugins/debugger/gdbengine.cpp | 2 + src/plugins/debugger/watchhandler.cpp | 22 ++++- tests/manual/gdbdebugger/simple/app.cpp | 119 ++++++++++++++++-------- 4 files changed, 170 insertions(+), 46 deletions(-) diff --git a/bin/gdbmacros/gdbmacros.cpp b/bin/gdbmacros/gdbmacros.cpp index 199b783f45d..e074ddd2a5d 100644 --- a/bin/gdbmacros/gdbmacros.cpp +++ b/bin/gdbmacros/gdbmacros.cpp @@ -122,6 +122,7 @@ int qtGhVersion = QT_VERSION; # include #endif +#include #include #include @@ -2101,6 +2102,76 @@ static void qDumpQVector(QDumper &d) d.disarm(); } +static void qDumpStdList(QDumper &d) +{ + const std::list &list = *reinterpret_cast *>(d.data); + const void *p = d.data; + qCheckAccess(p); + p = deref(p); + qCheckAccess(p); + p = deref(p); + qCheckAccess(p); + p = deref(p); + qCheckAccess(p); + p = deref(addOffset(d.data, sizeof(void*))); + qCheckAccess(p); + p = deref(addOffset(p, sizeof(void*))); + qCheckAccess(p); + p = deref(addOffset(p, sizeof(void*))); + qCheckAccess(p); + p = deref(addOffset(p, sizeof(void*))); + qCheckAccess(p); + + int nn = 0; + std::list::const_iterator it = list.begin(); + for (int i = 0; i < 101 && it != list.end(); ++i, ++it) { + qCheckAccess(it.operator->()); + ++nn; + } + + if (nn > 100) + P(d, "value", ""); + else + P(d, "value", "<" << nn << " items>"); + P(d, "numchild", nn); + + P(d, "valuedisabled", "true"); + if (d.dumpChildren) { + unsigned innersize = d.extraInt[0]; + bool innerTypeIsPointer = isPointerType(d.innertype); + QByteArray strippedInnerType = stripPointerType(d.innertype); + d << ",children=["; + std::list::const_iterator it = list.begin(); + for (int i = 0; i < 1000 && it != list.end(); ++i, ++it) { + d.beginHash(); + P(d, "name", "[" << i << "]"); + P(d, "type", d.innertype); + const void *p = it.operator->(); + if (innerTypeIsPointer) { + if (deref(p)) { + qDumpInnerValue(d, strippedInnerType.data(), deref(p)); + } else { + P(d, "type", d.innertype); + P(d, "value", ""); + P(d, "numchild", "0"); + } + } else { + qDumpInnerValue(d, d.innertype, p); + } + d.endHash(); + } + if (it != list.end()) { + d.beginHash(); + P(d, "name", "[...]"); + P(d, "value", ""); + P(d, "type", d.innertype); + d.endHash(); + } + d << "]"; + } + d.disarm(); +} + static void qDumpStdString(QDumper &d) { const std::string &str = *reinterpret_cast(d.data); @@ -2325,6 +2396,8 @@ static void handleProtocolVersion2and3(QDumper & d) qDumpStdVector(d); else if (isEqual(type, "std::vector::bool")) qDumpStdVectorBool(d); + else if (isEqual(type, "std::list")) + qDumpStdList(d); else if (isEqual(type, "string")) qDumpStdString(d); else if (isEqual(type, "std::string")) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index d7ac5b1aaa1..83473674782 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -2939,6 +2939,8 @@ bool GdbEngine::isCustomValueDumperAvailable(const QString &type) const if (tmplate == "QSet") return true; } + if (tmplate == "std::list") + return true; if (tmplate == "std::vector" && inner != "bool") return true; if (tmplate == "std::basic_string") { diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 053fcadcd19..47f1593db36 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -402,18 +402,30 @@ bool WatchHandler::setData(const QModelIndex &idx, static QString niceType(QString type) { if (type.contains("std::")) { - static QRegExp re("std::vector<(.*)\\s*,std::allocator<(.*)>\\s*>"); - re.setMinimal(true); - + // std::string type.replace("std::basic_string, " "std::allocator >", "std::string"); + + // std::wstring type.replace("std::basic_string, " "std::allocator >", "std::wstring"); + // std::vector + static QRegExp re1("std::vector<(.*)\\s*,std::allocator<(.*)>\\s*>"); + re1.setMinimal(true); for (int i = 0; i != 10; ++i) { - if (re.indexIn(type) == -1 || re.cap(1) != re.cap(2)) + if (re1.indexIn(type) == -1 || re1.cap(1) != re1.cap(2)) break; - type.replace(re.cap(0), "std::vector<" + re.cap(1) + ">"); + type.replace(re1.cap(0), "std::vector<" + re1.cap(1) + ">"); + } + + // std::list + static QRegExp re2("std::list<(.*)\\s*,std::allocator<(.*)>\\s*>"); + re2.setMinimal(true); + for (int i = 0; i != 10; ++i) { + if (re2.indexIn(type) == -1 || re2.cap(1) != re2.cap(2)) + break; + type.replace(re2.cap(0), "std::list<" + re2.cap(1) + ">"); } type.replace(" >", ">"); diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index 958c8985b05..4dc01961958 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -53,6 +53,8 @@ #include #include +#include +#include #include #include @@ -373,65 +375,63 @@ void stringRefTest(const QString &refstring) Q_UNUSED(refstring); } - -int F(int a, int b) +void testStdList() { - return a + b; -} - -int add(int i) { return i + 2; } - -int mul(int i) { return i * 2; } - - -void testStdVector() -{ - int x = F(add(1), mul(2)); - Q_UNUSED(x); - std::vector plist1; + std::list plist1; plist1.push_back(new int(1)); plist1.push_back(0); plist1.push_back(new int(2)); - std::vector flist2; + std::list flist2; flist2.push_back(1); flist2.push_back(2); flist2.push_back(3); flist2.push_back(4); - int a = 1; - int b = 0; - - while (0) { - a += 1; - if (b) - break; - } - flist2.push_back(1); flist2.push_back(2); flist2.push_back(3); flist2.push_back(4); - std::vector plist; + std::list plist; plist.push_back(new Foo(1)); plist.push_back(0); plist.push_back(new Foo(2)); - std::vector flist; + std::list flist; flist.push_back(1); - flist.push_back(2); flist.push_back(3); flist.push_back(4); - //flist.takeFirst(); - //flist.takeFirst(); - std::vector vec; + std::list vec; vec.push_back(true); vec.push_back(false); } +void testStdStack() +{ + std::stack plist1; + plist1.push(new int(1)); + plist1.push(0); + plist1.push(new int(2)); + plist1.pop(); + plist1.pop(); + plist1.pop(); + + std::stack flist2; + flist2.push(1); + flist2.push(2); + + std::stack plist; + plist.push(new Foo(1)); + plist.push(new Foo(2)); + + std::stack flist; + flist.push(1); + flist.push(2); +} + void testStdString() { QString foo; @@ -470,6 +470,42 @@ void testStdString() v.push_back(str); } +void testStdVector() +{ + std::vector plist1; + plist1.push_back(new int(1)); + plist1.push_back(0); + plist1.push_back(new int(2)); + + std::vector flist2; + flist2.push_back(1); + flist2.push_back(2); + flist2.push_back(3); + flist2.push_back(4); + + flist2.push_back(1); + flist2.push_back(2); + flist2.push_back(3); + flist2.push_back(4); + + std::vector plist; + plist.push_back(new Foo(1)); + plist.push_back(0); + plist.push_back(new Foo(2)); + + std::vector flist; + flist.push_back(1); + flist.push_back(2); + flist.push_back(3); + flist.push_back(4); + //flist.takeFirst(); + //flist.takeFirst(); + + std::vector vec; + vec.push_back(true); + vec.push_back(false); +} + void testString() { QString str = "Hello "; @@ -729,16 +765,9 @@ void testNamespace() bar.doit(1); } -int main(int argc, char *argv[]) + +void testHidden() { - testIO(); - //QString s; - //s = "hallo"; - //QList *> vi; - //QList *> vd; - //int n = A::barz(); - - int n = 1; n = 2; n = 3; @@ -762,10 +791,18 @@ int main(int argc, char *argv[]) } ++n; ++n; +} +int main(int argc, char *argv[]) +{ + //testIO(); + testHidden(); testArray(); - testStdVector(); + + testStdList(); + testStdStack(); testStdString(); + testStdVector(); testPlugin(); testList(); From 0722e9568202066ddee8a9cf9cc73716057799fe Mon Sep 17 00:00:00 2001 From: con Date: Wed, 10 Dec 2008 15:17:07 +0100 Subject: [PATCH 15/23] Fixes: - Don't popup the git output window at all operations --- src/plugins/git/gitclient.cpp | 58 +++++++++++++++++++---------- src/plugins/git/gitclient.h | 5 ++- src/plugins/git/gitoutputwindow.cpp | 1 - src/plugins/git/gitplugin.cpp | 3 +- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index ff0cdbde5e4..466307b4de3 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -197,7 +197,7 @@ void GitClient::diff(const QString &workingDirectory, const QStringList &fileNam const QString title = tr("Git Diff"); VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, workingDirectory, true, "originalFileName", workingDirectory); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor); + executeGit(workingDirectory, arguments, editor); } @@ -215,14 +215,14 @@ void GitClient::diff(const QString &workingDirectory, const QString &fileName) const QString sourceFile = source(workingDirectory, fileName); VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, true, "originalFileName", sourceFile); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor); + executeGit(workingDirectory, arguments, editor); } void GitClient::status(const QString &workingDirectory) { QStringList statusArgs(QLatin1String("status")); statusArgs << QLatin1String("-u"); - executeGit(workingDirectory, statusArgs, m_plugin->outputWindow(), 0,true); + executeGit(workingDirectory, statusArgs, 0, true); } void GitClient::log(const QString &workingDirectory, const QString &fileName) @@ -242,7 +242,7 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName) const QString kind = QLatin1String(Git::Constants::GIT_LOG_EDITOR_KIND); const QString sourceFile = source(workingDirectory, fileName); VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, false, "logFileName", sourceFile); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor); + executeGit(workingDirectory, arguments, editor); } void GitClient::show(const QString &source, const QString &id) @@ -258,7 +258,7 @@ void GitClient::show(const QString &source, const QString &id) const QFileInfo sourceFi(source); const QString workDir = sourceFi.isDir() ? sourceFi.absoluteFilePath() : sourceFi.absolutePath(); - executeGit(workDir, arguments, m_plugin->outputWindow(), editor); + executeGit(workDir, arguments, editor); } void GitClient::blame(const QString &workingDirectory, const QString &fileName) @@ -273,7 +273,7 @@ void GitClient::blame(const QString &workingDirectory, const QString &fileName) const QString sourceFile = source(workingDirectory, fileName); VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, true, "blameFileName", sourceFile); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor); + executeGit(workingDirectory, arguments, editor); } void GitClient::checkout(const QString &workingDirectory, const QString &fileName) @@ -287,7 +287,7 @@ void GitClient::checkout(const QString &workingDirectory, const QString &fileNam arguments << QLatin1String("checkout") << QLatin1String("HEAD") << QLatin1String("--") << fileName; - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true); + executeGit(workingDirectory, arguments, 0, true); } void GitClient::hardReset(const QString &workingDirectory, const QString &commit) @@ -297,7 +297,7 @@ void GitClient::hardReset(const QString &workingDirectory, const QString &commit if (!commit.isEmpty()) arguments << commit; - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true); + executeGit(workingDirectory, arguments, 0, true); } void GitClient::addFile(const QString &workingDirectory, const QString &fileName) @@ -305,7 +305,7 @@ void GitClient::addFile(const QString &workingDirectory, const QString &fileName QStringList arguments; arguments << QLatin1String("add") << fileName; - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true); + executeGit(workingDirectory, arguments, 0, true); } bool GitClient::synchronousAdd(const QString &workingDirectory, const QStringList &files) @@ -380,13 +380,14 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory, } void GitClient::executeGit(const QString &workingDirectory, const QStringList &arguments, - GitOutputWindow *outputWindow, VCSBase::VCSBaseEditor* editor, + VCSBase::VCSBaseEditor* editor, bool outputToWindow) { if (Git::Constants::debug) qDebug() << "executeGit" << workingDirectory << arguments << editor; - m_plugin->outputWindow()->append(formatCommand(QLatin1String(kGitCommand), arguments)); + GitOutputWindow *outputWindow = m_plugin->outputWindow(); + outputWindow->append(formatCommand(QLatin1String(kGitCommand), arguments)); QProcess process; ProjectExplorer::Environment environment = ProjectExplorer::Environment::systemEnvironment(); @@ -396,8 +397,13 @@ void GitClient::executeGit(const QString &workingDirectory, const QStringList &a GitCommand* command = new GitCommand(); if (outputToWindow) { - connect(command, SIGNAL(outputText(QString)), outputWindow, SLOT(append(QString))); - connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendData(QByteArray))); + if (!editor) { // assume that the commands output is the important thing + connect(command, SIGNAL(outputText(QString)), this, SLOT(appendAndPopup(QString))); + connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(appendDataAndPopup(QByteArray))); + } else { + connect(command, SIGNAL(outputText(QString)), outputWindow, SLOT(append(QString))); + connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendData(QByteArray))); + } } else { QTC_ASSERT(editor, /**/); connect(command, SIGNAL(outputText(QString)), editor, SLOT(setPlainText(QString))); @@ -405,11 +411,23 @@ void GitClient::executeGit(const QString &workingDirectory, const QStringList &a } if (outputWindow) - connect(command, SIGNAL(errorText(QString)), outputWindow, SLOT(append(QString))); + connect(command, SIGNAL(errorText(QString)), this, SLOT(appendAndPopup(QString))); command->execute(arguments, workingDirectory, environment); } +void GitClient::appendDataAndPopup(const QByteArray &data) +{ + m_plugin->outputWindow()->appendData(data); + m_plugin->outputWindow()->popup(false); +} + +void GitClient::appendAndPopup(const QString &text) +{ + m_plugin->outputWindow()->append(text); + m_plugin->outputWindow()->popup(false); +} + bool GitClient::synchronousGit(const QString &workingDirectory, const QStringList &arguments, QByteArray* outputText, @@ -810,12 +828,12 @@ void GitClient::revert(const QStringList &files) void GitClient::pull(const QString &workingDirectory) { - executeGit(workingDirectory, QStringList(QLatin1String("pull")), m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, QStringList(QLatin1String("pull")), 0, true); } void GitClient::push(const QString &workingDirectory) { - executeGit(workingDirectory, QStringList(QLatin1String("push")), m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, QStringList(QLatin1String("push")), 0, true); } QString GitClient::msgNoChangedFiles() @@ -829,7 +847,7 @@ void GitClient::stash(const QString &workingDirectory) QString errorMessage; switch (gitStatus(workingDirectory, false, 0, &errorMessage)) { case StatusChanged: - executeGit(workingDirectory, QStringList(QLatin1String("stash")), m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, QStringList(QLatin1String("stash")), 0, true); break; case StatusUnchanged: m_plugin->outputWindow()->append(msgNoChangedFiles()); @@ -846,21 +864,21 @@ void GitClient::stashPop(const QString &workingDirectory) { QStringList arguments(QLatin1String("stash")); arguments << QLatin1String("pop"); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, arguments, 0, true); } void GitClient::branchList(const QString &workingDirectory) { QStringList arguments(QLatin1String("branch")); arguments << QLatin1String("-r"); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, arguments, 0, true); } void GitClient::stashList(const QString &workingDirectory) { QStringList arguments(QLatin1String("stash")); arguments << QLatin1String("list"); - executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true); + executeGit(workingDirectory, arguments, 0, true); } QString GitClient::readConfig(const QString &workingDirectory, const QStringList &configVar) diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index efc767e5409..eb42b27efcb 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -130,6 +130,10 @@ public: public slots: void show(const QString &source, const QString &id); +private slots: + void appendAndPopup(const QString &text); + void appendDataAndPopup(const QByteArray &data); + private: VCSBase::VCSBaseEditor *createVCSEditor(const QString &kind, QString title, @@ -141,7 +145,6 @@ private: void executeGit(const QString &workingDirectory, const QStringList &arguments, - GitOutputWindow *outputWindow, VCSBase::VCSBaseEditor* editor = 0, bool outputToWindow = false); diff --git a/src/plugins/git/gitoutputwindow.cpp b/src/plugins/git/gitoutputwindow.cpp index 375be909597..fbaed2c8413 100644 --- a/src/plugins/git/gitoutputwindow.cpp +++ b/src/plugins/git/gitoutputwindow.cpp @@ -105,7 +105,6 @@ void GitOutputWindow::append(const QString &text) foreach (const QString &s, lines) m_outputListWidget->addItem(s); m_outputListWidget->scrollToBottom(); - popup(); } void GitOutputWindow::setData(const QByteArray &data) diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index d9187f542a9..f7647fb2d1a 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -496,7 +496,7 @@ QString GitPlugin::getWorkingDirectory() if (workingDirectory.isEmpty()) { m_outputWindow->clearContents(); m_outputWindow->append(tr("Could not find working directory")); - m_outputWindow->popup(); + m_outputWindow->popup(false); return QString(); } return workingDirectory; @@ -612,6 +612,7 @@ void GitPlugin::startCommit() changeTmpFile->setAutoRemove(true); if (!changeTmpFile->open()) { m_outputWindow->append(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString())); + m_outputWindow->popup(false); delete changeTmpFile; return; } From fdfae53abbdf57235fa35b0cc6e23e5f1a2bf18d Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 10 Dec 2008 15:43:17 +0100 Subject: [PATCH 16/23] Don't use QTC_ASSERT in the C++ front-end library. The engine does not recover from invalid asserts, so it will crash anyway, but not in a controlled environment. --- src/libs/cplusplus/CppDocument.cpp | 4 +--- src/libs/cplusplus/OverviewModel.cpp | 12 +++++------- src/libs/cplusplus/ResolveExpression.cpp | 22 ++++++++++------------ src/libs/cplusplus/pp-environment.cpp | 4 +--- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 3e619548a23..e67214f63b8 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -33,8 +33,6 @@ #include "CppDocument.h" -#include - #include #include #include @@ -273,7 +271,7 @@ bool Document::parse(ParseMode mode) void Document::check() { - QTC_ASSERT(!_globalNamespace, return); + Q_ASSERT(!_globalNamespace); Semantic semantic(_control); diff --git a/src/libs/cplusplus/OverviewModel.cpp b/src/libs/cplusplus/OverviewModel.cpp index 7f38cb8ba1a..b1b7267027c 100644 --- a/src/libs/cplusplus/OverviewModel.cpp +++ b/src/libs/cplusplus/OverviewModel.cpp @@ -34,8 +34,6 @@ #include "OverviewModel.h" #include "Overview.h" -#include - #include #include #include @@ -83,13 +81,13 @@ QModelIndex OverviewModel::index(int row, int column, const QModelIndex &parent) return createIndex(row, column, symbol); } else { Symbol *parentSymbol = static_cast(parent.internalPointer()); - QTC_ASSERT(parentSymbol, return QModelIndex()); + Q_ASSERT(parentSymbol); ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol(); - QTC_ASSERT(scopedSymbol, return QModelIndex()); + Q_ASSERT(scopedSymbol); Scope *scope = scopedSymbol->members(); - QTC_ASSERT(scope, return QModelIndex()); + Q_ASSERT(scope); return createIndex(row, 0, scope->symbolAt(row)); } @@ -126,12 +124,12 @@ int OverviewModel::rowCount(const QModelIndex &parent) const if (!parent.parent().isValid() && parent.row() == 0) // account for no symbol item return 0; Symbol *parentSymbol = static_cast(parent.internalPointer()); - QTC_ASSERT(parentSymbol, return 0); + Q_ASSERT(parentSymbol); if (ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol()) { if (!scopedSymbol->isFunction()) { Scope *parentScope = scopedSymbol->members(); - QTC_ASSERT(parentScope, return 0); + Q_ASSERT(parentScope); return parentScope->symbolCount(); } diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 6915e1169b0..0ea9018a353 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -45,8 +45,6 @@ #include #include -#include - #include #include @@ -100,7 +98,7 @@ protected: // types virtual void visit(PointerToMemberType * /*ty*/) { - QTC_ASSERT(false, /**/); + Q_ASSERT(false); } virtual void visit(PointerType *ty) @@ -152,32 +150,32 @@ protected: { /* nothing to do*/ } virtual void visit(Namespace *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(Class *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(Enum *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } // names virtual void visit(NameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(TemplateNameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(DestructorNameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(OperatorNameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(ConversionNameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } virtual void visit(QualifiedNameId *) - { QTC_ASSERT(false, /**/); } + { Q_ASSERT(false); } }; } // end of anonymous namespace diff --git a/src/libs/cplusplus/pp-environment.cpp b/src/libs/cplusplus/pp-environment.cpp index 20491727a4c..dd839087a40 100644 --- a/src/libs/cplusplus/pp-environment.cpp +++ b/src/libs/cplusplus/pp-environment.cpp @@ -53,8 +53,6 @@ #include "pp-environment.h" #include "pp.h" -#include - #include using namespace CPlusPlus; @@ -93,7 +91,7 @@ Macro *Environment::macroAt(unsigned index) const Macro *Environment::bind(const Macro &__macro) { - QTC_ASSERT(! __macro.name.isEmpty(), return 0); + Q_ASSERT(! __macro.name.isEmpty()); Macro *m = new Macro (__macro); m->hashcode = hash_code(m->name); From 3b31b5c98ce1ef1cc5158326b77d96d484f81aeb Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Dec 2008 16:31:50 +0100 Subject: [PATCH 17/23] work on std::list dumper; also a bit of refactoring --- bin/gdbmacros/gdbmacros.cpp | 155 +++++++++--------------- tests/manual/gdbdebugger/simple/app.cpp | 72 +++++------ 2 files changed, 89 insertions(+), 138 deletions(-) diff --git a/bin/gdbmacros/gdbmacros.cpp b/bin/gdbmacros/gdbmacros.cpp index e074ddd2a5d..abca7066ee4 100644 --- a/bin/gdbmacros/gdbmacros.cpp +++ b/bin/gdbmacros/gdbmacros.cpp @@ -407,12 +407,13 @@ struct QDumper QDumper &operator<<(unsigned int i); QDumper &operator<<(const void *p); QDumper &operator<<(qulonglong c); - void put(char c); - void addCommaIfNeeded(); - void putBase64Encoded(const char *buf, int n); QDumper &operator<<(const char *str); QDumper &operator<<(const QByteArray &ba); QDumper &operator<<(const QString &str); + void put(char c); + void addCommaIfNeeded(); + void putBase64Encoded(const char *buf, int n); + void putEllipsis(); void disarm(); void beginHash(); // start of data hash output @@ -658,6 +659,14 @@ void QDumper::endHash() put('}'); } +void QDumper::putEllipsis() +{ + d.beginHash(); + P(d, "name", "Warning:"); + P(d, "value", ""); + P(d, "type", d.innertype); + d.endHash(); +} // // Some helpers to keep the dumper code short @@ -816,6 +825,27 @@ static void qDumpInnerValue(QDumper &d, const char *type, const void *addr) } +static void qDumpInnerValueOrPointer(QDumper &d, + const char *type, const char *strippedtype, const void *addr) +{ + if (strippedtype) { + if (deref(addr)) { + P(d, "addr", deref(addr)); + P(d, "type", strippedtype); + qDumpInnerValueHelper(d, strippedtype, deref(addr)); + } else { + P(d, "addr", addr); + P(d, "type", strippedtype); + P(d, "value", ""); + P(d, "numchild", "0"); + } + } else { + P(d, "addr", addr); + P(d, "type", type); + qDumpInnerValueHelper(d, type, addr); + } +} + ////////////////////////////////////////////////////////////////////////////// static void qDumpQByteArray(QDumper &d) @@ -1213,9 +1243,8 @@ static void qDumpQList(QDumper &d) bool isInternal = innerSize <= int(sizeof(void*)) && isMovableType(d.innertype); - P(d, "internal", (int)isInternal); - - P(d, "childtype", d.innertype); + P(d, "internal", (int)isInternal); + P(d, "childtype", d.innertype); if (n > 1000) n = 1000; d << ",children=["; @@ -1245,11 +1274,8 @@ static void qDumpQList(QDumper &d) } d.endHash(); } - if (n < nn) { - d.beginHash(); - P(d, "value", ""); - d.endHash(); - } + if (n < nn) + d.putEllipsis(); d << "]"; } d.disarm(); @@ -1491,7 +1517,6 @@ static void qDumpQObject(QDumper &d) d.beginHash(); P(d, "name", "methods"); P(d, "exp", "*(class '"NS"QObject'*)" << d.data); - P(d, "type", NS"QObjectMethodList"); P(d, "value", "<" << mo->methodCount() << " items>"); P(d, "numchild", mo->methodCount()); d.endHash(); @@ -1877,11 +1902,7 @@ static void qDumpQSet(QDumper &d) d.endHash(); ++i; if (i > 10000) { - d.beginHash(); - P(d, "name", "Warning:"); - P(d, "value", ""); - P(d, "type", ""); - d.endHash(); + d.putEllipsis(); break; } } @@ -1936,13 +1957,8 @@ static void qDumpQStringList(QDumper &d) P(d, "valueencoded", "1"); d.endHash(); } - if (n < list.size()) { - d.beginHash(); - P(d, "name", "Warning:"); - P(d, "value", ""); - P(d, "type", ""); - d.endHash(); - } + if (n < list.size()) + d.putEllipsis(); d << "]"; } d.disarm(); @@ -2066,37 +2082,21 @@ static void qDumpQVector(QDumper &d) P(d, "valuedisabled", "true"); P(d, "numchild", n); if (d.dumpChildren) { - bool innerTypeIsPointer = isPointerType(d.innertype); QByteArray strippedInnerType = stripPointerType(d.innertype); - + const char *stripped = + isPointerType(d.innertype) ? strippedInnerType.data() : 0; if (n > 1000) n = 1000; d << ",children=["; for (int i = 0; i != n; ++i) { d.beginHash(); P(d, "name", "[" << i << "]"); - const void *p = addOffset(v, i * innersize + typeddatasize); - if (innerTypeIsPointer) { - if (deref(p)) { - //P(d, "value","@" << p); - qDumpInnerValue(d, strippedInnerType.data(), deref(p)); - } else { - P(d, "type", d.innertype); - P(d, "value", ""); - P(d, "numchild", "0"); - } - } else { - qDumpInnerValue(d, d.innertype, p); - } - d.endHash(); - } - if (n < nn) { - d.beginHash(); - P(d, "name", "[...]"); - P(d, "value", ""); - P(d, "type", d.innertype); + qDumpInnerValueOrPointer(d, d.innertype, stripped, + addOffset(v, i * innersize + typeddatasize)); d.endHash(); } + if (n < nn) + d.putEllipsis(); d << "]"; } d.disarm(); @@ -2111,23 +2111,17 @@ static void qDumpStdList(QDumper &d) qCheckAccess(p); p = deref(p); qCheckAccess(p); - p = deref(p); - qCheckAccess(p); p = deref(addOffset(d.data, sizeof(void*))); qCheckAccess(p); p = deref(addOffset(p, sizeof(void*))); qCheckAccess(p); p = deref(addOffset(p, sizeof(void*))); qCheckAccess(p); - p = deref(addOffset(p, sizeof(void*))); - qCheckAccess(p); int nn = 0; std::list::const_iterator it = list.begin(); - for (int i = 0; i < 101 && it != list.end(); ++i, ++it) { + for (nn < 101 && it != list.end(); ++nn, ++it) qCheckAccess(it.operator->()); - ++nn; - } if (nn > 100) P(d, "value", ""); @@ -2137,36 +2131,19 @@ static void qDumpStdList(QDumper &d) P(d, "valuedisabled", "true"); if (d.dumpChildren) { - unsigned innersize = d.extraInt[0]; - bool innerTypeIsPointer = isPointerType(d.innertype); QByteArray strippedInnerType = stripPointerType(d.innertype); + const char *stripped = + isPointerType(d.innertype) ? strippedInnerType.data() : 0; d << ",children=["; std::list::const_iterator it = list.begin(); for (int i = 0; i < 1000 && it != list.end(); ++i, ++it) { d.beginHash(); P(d, "name", "[" << i << "]"); - P(d, "type", d.innertype); - const void *p = it.operator->(); - if (innerTypeIsPointer) { - if (deref(p)) { - qDumpInnerValue(d, strippedInnerType.data(), deref(p)); - } else { - P(d, "type", d.innertype); - P(d, "value", ""); - P(d, "numchild", "0"); - } - } else { - qDumpInnerValue(d, d.innertype, p); - } - d.endHash(); - } - if (it != list.end()) { - d.beginHash(); - P(d, "name", "[...]"); - P(d, "value", ""); - P(d, "type", d.innertype); + qDumpInnerValueOrPointer(d, d.innertype, stripped, it.operator->()); d.endHash(); } + if (it != list.end()) + d.putEllipsis(); d << "]"; } d.disarm(); @@ -2238,37 +2215,21 @@ static void qDumpStdVector(QDumper &d) P(d, "numchild", n); if (d.dumpChildren) { unsigned innersize = d.extraInt[0]; - bool innerTypeIsPointer = isPointerType(d.innertype); QByteArray strippedInnerType = stripPointerType(d.innertype); - + const char *stripped = + isPointerType(d.innertype) ? strippedInnerType.data() : 0; if (n > 1000) n = 1000; d << ",children=["; for (int i = 0; i != n; ++i) { d.beginHash(); P(d, "name", "[" << i << "]"); - const void *p = addOffset(v->start, i * innersize); - if (innerTypeIsPointer) { - if (deref(p)) { - //P(d, "value","@" << p); - qDumpInnerValue(d, strippedInnerType.data(), deref(p)); - } else { - P(d, "type", d.innertype); - P(d, "value", ""); - P(d, "numchild", "0"); - } - } else { - qDumpInnerValue(d, d.innertype, p); - } - d.endHash(); - } - if (n < nn) { - d.beginHash(); - P(d, "name", "[...]"); - P(d, "value", ""); - P(d, "type", d.innertype); + qDumpInnerValueOrPointer(d, d.innertype, stripped, + addOffset(v->start, i * innersize)); d.endHash(); } + if (n < nn) + d.putEllipsis(); d << "]"; } d.disarm(); diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index 4dc01961958..35933ec5a20 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -129,7 +129,7 @@ void testArray() } -void testByteArray() +void testQByteArray() { QByteArray ba = "Hello"; ba += '"'; @@ -140,7 +140,7 @@ void testByteArray() } -void testHash() +void testQHash() { QHash hgg0; hgg0[11] = 11.0; @@ -164,7 +164,7 @@ void testHash() hash.insert(".", QPointer(&ob)); } -void testImage() +void testQImage() { QImage im(QSize(200, 200), QImage::Format_RGB32); im.fill(QColor(200, 100, 130).rgba()); @@ -192,7 +192,7 @@ void testIO() } -void testList() +void testQList() { #if 1 QList li; @@ -254,7 +254,7 @@ void testList() v.push_back("dd"); } -void testMap() +void testQMap() { QMap ggl; ggl[11] = QStringList() << "11"; @@ -289,7 +289,7 @@ void testMap() #endif } -void testObject(int &argc, char *argv[]) +void testQObject(int &argc, char *argv[]) { QApplication app(argc, argv); QAction act("xxx", &app); @@ -317,7 +317,7 @@ void testObject(int &argc, char *argv[]) app.exec(); } -void testPixmap() +void testQPixmap() { QImage im(QSize(200, 200), QImage::Format_RGB32); im.fill(QColor(200, 100, 130).rgba()); @@ -353,7 +353,7 @@ void testPlugin() } } -void testSet() +void testQSet() { QSet hgg0; hgg0.insert(11); @@ -506,7 +506,7 @@ void testStdVector() vec.push_back(false); } -void testString() +void testQString() { QString str = "Hello "; str += " big, "; @@ -516,19 +516,9 @@ void testString() str += " World "; str += " World "; str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; - str += " World "; } -void testString3() +void testQString3() { QString str = "Hello "; str += " big, "; @@ -544,7 +534,7 @@ void testString3() delete pstring; } -void testStringList() +void testQStringList() { QStringList l; l << "Hello "; @@ -578,7 +568,7 @@ private: int m_id; }; -void testThreads() +void testQThread() { Thread thread1(1); Thread thread2(2); @@ -588,7 +578,7 @@ void testThreads() thread2.wait(); } -void testVariant1() +void testQVariant1() { QVariant v; v = 1; @@ -597,7 +587,7 @@ void testVariant1() v = 1; } -void testVariant2() +void testQVariant2() { QVariant var; #if 0 @@ -622,7 +612,7 @@ void testVariant2() var.setValue(my); } -void testVariant3() +void testQVariant3() { QList list; list << 1 << 2 << 3; @@ -631,7 +621,7 @@ void testVariant3() list = qVariantValue >(variant); } -void testVector() +void testQVector() { QVector plist; plist.append(new Foo(1)); @@ -652,7 +642,7 @@ void testVector() vec.append(false); } -void testVectorOfList() +void testQVectorOfQList() { QVector > v; QVector > *pv = &v; @@ -805,28 +795,28 @@ int main(int argc, char *argv[]) testStdVector(); testPlugin(); - testList(); + testQList(); testNamespace(); //return 0; - testByteArray(); - testHash(); - testImage(); - testMap(); - testString(); - testSet(); - testStringList(); + testQByteArray(); + testQHash(); + testQImage(); + testQMap(); + testQString(); + testQSet(); + testQStringList(); testStruct(); //testThreads(); - testVariant1(); - testVariant2(); - testVariant3(); - testVector(); - testVectorOfList(); + testQVariant1(); + testQVariant2(); + testQVariant3(); + testQVector(); + testQVectorOfQList(); *(int *)0 = 0; - testObject(argc, argv); + testQObject(argc, argv); //QColor color(255,128,10); From 09da60f050b35b9150b1febdcdd546d7fcb981b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 10 Dec 2008 16:22:45 +0100 Subject: [PATCH 18/23] Fix git configuration page resize behaviour Now it uses all the available space. --- src/plugins/git/settingspage.ui | 153 ++++++++++++++------------------ 1 file changed, 68 insertions(+), 85 deletions(-) diff --git a/src/plugins/git/settingspage.ui b/src/plugins/git/settingspage.ui index aa2337605b8..151608d03b0 100644 --- a/src/plugins/git/settingspage.ui +++ b/src/plugins/git/settingspage.ui @@ -6,114 +6,97 @@ 0 0 - 436 - 186 + 389 + 183 Form - + - - - - - true - - - Environment variables - - - true - - - - - - PATH: - - + + + true + + + Environment variables + + + true + + + + + + PATH: + + + + + + + - - - - - - - - - From system - - - - - - - + + - <b>Note:</b> - - - - - - - Git needs to find Perl in the environment as well. + From system + + + + + <b>Note:</b> + + + + + + + Git needs to find Perl in the environment as well. + + + + + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Note that huge amount of commits might take some time. + + + 1000 + - - - - QFormLayout::ExpandingFieldsGrow + + + + Log commit display count: - - - - Note that huge amount of commits might take some time. - - - 1000 - - - - - - - Log commit display count: - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - + - + - Qt::Horizontal + Qt::Vertical - 40 - 20 + 20 + 40 From 540c6de10830326c89da4f4c127551a97c2518a5 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Dec 2008 16:48:12 +0100 Subject: [PATCH 19/23] work on std::list dumper --- bin/gdbmacros/gdbmacros.cpp | 11 ++++------- tests/manual/gdbdebugger/simple/app.cpp | 5 +++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bin/gdbmacros/gdbmacros.cpp b/bin/gdbmacros/gdbmacros.cpp index abca7066ee4..9ea2a9aff56 100644 --- a/bin/gdbmacros/gdbmacros.cpp +++ b/bin/gdbmacros/gdbmacros.cpp @@ -661,11 +661,8 @@ void QDumper::endHash() void QDumper::putEllipsis() { - d.beginHash(); - P(d, "name", "Warning:"); - P(d, "value", ""); - P(d, "type", d.innertype); - d.endHash(); + addCommaIfNeeded(); + *this << "{name=\"\",value=\"\",type=\"" << innertype << "\"}"; } // @@ -2120,7 +2117,7 @@ static void qDumpStdList(QDumper &d) int nn = 0; std::list::const_iterator it = list.begin(); - for (nn < 101 && it != list.end(); ++nn, ++it) + for (; nn < 101 && it != list.end(); ++nn, ++it) qCheckAccess(it.operator->()); if (nn > 100) @@ -2135,7 +2132,7 @@ static void qDumpStdList(QDumper &d) const char *stripped = isPointerType(d.innertype) ? strippedInnerType.data() : 0; d << ",children=["; - std::list::const_iterator it = list.begin(); + it = list.begin(); for (int i = 0; i < 1000 && it != list.end(); ++i, ++it) { d.beginHash(); P(d, "name", "[" << i << "]"); diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index 35933ec5a20..dbc7eebcd3c 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -73,6 +73,9 @@ uint qHash(const double & f) return int(f); } +#define X myns +X::QString str; + class Foo { public: @@ -623,6 +626,8 @@ void testQVariant3() void testQVector() { + QVector big(10000); + QVector plist; plist.append(new Foo(1)); plist.append(0); From e9d90710099376d585b73a872be62889b0fd24da Mon Sep 17 00:00:00 2001 From: con Date: Wed, 10 Dec 2008 16:48:28 +0100 Subject: [PATCH 20/23] Fixes: - Restoring session doesn't end up with focus in editor RevBy: - dt Details: - ProjectWindow always grabbed the focus --- src/plugins/projectexplorer/projectwindow.cpp | 10 +++++++++- src/plugins/projectexplorer/session.cpp | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index c725c915c9e..e6732387424 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -190,7 +191,14 @@ void ProjectWindow::updateTreeWidget() // That one runs fully thorough and deletes all widgets, even that one that we are currently removing // from m_panelsTabWidget. // To prevent that, we simply prevent the focus switching.... - m_treeWidget->setFocus(); + QWidget *focusWidget = qApp->focusWidget(); + while (focusWidget) { + if (focusWidget == this) { + m_treeWidget->setFocus(); + break; + } + focusWidget = focusWidget->parentWidget(); + } m_treeWidget->clear(); foreach(Project *project, m_session->projects()) { diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index a9bded02c61..89716ce3f68 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -628,8 +628,10 @@ bool SessionManager::loadImpl(const QString &fileName) if (success) { // restore the active mode const QString &modeIdentifier = value(QLatin1String("ActiveMode")).toString(); - if (!modeIdentifier.isEmpty()) + if (!modeIdentifier.isEmpty()) { m_core->modeManager()->activateMode(modeIdentifier); + m_core->modeManager()->setFocusToCurrentMode(); + } } if (debug) From 154121279e1befa507c4077f813af5f9aa11a253 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Dec 2008 16:53:18 +0100 Subject: [PATCH 21/23] add to watchwindow was missing an update. --- src/plugins/debugger/debuggermanager.cpp | 1 - src/plugins/debugger/watchhandler.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index a01a3ddc57e..4981f199790 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -1033,7 +1033,6 @@ void DebuggerManager::addToWatchWindow() void DebuggerManager::watchExpression(const QString &expression) { watchHandler()->watchExpression(expression); - //engine()->updateWatchModel(); } void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 47f1593db36..6f443c92b47 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -877,9 +877,9 @@ void WatchHandler::watchExpression(const QString &exp) data.name = exp; data.iname = "watch." + exp; insertData(data); + emit watchModelUpdateRequested(); } - void WatchHandler::setDisplayedIName(const QString &iname, bool on) { WatchData *d = findData(iname); From d45460726479931ff7ed75fe0d34da8eea469718 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 10 Dec 2008 17:21:01 +0100 Subject: [PATCH 22/23] Implemented tooltip and lookat for #include directives. --- src/libs/cplusplus/CppDocument.cpp | 10 +++++++--- src/libs/cplusplus/CppDocument.h | 23 +++++++++++++++++++++-- src/libs/cplusplus/pp-client.h | 3 ++- src/libs/cplusplus/pp-engine.cpp | 4 ++-- src/plugins/cppeditor/cppeditor.cpp | 12 +++++++++++- src/plugins/cpptools/cpphoverhandler.cpp | 10 ++++++++++ src/plugins/cpptools/cppmodelmanager.cpp | 10 ++++++---- 7 files changed, 59 insertions(+), 13 deletions(-) diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index e67214f63b8..d670e7e0018 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -131,12 +131,16 @@ QString Document::fileName() const QStringList Document::includedFiles() const { - return _includedFiles; + QStringList files; + foreach (const Include &i, _includes) + files.append(i.fileName()); + files.removeDuplicates(); + return files; } -void Document::addIncludeFile(const QString &fileName) +void Document::addIncludeFile(const QString &fileName, unsigned line) { - _includedFiles.append(fileName); + _includes.append(Include(fileName, line)); } void Document::appendMacro(const Macro ¯o) diff --git a/src/libs/cplusplus/CppDocument.h b/src/libs/cplusplus/CppDocument.h index aaca36c18ee..b31f0d2bc64 100644 --- a/src/libs/cplusplus/CppDocument.h +++ b/src/libs/cplusplus/CppDocument.h @@ -65,7 +65,7 @@ public: QString fileName() const; QStringList includedFiles() const; - void addIncludeFile(const QString &fileName); + void addIncludeFile(const QString &fileName, unsigned line); void appendMacro(const Macro ¯o); void addMacroUse(const Macro ¯o, unsigned offset, unsigned length); @@ -181,6 +181,22 @@ public: { return pos >= _begin && pos < _end; } }; + class Include { + QString _fileName; + unsigned _line; + + public: + Include(const QString &fileName, unsigned line) + : _fileName(fileName), _line(line) + { } + + QString fileName() const + { return _fileName; } + + unsigned line() const + { return _line; } + }; + class MacroUse: public Block { Macro _macro; @@ -196,6 +212,9 @@ public: { return _macro; } }; + QList includes() const + { return _includes; } + QList skippedBlocks() const { return _skippedBlocks; } @@ -207,11 +226,11 @@ private: private: QString _fileName; - QStringList _includedFiles; Control *_control; TranslationUnit *_translationUnit; Namespace *_globalNamespace; QList _diagnosticMessages; + QList _includes; QList _definedMacros; QList _skippedBlocks; QList _macroUses; diff --git a/src/libs/cplusplus/pp-client.h b/src/libs/cplusplus/pp-client.h index 2fc781f22f5..eead5bf4600 100644 --- a/src/libs/cplusplus/pp-client.h +++ b/src/libs/cplusplus/pp-client.h @@ -63,7 +63,8 @@ public: { } virtual void macroAdded(const Macro ¯o) = 0; - virtual void sourceNeeded(QString &fileName, IncludeType mode) = 0; // ### FIX the signature. + virtual void sourceNeeded(QString &fileName, IncludeType mode, + unsigned line) = 0; // ### FIX the signature. virtual void startExpandingMacro(unsigned offset, const Macro ¯o, diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 83386e8079c..c33fc8cb151 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -818,7 +818,7 @@ void pp::processInclude(bool skipCurentPath, QString fn = QString::fromUtf8(path.constData(), path.length()); if (client) - client->sourceNeeded(fn, Client::IncludeGlobal); + client->sourceNeeded(fn, Client::IncludeGlobal, firstToken->lineno); } else if (tk->is(T_ANGLE_STRING_LITERAL) || tk->is(T_STRING_LITERAL)) { const QByteArray spell = tokenSpell(*tk); const char *beginOfPath = spell.constBegin(); @@ -831,7 +831,7 @@ void pp::processInclude(bool skipCurentPath, QString fn = QString::fromUtf8(path.constData(), path.length()); if (client) - client->sourceNeeded(fn, Client::IncludeLocal); + client->sourceNeeded(fn, Client::IncludeLocal, firstToken->lineno); } } } diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 8d4a36178ce..f233c0121f8 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -480,13 +480,23 @@ void CPPEditor::jumpToDefinition() Document::Ptr doc = m_modelManager->document(file()->fileName()); if (!doc) return; + + QTextCursor tc = textCursor(); + unsigned lineno = tc.blockNumber() + 1; + foreach (const Document::Include &incl, doc->includes()) { + if (incl.line() == lineno) { + if (TextEditor::BaseTextEditor::openEditorAt(incl.fileName(), 0, 0)) + return; // done + break; + } + } + Symbol *lastSymbol = doc->findSymbolAt(line, column); if (!lastSymbol) return; // Get the expression under the cursor const int endOfName = endOfNameUnderCursor(); - QTextCursor tc = textCursor(); tc.setPosition(endOfName); ExpressionUnderCursor expressionUnderCursor; const QString expression = expressionUnderCursor(tc); diff --git a/src/plugins/cpptools/cpphoverhandler.cpp b/src/plugins/cpptools/cpphoverhandler.cpp index 338123bc5e6..f3831e5394d 100644 --- a/src/plugins/cpptools/cpphoverhandler.cpp +++ b/src/plugins/cpptools/cpphoverhandler.cpp @@ -177,6 +177,16 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in } } + if (m_toolTip.isEmpty()) { + unsigned lineno = tc.blockNumber() + 1; + foreach (const Document::Include &incl, doc->includes()) { + if (lineno == incl.line()) { + m_toolTip = incl.fileName(); + break; + } + } + } + if (m_toolTip.isEmpty()) { // Move to the end of a qualified name bool stop = false; diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 40888d99f3f..9adc892713d 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -138,7 +138,8 @@ protected: virtual void stopExpandingMacro(unsigned offset, const Macro ¯o); virtual void startSkippingBlocks(unsigned offset); virtual void stopSkippingBlocks(unsigned offset); - virtual void sourceNeeded(QString &fileName, IncludeType type); + virtual void sourceNeeded(QString &fileName, IncludeType type, + unsigned line); private: QPointer m_modelManager; @@ -176,7 +177,7 @@ void CppPreprocessor::setProjectFiles(const QStringList &files) { m_projectFiles = files; } void CppPreprocessor::run(QString &fileName) -{ sourceNeeded(fileName, IncludeGlobal); } +{ sourceNeeded(fileName, IncludeGlobal, /*line = */ 0); } void CppPreprocessor::operator()(QString &fileName) { run(fileName); } @@ -361,7 +362,8 @@ void CppPreprocessor::stopSkippingBlocks(unsigned offset) m_currentDoc->stopSkippingBlocks(offset); } -void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type) +void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type, + unsigned line) { if (fileName.isEmpty()) return; @@ -369,7 +371,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type) QByteArray contents = tryIncludeFile(fileName, type); if (m_currentDoc) { - m_currentDoc->addIncludeFile(fileName); + m_currentDoc->addIncludeFile(fileName, line); if (contents.isEmpty() && ! QFileInfo(fileName).isAbsolute()) { QString msg; msg += fileName; From 0343c8bf2d3ce4d8291bccea95abeb4bde465bfb Mon Sep 17 00:00:00 2001 From: con Date: Wed, 10 Dec 2008 17:24:06 +0100 Subject: [PATCH 23/23] Fixes: - Using Return in project tree on Mac to open files --- src/plugins/projectexplorer/projecttreewidget.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index 6285bb81dee..c2197a2dc7c 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -90,6 +90,20 @@ protected: if (event->reason() != Qt::PopupFocusReason) QTreeView::focusOutEvent(event); } + +#ifdef Q_OS_MAC + void keyPressEvent(QKeyEvent *event) + { + if ((event->key() == Qt::Key_Return + || event->key() == Qt::Key_Enter) + && event->modifiers() == 0 + && currentIndex().isValid()) { + emit activated(currentIndex()); + return; + } + QTreeView::keyPressEvent(event); + } +#endif }; /*!