From 2c80805165c19966e8242d50facc8ad6f2903c1f Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 14 Oct 2009 17:12:41 +0200 Subject: [PATCH 1/6] Fixed possible crash when searching the canonical symbol. --- src/libs/cplusplus/LookupContext.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index e04ee2a1b80..b3fe9f0ed02 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -581,6 +581,8 @@ Symbol *LookupContext::canonicalSymbol(Symbol *symbol, NamespaceBinding *globalNamespace) { Symbol *canonicalSymbol = LookupContext::canonicalSymbol(symbol); + if (! canonicalSymbol) + return 0; if (Identifier *symbolId = canonicalSymbol->identifier()) { if (symbolId && canonicalSymbol->type()->isFunctionType()) { From 28231f8f9cb487e023a1c13d2a3a4ac6044d3e71 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Wed, 14 Oct 2009 18:06:10 +0200 Subject: [PATCH 2/6] Add more MSVC specific intrinsics. --- src/plugins/projectexplorer/toolchain.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp index f966fa33085..dfac68d192e 100644 --- a/src/plugins/projectexplorer/toolchain.cpp +++ b/src/plugins/projectexplorer/toolchain.cpp @@ -336,7 +336,12 @@ QByteArray MSVCToolChain::predefinedMacros() "#define __WINNT__\n" "#define __WINNT\n" "#define WINNT\n" - "#define __int64 long long"; + "#define __int64 long long\n" + "#define __int32 long\n" + "#define __int16 short\n" + "#define __int8 char\n" + "#define __ptr32\n" + "#define __ptr64\n"; QString tmpFilePath; { From 2c17c756395120e5da5fc251edb6c737a2786534 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Tue, 6 Oct 2009 16:07:34 +1000 Subject: [PATCH 3/6] Windows CE SDK not always found. Creator fails to set up the build environment with MSVC 2008 and Windows Mobile SDK 6. This is caused by two problems: 1. The toolchain was being searched for in C:\Program Files\Microsoft Visual Studio 9.0\VC\VC The correct path is C:\Program Files\Microsoft Visual Studio 9.0\VC 2. Include statements in mkspecs were not being processed. All of the important variables are set in files included from the wincewm60{standard,professional}-msvc2008 mkspecs. --- src/plugins/projectexplorer/cesdkhandler.cpp | 41 ++++++++++++++------ src/plugins/projectexplorer/toolchain.cpp | 4 +- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/plugins/projectexplorer/cesdkhandler.cpp b/src/plugins/projectexplorer/cesdkhandler.cpp index 9f1a0325211..96c2b12df8d 100644 --- a/src/plugins/projectexplorer/cesdkhandler.cpp +++ b/src/plugins/projectexplorer/cesdkhandler.cpp @@ -56,11 +56,8 @@ CeSdkHandler::CeSdkHandler() { } -QString CeSdkHandler::platformName(const QString &qtpath) +static void readMkSpec(const QString &qtpath, QString *ceSdk, QString *ceArch) { - QString platformName; - QString CE_SDK; - QString CE_ARCH; QFile f(qtpath); if (f.exists() && f.open(QIODevice::ReadOnly)) { while (!f.atEnd()) { @@ -68,20 +65,41 @@ QString CeSdkHandler::platformName(const QString &qtpath) if (line.startsWith("CE_SDK")) { int index = line.indexOf('='); if (index >= 0) { - CE_SDK = line.mid(index + 1).trimmed(); + *ceSdk = line.mid(index + 1).trimmed(); } } else if (line.startsWith("CE_ARCH")) { int index = line.indexOf('='); if (index >= 0) { - CE_ARCH = line.mid(index + 1).trimmed(); + *ceArch = line.mid(index + 1).trimmed(); + } + } else if (line.startsWith("include(")) { + int startIndex = line.indexOf('('); + int endIndex = line.indexOf(')'); + if (startIndex >= 0 && endIndex >= 0) { + QString path = line.mid(startIndex + 1, endIndex - startIndex - 1).trimmed(); + + int index = qtpath.lastIndexOf('/'); + if (index >= 0) + readMkSpec(qtpath.left(index + 1) + path, ceSdk, ceArch); + else + readMkSpec(path, ceSdk, ceArch); } - } - if (!CE_SDK.isEmpty() && !CE_ARCH.isEmpty()) { - platformName = CE_SDK + " (" + CE_ARCH + ")"; - break; } } } +} + +QString CeSdkHandler::platformName(const QString &qtpath) +{ + QString platformName; + QString CE_SDK; + QString CE_ARCH; + + readMkSpec(qtpath, &CE_SDK, &CE_ARCH); + + if (!CE_SDK.isEmpty() && !CE_ARCH.isEmpty()) + platformName = CE_SDK + " (" + CE_ARCH + ")"; + return platformName; } @@ -91,8 +109,7 @@ bool CeSdkHandler::parse(const QString &vsdir) // and scan through all installed sdks... m_list.clear(); - VCInstallDir = vsdir + "/VC/"; - VSInstallDir = vsdir; + VCInstallDir = vsdir; QDir vStudioDir(VCInstallDir); if (!vStudioDir.cd("vcpackages")) diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp index dfac68d192e..9f680ac2742 100644 --- a/src/plugins/projectexplorer/toolchain.cpp +++ b/src/plugins/projectexplorer/toolchain.cpp @@ -518,10 +518,10 @@ void WinCEToolChain::addToEnvironment(ProjectExplorer::Environment &env) path += "/"; -// qDebug()<<"MSVC path"< Date: Thu, 15 Oct 2009 11:39:22 +0200 Subject: [PATCH 4/6] Improved lookup of class bindings. Unmark the visited nodes when searching bindings in class or namespace scopes. --- src/libs/cplusplus/CppBindings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/cplusplus/CppBindings.cpp b/src/libs/cplusplus/CppBindings.cpp index e011c862359..1eb11b31273 100644 --- a/src/libs/cplusplus/CppBindings.cpp +++ b/src/libs/cplusplus/CppBindings.cpp @@ -676,6 +676,8 @@ ClassBinding *Binder::findClassBinding(Name *name) if (classBinding) { if (ClassBinding *k = classBinding->findClassBinding(name, &processed)) return k; + + processed.clear(); } if (namespaceBinding) @@ -718,8 +720,6 @@ bool Binder::visit(UsingNamespaceDirective *u) bool Binder::visit(Class *classSymbol) { - Overview oo; - ClassBinding *binding = findOrCreateClassBinding(classSymbol); ClassBinding *previousClassBinding = switchClassBinding(binding); From 8ad31cba42fe5494ef20478a03a927492a0e23de Mon Sep 17 00:00:00 2001 From: con Date: Tue, 13 Oct 2009 14:57:30 +0200 Subject: [PATCH 5/6] Remove some unused code. --- src/app/main.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 362147991af..9ed1cf10dda 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -46,24 +46,6 @@ #include #include -#ifdef Q_OS_MAC -# include -# include - -// Helper function CoreFoundation -> Qt -static QString stringFromCFString(CFStringRef value) { - QString retVal; - CFIndex maxLength = 2 * CFStringGetLength(value) + 1/*zero term*/; // max UTF8 - char *cstring = new char[maxLength]; - if (CFStringGetCString(CFStringRef(value), cstring, maxLength, kCFStringEncodingUTF8)) { - retVal = QString::fromUtf8(cstring); - } - delete cstring; - return retVal; -} - -#endif - enum { OptionIndent = 4, DescriptionIndent = 24 }; static const char *appNameC = "Qt Creator"; From f92b1428f39a3128c0227d5802e2559a62adbcc2 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 15 Oct 2009 12:30:27 +0200 Subject: [PATCH 6/6] Fixed the refactoring engine. It was not working for files opened while indexing the project. --- src/plugins/cppeditor/cppeditor.cpp | 21 +++++++++++++++------ src/plugins/cppeditor/cppeditor.h | 9 ++++++--- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index a9f9ea95882..c3942e5794b 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -549,6 +549,7 @@ CPPEditor::CPPEditor(QWidget *parent) , m_inRename(false) , m_allowSkippingOfBlockEnd(false) { + m_initialized = false; qRegisterMetaType("SemanticInfo"); m_semanticHighlighter = new SemanticHighlighter(this); @@ -700,6 +701,13 @@ void CPPEditor::onDocumentUpdated(Document::Ptr doc) if (doc->fileName() != file()->fileName()) return; + if (! m_initialized) { + m_initialized = true; + + const SemanticHighlighter::Source source = currentSource(/*force = */ true); + m_semanticHighlighter->rehighlight(source); + } + m_overviewModel->rebuild(doc); OverviewTreeView *treeView = static_cast(m_methodCombo->view()); treeView->sync(); @@ -1885,7 +1893,7 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo) setExtraSelections(CodeSemanticsSelection, allSelections); } -SemanticHighlighter::Source CPPEditor::currentSource() +SemanticHighlighter::Source CPPEditor::currentSource(bool force) { int line = 0, column = 0; convertPosition(position(), &line, &column); @@ -1894,12 +1902,13 @@ SemanticHighlighter::Source CPPEditor::currentSource() const QString fileName = file()->fileName(); QString code; - if (m_lastSemanticInfo.revision != document()->revision()) + if (force || m_lastSemanticInfo.revision != document()->revision()) code = toPlainText(); // get the source code only when needed. const int revision = document()->revision(); - const SemanticHighlighter::Source source(snapshot, fileName, code, - line, column, revision); + SemanticHighlighter::Source source(snapshot, fileName, code, + line, column, revision); + source.force = force; return source; } @@ -1974,14 +1983,14 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source) Snapshot snapshot; Document::Ptr doc; - if (revision == source.revision) { + if (! source.force && revision == source.revision) { m_mutex.lock(); snapshot = m_lastSemanticInfo.snapshot; doc = m_lastSemanticInfo.doc; m_mutex.unlock(); } - if (!doc) { + if (! doc) { const QByteArray preprocessedCode = source.snapshot.preprocessedCode(source.code, source.fileName); snapshot = source.snapshot; diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index 68159ee9100..f3489d8b998 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -105,9 +105,10 @@ public: int line; int column; int revision; + bool force; Source() - : line(0), column(0), revision(0) + : line(0), column(0), revision(0), force(false) { } Source(const CPlusPlus::Snapshot &snapshot, @@ -117,7 +118,7 @@ public: int revision) : snapshot(snapshot), fileName(fileName), code(code), line(line), column(column), - revision(revision) + revision(revision), force(false) { } void clear() @@ -128,6 +129,7 @@ public: line = 0; column = 0; revision = 0; + force = false; } }; @@ -240,7 +242,7 @@ private: TextEditor::ITextEditor *openCppEditorAt(const QString &fileName, int line, int column = 0); - SemanticHighlighter::Source currentSource(); + SemanticHighlighter::Source currentSource(bool force = false); void highlightUses(const QList &uses, QList *selections); @@ -285,6 +287,7 @@ private: SemanticHighlighter *m_semanticHighlighter; SemanticInfo m_lastSemanticInfo; + bool m_initialized; };