From 97e7b7bbf9a90acb1970e629a526d146f22e2871 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Oct 2009 20:47:47 +0200 Subject: [PATCH 01/91] two more commands which are RunRequests these missed the handleExecContinue() callback, so they got missed last time. added both callback and flag, and some more glue to the gross isBogus hack. --- src/plugins/debugger/gdb/gdbengine.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 9d7383763cd..dff58fe30f9 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1616,7 +1616,8 @@ void GdbEngine::runToLineExec(const QString &fileName, int lineNumber) setTokenBarrier(); setState(InferiorRunningRequested); showStatusMessage(tr("Run to line %1 requested...").arg(lineNumber), 5000); - postCommand(_("-exec-until %1:%2").arg(fileName).arg(lineNumber)); + postCommand(_("-exec-until %1:%2").arg(fileName).arg(lineNumber), + RunRequest, CB(handleExecContinue)); } void GdbEngine::runToFunctionExec(const QString &functionName) @@ -2314,7 +2315,10 @@ void GdbEngine::handleStackListFrames(const GdbResponse &response) // Immediately leave bogus frames. if (targetFrame == -1 && isBogus) { - postCommand(_("-exec-finish")); + setTokenBarrier(); + setState(InferiorRunningRequested); + postCommand(_("-exec-finish"), RunRequest, CB(handleExecContinue)); + showStatusMessage(tr("Jumping out of bogus frame..."), 1000); return; } #endif From 09b170648259afe70d89ab9ef33a00040b790c1b Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Wed, 21 Oct 2009 10:46:15 +0200 Subject: [PATCH 02/91] cdb.pri: isEmpty() takes a variable, not a string --- src/plugins/debugger/cdb/cdb.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/debugger/cdb/cdb.pri b/src/plugins/debugger/cdb/cdb.pri index ca08a11bb61..34a89b7042a 100644 --- a/src/plugins/debugger/cdb/cdb.pri +++ b/src/plugins/debugger/cdb/cdb.pri @@ -5,7 +5,7 @@ win32 { contains(QMAKE_CXX, cl) { CDB_PATH=$$(CDB_PATH) -isEmpty($$CDB_PATH):CDB_PATH="$$(ProgramFiles)/Debugging Tools For Windows/sdk" +isEmpty(CDB_PATH):CDB_PATH="$$(ProgramFiles)/Debugging Tools For Windows/sdk" !exists($$CDB_PATH):CDB_PATH="$$(ProgramFiles)/Debugging Tools For Windows (x86)/sdk" !exists($$CDB_PATH):CDB_PATH="$$(ProgramFiles)/Debugging Tools For Windows (x64)/sdk" From 7d50aa29b809a2ba0e6b456255af3bbe5e275694 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 21 Oct 2009 11:11:28 +0200 Subject: [PATCH 03/91] work around -exec-until breakage on S60 gdb 6.4 --- src/plugins/debugger/gdb/gdbengine.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index dff58fe30f9..d6462e9db41 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1616,8 +1616,13 @@ void GdbEngine::runToLineExec(const QString &fileName, int lineNumber) setTokenBarrier(); setState(InferiorRunningRequested); showStatusMessage(tr("Run to line %1 requested...").arg(lineNumber), 5000); - postCommand(_("-exec-until %1:%2").arg(fileName).arg(lineNumber), - RunRequest, CB(handleExecContinue)); + if (m_gdbVersion < 60500) { // We just know that 6.4 on S60 is broken + postCommand(_("tbreak %1:%2").arg(fileName).arg(lineNumber)); + postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue)); + } else { + postCommand(_("-exec-until %1:%2").arg(fileName).arg(lineNumber), + RunRequest, CB(handleExecContinue)); + } } void GdbEngine::runToFunctionExec(const QString &functionName) From 1253c55d5609a96a8a0318ac102029f618578d08 Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 21 Oct 2009 13:45:49 +0200 Subject: [PATCH 04/91] Fix a race in CMakeProjectManager::createXml --- .../cmakeprojectmanager/cmakeopenprojectwizard.cpp | 3 ++- .../cmakeprojectmanager/cmakeprojectmanager.cpp | 12 +++++------- .../cmakeprojectmanager/cmakeprojectmanager.h | 11 ++++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp index 0939a1c43f3..f9526756e79 100644 --- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp @@ -435,9 +435,10 @@ void CMakeRunPage::runCMake() m_output->clear(); if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) { - m_cmakeProcess = cmakeManager->createXmlFile(arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory, env, generator); + m_cmakeProcess = new QProcess(); connect(m_cmakeProcess, SIGNAL(readyRead()), this, SLOT(cmakeReadyRead())); connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished())); + cmakeManager->createXmlFile(m_cmakeProcess, arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory, env, generator); } else { m_runCMake->setEnabled(true); m_argumentsLineEdit->setEnabled(true); diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index fbab5af5d8f..d0b683c8b38 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -99,7 +99,7 @@ bool CMakeManager::hasCodeBlocksMsvcGenerator() const // we probably want the process instead of this function // cmakeproject then could even run the cmake process in the background, adding the files afterwards // sounds like a plan -QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory, const ProjectExplorer::Environment &env, const QString &generator) +void CMakeManager::createXmlFile(QProcess *proc, const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory, const ProjectExplorer::Environment &env, const QString &generator) { // We create a cbp file, only if we didn't find a cbp file in the base directory // Yet that can still override cbp files in subdirectories @@ -111,14 +111,12 @@ QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QStrin // TODO we need to pass on the same paremeters as the cmakestep QString buildDirectoryPath = buildDirectory.absolutePath(); buildDirectory.mkpath(buildDirectoryPath); - QProcess *cmake = new QProcess; - cmake->setWorkingDirectory(buildDirectoryPath); - cmake->setProcessChannelMode(QProcess::MergedChannels); - cmake->setEnvironment(env.toStringList()); + proc->setWorkingDirectory(buildDirectoryPath); + proc->setProcessChannelMode(QProcess::MergedChannels); + proc->setEnvironment(env.toStringList()); const QString srcdir = buildDirectory.exists(QLatin1String("CMakeCache.txt")) ? QString(QLatin1Char('.')) : sourceDirectory; - cmake->start(cmakeExecutable(), QStringList() << srcdir << arguments << generator); - return cmake; + proc->start(cmakeExecutable(), QStringList() << srcdir << arguments << generator); } QString CMakeManager::findCbpFile(const QDir &directory) diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h index a33055235ab..2c8a3ee3fc0 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h @@ -63,11 +63,12 @@ public: void setCMakeExecutable(const QString &executable); - QProcess* createXmlFile(const QStringList &arguments, - const QString &sourceDirectory, - const QDir &buildDirectory, - const ProjectExplorer::Environment &env, - const QString &generator); + void createXmlFile(QProcess *process, + const QStringList &arguments, + const QString &sourceDirectory, + const QDir &buildDirectory, + const ProjectExplorer::Environment &env, + const QString &generator); bool hasCodeBlocksMsvcGenerator() const; static QString findCbpFile(const QDir &); From f4b95586c534d2be2103f5e20d24e8a01b33b723 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 14:56:42 +0200 Subject: [PATCH 05/91] Removed obsoleted code. --- tests/manual/cplusplus/main.cpp | 192 +-------------------- tests/manual/cplusplus/test-pretty-printer | 3 - tests/manual/cplusplus/test-rewriter | 3 - 3 files changed, 4 insertions(+), 194 deletions(-) delete mode 100755 tests/manual/cplusplus/test-pretty-printer delete mode 100755 tests/manual/cplusplus/test-rewriter diff --git a/tests/manual/cplusplus/main.cpp b/tests/manual/cplusplus/main.cpp index cc69cb1681b..1fcf76ce189 100644 --- a/tests/manual/cplusplus/main.cpp +++ b/tests/manual/cplusplus/main.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -52,171 +51,7 @@ #include #include -CPLUSPLUS_USE_NAMESPACE - -class Rewrite -{ - QMultiMap _insertBefore; - QMultiMap _insertAfter; - QSet _removed; - -public: - void remove(unsigned index) - { remove(index, index + 1); } - - void remove(unsigned first, unsigned last) - { - Q_ASSERT(first < last); - - for (; first != last; ++first) - _removed.insert(first); - } - - void insertTextBefore(unsigned index, const QByteArray &text) - { _insertBefore.insert(index, text); } - - void insertTextAfter(unsigned index, const QByteArray &text) - { _insertAfter.insert(index, text); } - - void rewrite(const TranslationUnit *unit, - const QByteArray &contents, - QByteArray *out) - { - _source = contents; - const char *source = contents.constData(); - unsigned previousTokenEndPosition = 0; - for (unsigned i = 0; i < unit->tokenCount(); ++i) { - const Token &tk = unit->tokenAt(i); - - if (previousTokenEndPosition != tk.begin()) { - Q_ASSERT(previousTokenEndPosition < tk.begin()); - out->append(source + previousTokenEndPosition, - tk.begin() - previousTokenEndPosition); - } - - QMultiMap::const_iterator it; - - it = _insertBefore.constFind(i); - for (; it != _insertBefore.constEnd() && it.key() == i; ++it) { - out->append(it.value()); - } - - if (! _removed.contains(i)) - out->append(source + tk.begin(), tk.f.length); - - it = _insertAfter.constFind(i); - for (; it != _insertAfter.constEnd() && it.key() == i; ++it) { - out->append(it.value()); - } - - previousTokenEndPosition = tk.end(); - } - } - -protected: - QByteArray _source; -}; - -class SimpleRefactor: protected ASTVisitor, Rewrite { -public: - SimpleRefactor(Control *control) - : ASTVisitor(control) - { } - - void operator()(const TranslationUnit *unit, - const QByteArray &source, - QByteArray *out) - { - accept(unit->ast()); - rewrite(unit, source, out); - } - -protected: - bool isEnumOrTypedefEnum(SpecifierAST *spec) { - if (! spec) - return false; - if (SimpleSpecifierAST *simpleSpec = spec->asSimpleSpecifier()) { - if (tokenKind(simpleSpec->specifier_token) == T_TYPEDEF) - return isEnumOrTypedefEnum(spec->next); - } - return spec->asEnumSpecifier() != 0; - } - virtual bool visit(SimpleDeclarationAST *ast) { - if (isEnumOrTypedefEnum(ast->decl_specifier_seq)) { - //remove(ast->firstToken(), ast->lastToken()); - insertTextBefore(ast->firstToken(), "/* #REF# removed "); - insertTextAfter(ast->lastToken() - 1, "*/"); - return true; - } - return true; - } - - virtual bool visit(AccessDeclarationAST *ast) - { - if (tokenKind(ast->access_specifier_token) == T_PRIVATE) { - // change visibility from `private' to `public'. - remove(ast->access_specifier_token); - insertTextAfter(ast->access_specifier_token, "public /* #REF# private->public */"); - } - return true; - } - - virtual bool visit(FunctionDefinitionAST *ast) - { - bool isInline = false; - for (SpecifierAST *spec = ast->decl_specifier_seq; spec; spec = spec->next) { - if (SimpleSpecifierAST *simpleSpec = spec->asSimpleSpecifier()) { - if (tokenKind(simpleSpec->specifier_token) == T_INLINE) { - isInline = true; - break; - } - } - } - - // force the `inline' specifier. - if (! isInline) - insertTextBefore(ast->firstToken(), "inline /* #REF# made inline */ "); - - return true; - } - - virtual bool visit(ClassSpecifierAST *ast) - { - // export/import the class using the macro MY_EXPORT. - if (ast->name) - insertTextBefore(ast->name->firstToken(), "MY_EXPORT "); - - // add QObject to the base clause. - if (ast->colon_token) - insertTextAfter(ast->colon_token, " public QObject,"); - else if (ast->lbrace_token) - insertTextBefore(ast->lbrace_token, ": public QObject "); - - // mark the class as Q_OBJECT. - if (ast->lbrace_token) - insertTextAfter(ast->lbrace_token, " Q_OBJECT\n"); - - for (DeclarationListAST *it = ast->member_specifiers; it; it = it->next) { - accept(it->declaration); - } - - return false; - } - - virtual bool visit(CppCastExpressionAST *ast) - { - // Replace the C++ cast expression (e.g. static_cast(a)) with - // the one generated by the pretty printer. - std::ostringstream o; - PrettyPrinter pp(control(), o); - pp(ast, _source); - remove(ast->firstToken(), ast->lastToken()); - const std::string str = o.str(); - insertTextBefore(ast->firstToken(), str.c_str()); - insertTextBefore(ast->firstToken(), "/* #REF# beautiful cast */ "); - return false; - } -}; +using namespace CPlusPlus; class CloneCG: protected ASTVisitor { @@ -513,15 +348,8 @@ int main(int argc, char *argv[]) const QString appName = args.first(); args.removeFirst(); - bool test_rewriter = false; - bool test_pretty_printer = false; - - foreach (QString arg, args) { - if (arg == QLatin1String("--test-rewriter")) - test_rewriter = true; - else if (arg == QLatin1String("--test-pretty-printer")) - test_pretty_printer = true; - else if (arg == QLatin1String("--help")) { + foreach (const QString &arg, args) { + if (arg == QLatin1String("--help")) { const QFileInfo appInfo(appName); const QByteArray appFileName = QFile::encodeName(appInfo.fileName()); @@ -530,6 +358,7 @@ int main(int argc, char *argv[]) " --test-rewriter Test the tree rewriter\n" " --test-pretty-printer Test the pretty printer\n", appFileName.constData()); + return EXIT_SUCCESS; } } @@ -558,18 +387,5 @@ int main(int argc, char *argv[]) sem.check(decl->declaration, globalNamespace->members()); } - // test the rewriter - if (test_rewriter) { - QByteArray out; - SimpleRefactor refactor(&control); - refactor(&unit, source, &out); - printf("%s\n", out.constData()); - } else if (test_pretty_printer) { - MemoryPool pool2; - TranslationUnitAST *other = unit.ast()->clone(&pool2)->asTranslationUnit(); - PrettyPrinter pp(&control, std::cout); - pp(other, source); - } - return EXIT_SUCCESS; } diff --git a/tests/manual/cplusplus/test-pretty-printer b/tests/manual/cplusplus/test-pretty-printer deleted file mode 100755 index 7403721300e..00000000000 --- a/tests/manual/cplusplus/test-pretty-printer +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -me=$(dirname $0) -${CPP-gcc} -xc++ -E -include $me/conf.c++ $* | $me/cplusplus0 --test-pretty-printer diff --git a/tests/manual/cplusplus/test-rewriter b/tests/manual/cplusplus/test-rewriter deleted file mode 100755 index c0494257c8f..00000000000 --- a/tests/manual/cplusplus/test-rewriter +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -me=$(dirname $0) -${CPP-gcc} -xc++ -E -include $me/conf.c++ $* | $me/cplusplus0 --test-rewriter From 671a1874ba99e5e8b0910a11156372137b9f09dd Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 15:00:10 +0200 Subject: [PATCH 06/91] Fixed the output generated by CloneCG and VisitCG. Removed CPLUSPLUS_BEGIN/END_NAMESPACE and replace CPLUSPLUS_USE_NAMESPACE with `using namespace CPlusPlus;' --- tests/manual/cplusplus/main.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/manual/cplusplus/main.cpp b/tests/manual/cplusplus/main.cpp index 1fcf76ce189..63efc8b985b 100644 --- a/tests/manual/cplusplus/main.cpp +++ b/tests/manual/cplusplus/main.cpp @@ -95,11 +95,9 @@ public: "#include \"AST.h\"\n" "#include \"ASTVisitor.h\"\n" "\n" - "CPLUSPLUS_BEGIN_NAMESPACE\n" << std::endl; + "using namespace CPlusPlus;\n" << std::endl; accept(ast); - - std::cout << "CPLUSPLUS_END_NAMESPACE" << std::endl; } protected: @@ -250,14 +248,12 @@ public: "\n" "#include \"AST.h\"\n" "\n" - "CPLUSPLUS_BEGIN_NAMESPACE\n" << std::endl; + "using namespace CPlusPlus;\n" << std::endl; SearchListNodes listNodes(control()); _listNodes = listNodes(ast); accept(ast); - - std::cout << "CPLUSPLUS_END_NAMESPACE" << std::endl; } protected: @@ -354,9 +350,7 @@ int main(int argc, char *argv[]) const QByteArray appFileName = QFile::encodeName(appInfo.fileName()); printf("Usage: %s [options]\n" - " --help Display this information\n" - " --test-rewriter Test the tree rewriter\n" - " --test-pretty-printer Test the pretty printer\n", + " --help Display this information\n", appFileName.constData()); return EXIT_SUCCESS; From 5e00b7695c791f7e505a794f1d3cfc6858ffb57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 21 Oct 2009 15:35:19 +0200 Subject: [PATCH 07/91] Fixed Ui_PasteBinComSettingsWidget memory leak --- src/plugins/cpaster/pastebindotcomsettings.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/cpaster/pastebindotcomsettings.cpp b/src/plugins/cpaster/pastebindotcomsettings.cpp index 6205facfdb8..3823524c0b7 100644 --- a/src/plugins/cpaster/pastebindotcomsettings.cpp +++ b/src/plugins/cpaster/pastebindotcomsettings.cpp @@ -65,11 +65,11 @@ QString PasteBinDotComSettings::trCategory() const QWidget *PasteBinDotComSettings::createPage(QWidget *parent) { - Ui_PasteBinComSettingsWidget* ui = new Ui_PasteBinComSettingsWidget; + Ui_PasteBinComSettingsWidget ui; QWidget *w = new QWidget(parent); - ui->setupUi(w); - ui->lineEdit->setText(hostPrefix()); - connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(serverChanged(QString))); + ui.setupUi(w); + ui.lineEdit->setText(hostPrefix()); + connect(ui.lineEdit, SIGNAL(textChanged(QString)), this, SLOT(serverChanged(QString))); return w; } From 5b7a19425b7ff8233b4b727e195fe594c81fd7e5 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 16:18:34 +0200 Subject: [PATCH 08/91] Use bit vectors to store the preprocessor's state. --- src/libs/cplusplus/pp-engine.cpp | 2 ++ src/libs/cplusplus/pp-engine.h | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 5ce662b9981..1a6094601d7 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -545,6 +545,8 @@ Preprocessor::Preprocessor(Client *client, Environment *env) : client(client), env(env), _expand(env), + _skipping(MAX_LEVEL), + _true_test(MAX_LEVEL), _result(0), _markGeneratedTokens(false), _expandMacros(true) diff --git a/src/libs/cplusplus/pp-engine.h b/src/libs/cplusplus/pp-engine.h index 5203f7db0ea..73594726403 100644 --- a/src/libs/cplusplus/pp-engine.h +++ b/src/libs/cplusplus/pp-engine.h @@ -54,6 +54,7 @@ #include #include +#include namespace CPlusPlus { @@ -177,8 +178,8 @@ private: Environment *env; MacroExpander _expand; - bool _skipping[MAX_LEVEL]; // ### move in state - bool _true_test[MAX_LEVEL]; // ### move in state + QBitArray _skipping; // ### move in state + QBitArray _true_test; // ### move in state int iflevel; // ### move in state QList _savedStates; From 146ec6248deafdc02f1767e02097df24f97421be Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 16:20:45 +0200 Subject: [PATCH 09/91] Renamed Preprocessor::_true_test --- src/libs/cplusplus/pp-engine.cpp | 18 +++++++++--------- src/libs/cplusplus/pp-engine.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 1a6094601d7..d84722c3fd6 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -546,7 +546,7 @@ Preprocessor::Preprocessor(Client *client, Environment *env) env(env), _expand(env), _skipping(MAX_LEVEL), - _true_test(MAX_LEVEL), + _trueTest(MAX_LEVEL), _result(0), _markGeneratedTokens(false), _expandMacros(true) @@ -1270,7 +1270,7 @@ void Preprocessor::processIf(TokenIterator firstToken, TokenIterator lastToken) tokens.constEnd() - 1, condition); - _true_test[iflevel] = ! result.is_zero (); + _trueTest[iflevel] = ! result.is_zero (); _skipping[iflevel] = result.is_zero (); } } @@ -1284,7 +1284,7 @@ void Preprocessor::processElse(TokenIterator firstToken, TokenIterator lastToken } else if (iflevel > 0 && _skipping[iflevel - 1]) { _skipping[iflevel] = true; } else { - _skipping[iflevel] = _true_test[iflevel]; + _skipping[iflevel] = _trueTest[iflevel]; } } @@ -1298,7 +1298,7 @@ void Preprocessor::processElif(TokenIterator firstToken, TokenIterator lastToken // std::cerr << "*** WARNING: " << __FILE__ << __LINE__ << std::endl; } else if (iflevel == 0 && !skipping()) { // std::cerr << "*** WARNING #else without #if" << std::endl; - } else if (!_true_test[iflevel] && !_skipping[iflevel - 1]) { + } else if (!_trueTest[iflevel] && !_skipping[iflevel - 1]) { const char *first = startOfToken(*tk); const char *last = startOfToken(*lastToken); @@ -1314,7 +1314,7 @@ void Preprocessor::processElif(TokenIterator firstToken, TokenIterator lastToken tokens.constEnd() - 1, condition); - _true_test[iflevel] = ! result.is_zero (); + _trueTest[iflevel] = ! result.is_zero (); _skipping[iflevel] = result.is_zero (); } else { _skipping[iflevel] = true; @@ -1327,7 +1327,7 @@ void Preprocessor::processEndif(TokenIterator, TokenIterator) // std::cerr << "*** WARNING #endif without #if" << std::endl; } else { _skipping[iflevel] = false; - _true_test[iflevel] = false; + _trueTest[iflevel] = false; --iflevel; } @@ -1349,7 +1349,7 @@ void Preprocessor::processIfdef(bool checkUndefined, if (checkUndefined) value = ! value; - _true_test[iflevel] = value; + _trueTest[iflevel] = value; _skipping [iflevel] = ! value; } } @@ -1375,7 +1375,7 @@ void Preprocessor::resetIfLevel () { iflevel = 0; _skipping[iflevel] = false; - _true_test[iflevel] = false; + _trueTest[iflevel] = false; } Preprocessor::PP_DIRECTIVE_TYPE Preprocessor::classifyDirective(const QByteArray &directive) const @@ -1433,7 +1433,7 @@ bool Preprocessor::testIfLevel() { const bool result = !_skipping[iflevel++]; _skipping[iflevel] = _skipping[iflevel - 1]; - _true_test[iflevel] = false; + _trueTest[iflevel] = false; return result; } diff --git a/src/libs/cplusplus/pp-engine.h b/src/libs/cplusplus/pp-engine.h index 73594726403..596a223e058 100644 --- a/src/libs/cplusplus/pp-engine.h +++ b/src/libs/cplusplus/pp-engine.h @@ -179,7 +179,7 @@ private: MacroExpander _expand; QBitArray _skipping; // ### move in state - QBitArray _true_test; // ### move in state + QBitArray _trueTest; // ### move in state int iflevel; // ### move in state QList _savedStates; From 8bea428020088598a003b99fecb4ef942dc44db3 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 20 Oct 2009 18:15:03 +0200 Subject: [PATCH 10/91] debugger: work on debugger autotests --- tests/auto/debugger/tst_gdb.cpp | 368 ++++++++++++++++++++------------ 1 file changed, 231 insertions(+), 137 deletions(-) diff --git a/tests/auto/debugger/tst_gdb.cpp b/tests/auto/debugger/tst_gdb.cpp index 433b11f8192..9e2f62d73ec 100644 --- a/tests/auto/debugger/tst_gdb.cpp +++ b/tests/auto/debugger/tst_gdb.cpp @@ -1,4 +1,6 @@ +//bool checkUninitialized = true; +bool checkUninitialized = false; //#define DO_DEBUG 1 #include @@ -136,7 +138,13 @@ signals: private slots: void dumpMisc(); + void dumpQByteArray(); + void dumpQChar(); + void dumpQList_char(); void dumpQList_int(); + void dumpQList_QString(); + void dumpQList_QString3(); + void dumpQList_Int3(); void dumpQString(); void dumpQStringList(); @@ -145,8 +153,6 @@ public slots: #if 0 void dumpQAbstractItemAndModelIndex(); void dumpQAbstractItemModel(); - void dumpQByteArray(); - void dumpQChar(); void dumpQDateTime(); void dumpQDir(); void dumpQFile(); @@ -156,10 +162,6 @@ public slots: void dumpQImage(); void dumpQImageData(); void dumpQLinkedList(); - void dumpQList_char(); - void dumpQList_QString(); - void dumpQList_QString3(); - void dumpQList_Int3(); void dumpQLocale(); void dumpQMap(); void dumpQMapNode(); @@ -649,81 +651,93 @@ void tst_Gdb::dumpQAbstractItemModel() model2.appendRow(QList() << &item3 << &item4); dumpQAbstractItemModelHelper(model); } +#endif + +void dumpQByteArrayTest() +{ + /* A */ QByteArray ba; // Empty object. + /* B */ ba.append('a'); // One element. + /* C */ ba.append('b'); // Two elements. + /* D */ ba = QByteArray(101, 'a'); // > 100 elements. + /* E */ ba = QByteArray("abc\a\n\r\e\'\"?"); // Mixed. + /* F */ (void) 0; +} void tst_Gdb::dumpQByteArray() { - // Case 1: Empty object. - QByteArray ba; - testDumper("value='',valueencoded='1',type='"NS"QByteArray',numchild='0'," - "childtype='char',childnumchild='0',children=[]", - &ba, NS"QByteArray", true); - - // Case 2: One element. - ba.append('a'); - testDumper("value='YQ==',valueencoded='1',type='"NS"QByteArray',numchild='1'," - "childtype='char',childnumchild='0',children=[{value='61 (97 'a')'}]", - &ba, NS"QByteArray", true); - - // Case 3: Two elements. - ba.append('b'); - testDumper("value='YWI=',valueencoded='1',type='"NS"QByteArray',numchild='2'," - "childtype='char',childnumchild='0',children=[" - "{value='61 (97 'a')'},{value='62 (98 'b')'}]", - &ba, NS"QByteArray", true); - - // Case 4: > 100 elements. - ba = QByteArray(101, 'a'); - QByteArray children; - for (int i = 0; i < 101; i++) - children.append("{value='61 (97 'a')'},"); - children.chop(1); - testDumper(QByteArray("value='YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh" - "YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh" - "YWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== '," - "valueencoded='1',type='"NS"QByteArray',numchild='101'," - "childtype='char',childnumchild='0',children=[%]") << children, - &ba, NS"QByteArray", true); - - // Case 5: Regular and special characters and the replacement character. - ba = QByteArray("abc\a\n\r\e\'\"?"); - testDumper("value='YWJjBwoNGyciPw==',valueencoded='1',type='"NS"QByteArray'," - "numchild='10',childtype='char',childnumchild='0',children=[" - "{value='61 (97 'a')'},{value='62 (98 'b')'}," - "{value='63 (99 'c')'},{value='07 (7 '?')'}," - "{value='0a (10 '?')'},{value='0d (13 '?')'}," - "{value='1b (27 '?')'},{value='27 (39 '?')'}," - "{value='22 (34 '?')'},{value='3f (63 '?')'}]", - &ba, NS"QByteArray", true); + prepare("dumpQByteArrayTest"); + if (checkUninitialized) + run("A","{iname='local.ba',addr='-',name='ba',type='"NS"QByteArray'," + "value='',numchild='0'}"); + next(); + run("B","{iname='local.ba',addr='-',name='ba',type='"NS"QByteArray'," + "valueencoded='6',value='',numchild='0'}"); + next(); + run("C","{iname='local.ba',addr='-',name='ba',type='"NS"QByteArray'," + "valueencoded='6',value='61',numchild='1'}"); + next(); + run("D","{iname='local.ba',addr='-',name='ba',type='"NS"QByteArray'," + "valueencoded='6',value='6162',numchild='2'}"); + next(); + run("E","{iname='local.ba',addr='-',name='ba',type='"NS"QByteArray'," + "valueencoded='6',value='616161616161616161616161616161616161" + "616161616161616161616161616161616161616161616161616161616161" + "616161616161616161616161616161616161616161616161616161616161" + "6161616161616161616161616161616161616161616161',numchild='101'}"); + next(); + run("F","{iname='local.ba',addr='-',name='ba',type='"NS"QByteArray'," + "valueencoded='6',value='616263070a0d1b27223f',numchild='10'}"); + run("F","{iname='local.ba',addr='-',name='ba',type='"NS"QByteArray'," + "valueencoded='6',value='616263070a0d1b27223f',numchild='10'," + "childtype='char',childnumchild='0'," + "children=[{value='97 'a''},{value='98 'b''}," + "{value='99 'c''},{value='7 '\\\\a''}," + "{value='10 '\\\\n''},{value='13 '\\\\r''}," + "{value='27 '\\\\033''},{value='39 '\\\\'''}," + "{value='34 ''''},{value='63 '?''}]}", + "local.ba"); } +void dumpQCharTest() +{ + /* A */ QChar c('X'); // Printable ASCII character. + /* B */ c = QChar(0x600); // Printable non-ASCII character. + /* C */ c = QChar::fromAscii('\a'); // Non-printable ASCII character. + /* D */ c = QChar(0x9f); // Non-printable non-ASCII character. + /* E */ c = QChar::fromAscii('?'); // The replacement character. + /* F */ (void) 0; } + void tst_Gdb::dumpQChar() { + prepare("dumpQCharTest"); + next(); + // Case 1: Printable ASCII character. - QChar c('X'); - testDumper("value=''X', ucs=88',numchild='0'", - &c, NS"QChar", false); + run("B","{iname='local.c',addr='-',name='c',type='"NS"QChar'," + "value=''X', ucs=88',numchild='0'}"); + next(); // Case 2: Printable non-ASCII character. - c = QChar(0x600); - testDumper("value=''?', ucs=1536',numchild='0'", - &c, NS"QChar", false); + run("C","{iname='local.c',addr='-',name='c',type='"NS"QChar'," + "value=''?', ucs=1536',numchild='0'}"); + next(); // Case 3: Non-printable ASCII character. - c = QChar::fromAscii('\a'); - testDumper("value=''?', ucs=7',numchild='0'", - &c, NS"QChar", false); + run("D","{iname='local.c',addr='-',name='c',type='"NS"QChar'," + "value=''?', ucs=7',numchild='0'}"); + next(); // Case 4: Non-printable non-ASCII character. - c = QChar(0x9f); - testDumper("value=''?', ucs=159',numchild='0'", - &c, NS"QChar", false); + run("E","{iname='local.c',addr='-',name='c',type='"NS"QChar'," + "value=''?', ucs=159',numchild='0'}"); + next(); // Case 5: Printable ASCII Character that looks like the replacement character. - c = QChar::fromAscii('?'); - testDumper("value=''?', ucs=63',numchild='0'", - &c, NS"QChar", false); + run("F","{iname='local.c',addr='-',name='c',type='"NS"QChar'," + "value=''?', ucs=63',numchild='0'}"); } +#if 0 void tst_Gdb::dumpQDateTimeHelper(const QDateTime &d) { QByteArray value; @@ -1160,36 +1174,6 @@ void tst_Gdb::dumpQLinkedList() } #endif -void tst_Gdb::dumpQList_Int3() -{ - QList i3list; - testDumper("value='<0 items>',valuedisabled='true',numchild='0'," - "internal='0',children=[]", - &i3list, NS"QList", true, "Int3"); - i3list.append(Int3()); - i3list.append(Int3()); - testDumper("value='<2 items>',valuedisabled='true',numchild='2'," - "internal='0',childtype='Int3',children=[" - "{addr='" + str(&i3list.at(0)) + "'}," - "{addr='" + str(&i3list.at(1)) + "'}]", - &i3list, NS"QList", true, "Int3"); -} - -void tst_Gdb::dumpQList_QString3() -{ - QList s3list; - testDumper("value='<0 items>',valuedisabled='true',numchild='0'," - "internal='0',children=[]", - &s3list, NS"QList", true, "QString3"); - s3list.append(QString3()); - s3list.append(QString3()); - testDumper("value='<2 items>',valuedisabled='true',numchild='2'," - "internal='0',childtype='QString3',children=[" - "{addr='" + str(&s3list.at(0)) + "'}," - "{addr='" + str(&s3list.at(1)) + "'}]", - &s3list, NS"QList", true, "QString3"); -} - void tst_Gdb::dumpQLocaleHelper(QLocale &loc) { QByteArray expected = QByteArray("value='%',type='$T',numchild='8'," @@ -2162,14 +2146,30 @@ void Thread::readStandardOutput() // "^error,msg="The program being debugged stopped ..." // Extract the "2321" from this static QByteArray lastText; - if (ba.startsWith("~")) + if (ba.startsWith("~")) { lastText = ba; + if (ba.size() > 8 + && (ba.at(2) < 'a' || ba.at(2) > 'z') + && (ba.at(2) < '0' || ba.at(2) > '9') + && !ba.startsWith("~\"Breakpoint ") + && !ba.startsWith("~\" at ") + && !ba.startsWith("~\" locals=") + && !ba.startsWith("~\"XXX:")) { + QByteArray ba1 = ba.mid(2, ba.size() - 6); + if (ba1.startsWith(" File ")) + ba1 = ba1.replace(2, ba1.indexOf(','), ""); + qWarning() << "OUT: " << ba1; + } + } if (ba.startsWith("&\"The program being debugged")) { int pos1 = 2; int pos2 = lastText.indexOf("\\", pos1); m_line = lastText.mid(pos1, pos2 - pos1).toInt(); DEBUG(" LINE 2: " << m_line); } + if (ba.startsWith("^error,msg=")) { + qWarning() << "ERROR: " << ba.mid(1, ba.size() - 3); + } if (ba.startsWith("~\"XXX: ")) { QByteArray ba1 = ba.mid(7, ba.size() - 11); @@ -2249,6 +2249,7 @@ void tst_Gdb::run(const QByteArray &label, const QByteArray &expected0, const QByteArray &expanded, bool fancy) { //qDebug() << "\nABOUT TO RUN TEST: " << expanded; + qWarning() << label << "..."; writeToGdb("bb " + QByteArray::number(int(fancy)) + " " + expanded); m_mutex.lock(); m_waitCondition.wait(&m_mutex); @@ -2275,6 +2276,8 @@ void tst_Gdb::run(const QByteArray &label, const QByteArray &expected0, if (l1.at(i) != l2.at(i) && !l2.at(i).endsWith("'-'")) ok = false; } + } else { + qWarning() << "!= size: " << l1.size() << l2.size(); } if (!ok) { @@ -2299,7 +2302,7 @@ void tst_Gdb::run(const QByteArray &label, const QByteArray &expected0, qWarning() << "RECEIVED: " << received; } QCOMPARE(ok, true); - qWarning() << "LINE: " << line << "ACT/EXP" << m_function + '@' + label; + //qWarning() << "LINE: " << line << "ACT/EXP" << m_function + '@' + label; //QCOMPARE(actual____, expected); @@ -2350,53 +2353,135 @@ void tst_Gdb::dumpQList_int() next(); run("C","{iname='local.ilist',addr='-',name='ilist'," "type='"NS"QList',value='<1 items>',numchild='1'}"); - //run("C","{iname='local.ilist',addr='-',name='ilist'," - // "type='"NS"QList',value='<1 items>',numchild='1'," - // "childtype='int',childnumchild='0',children=[" - // "{value='1'}]}", "local.ilist"); -/* + run("C","{iname='local.ilist',addr='-',name='ilist'," + "type='"NS"QList',value='<1 items>',numchild='1'," + "childtype='int',childnumchild='0',children=[" + "{value='1'}]}", "local.ilist"); next(); run("D","{iname='local.ilist',addr='-',name='ilist'," - "type='"NS"QList',value='<2 items>',numchild='2'," - "childtype='int',childnumchild='0'}"); + "type='"NS"QList',value='<2 items>',numchild='2'}"); run("D","{iname='local.ilist',addr='-',name='ilist'," "type='"NS"QList',value='<2 items>',numchild='2'," - "childtype='int',childnumchild='0',children=[" - "{addr='-',value='1'},{addr='-',value='2'}]}", "local.ilist"); -*/ + "childtype='int',childnumchild='0',children=[" + "{value='1'},{value='2'}]}", "local.ilist"); +} + +void dumpQList_char() +{ + /* A */ QList ilist; + /* B */ ilist.append('a'); + /* C */ (void) 0; } -/* void tst_Gdb::dumpQList_char() { - QList clist; - testDumper("value='<0 items>',valuedisabled='true',numchild='0'," - "internal='1',children=[]", - &clist, NS"QList", true, "char"); - clist.append('a'); - clist.append('b'); - testDumper("value='<2 items>',valuedisabled='true',numchild='2'," - "internal='1',childtype='char',childnumchild='0',children=[" - "{addr='" + str(&clist.at(0)) + "',value=''a', ascii=97'}," - "{addr='" + str(&clist.at(1)) + "',value=''b', ascii=98'}]", - &clist, NS"QList", true, "char"); + prepare("dumpQList_char"); + if (checkUninitialized) + run("A","{iname='local.ilist',addr='-',name='ilist'," + "type='"NS"QList',value='',numchild='0'}"); + next(); + run("B","{iname='local.ilist',addr='-',name='ilist'," + "type='"NS"QList',value='<0 items>',numchild='0'}"); + next(); + run("C","{iname='local.ilist',addr='-',name='ilist'," + "type='"NS"QList',value='<1 items>',numchild='1'}"); + run("C","{iname='local.ilist',addr='-',name='ilist'," + "type='"NS"QList',value='<1 items>',numchild='1'," + "childtype='char',childnumchild='0',children=[" + "{value='97 'a''}]}", "local.ilist"); +} + +void dumpQList_QString() +{ + /* A */ QList list; + /* B */ list.append("Hallo"); + /* C */ (void) 0; } void tst_Gdb::dumpQList_QString() { - QList slist; - testDumper("value='<0 items>',valuedisabled='true',numchild='0'," - "internal='1',children=[]", - &slist, NS"QList", true, NS"QString"); - slist.append("a"); - slist.append("b"); - testDumper("value='<2 items>',valuedisabled='true',numchild='2'," - "internal='1',childtype='"NS"QString',childnumchild='0',children=[" - "{addr='" + str(&slist.at(0)) + "',value='YQA=',valueencoded='2'}," - "{addr='" + str(&slist.at(1)) + "',value='YgA=',valueencoded='2'}]", - &slist, NS"QList", true, NS"QString"); + prepare("dumpQList_QString"); + if (0 && checkUninitialized) + run("A","{iname='local.list',addr='-',name='list'," + "type='"NS"QList<"NS"QString>',value='',numchild='0'}"); + next(); + run("B","{iname='local.list',addr='-',name='list'," + "type='"NS"QList<"NS"QString>',value='<0 items>',numchild='0'}"); + next(); + run("C","{iname='local.list',addr='-',name='list'," + "type='"NS"QList<"NS"QString>',value='<1 items>',numchild='1'}"); + run("C","{iname='local.list',addr='-',name='list'," + "type='"NS"QList<"NS"QString>',value='<1 items>',numchild='1'," + "childtype='"NS"QString',childnumchild='0',children=[" + "{valueencoded='7',value='480061006c006c006f00'}]}", "local.list"); +} + +void dumpQList_QString3() +{ + /* A */ QList list; + /* B */ list.append(QString3()); + /* C */ (void) 0; +} + +void tst_Gdb::dumpQList_QString3() +{ + prepare("dumpQList_QString3"); + if (checkUninitialized) + run("A","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='',numchild='0'}"); + next(); + run("B","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<0 items>',numchild='0'}"); + next(); + run("C","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<1 items>',numchild='1'}"); + run("C","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<1 items>',numchild='1'," + "childtype='QString3',children=[" + "{value='{...}',numchild='3'}]}", "local.list"); + run("C","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<1 items>',numchild='1'," + "childtype='QString3',children=[{value='{...}',numchild='3',children=[" + "{iname='local.list.0.s1',name='s1',type='"NS"QString'," + "valueencoded='7',value='6100',numchild='0'}," + "{iname='local.list.0.s2',name='s2',type='"NS"QString'," + "valueencoded='7',value='6200',numchild='0'}," + "{iname='local.list.0.s3',name='s3',type='"NS"QString'," + "valueencoded='7',value='6300',numchild='0'}]}]}", + "local.list,local.list.0"); +} + +void dumpQList_Int3() +{ + /* A */ QList list; + /* B */ list.append(Int3()); + /* C */ (void) 0; +} + +void tst_Gdb::dumpQList_Int3() +{ + prepare("dumpQList_Int3"); + if (checkUninitialized) + run("A","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='',numchild='0'}"); + next(); + run("B","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<0 items>',numchild='0'}"); + next(); + run("C","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<1 items>',numchild='1'}"); + run("C","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<1 items>',numchild='1'," + "childtype='Int3',children=[{value='{...}',numchild='3'}]}", + "local.list"); + run("C","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<1 items>',numchild='1'," + "childtype='Int3',children=[{value='{...}',numchild='3',children=[" + "{iname='local.list.0.i1',name='i1',type='int',value='42',numchild='0'}," + "{iname='local.list.0.i2',name='i2',type='int',value='43',numchild='0'}," + "{iname='local.list.0.i3',name='i3',type='int',value='44',numchild='0'}]}]}", + "local.list,local.list.0"); } -*/ void dumpMisc() { @@ -2427,17 +2512,26 @@ void dumpQStringTest() void tst_Gdb::dumpQString() { prepare("dumpQStringTest"); - run("A","{iname='local.s',addr='-',name='s',type='"NS"QString'," - "value='',numchild='0'}"); + if (checkUninitialized) + run("A","{iname='local.s',addr='-',name='s',type='"NS"QString'," + "value='',numchild='0'}"); next(); run("B","{iname='local.s',addr='-',name='s',type='"NS"QString'," "valueencoded='7',value='',numchild='0'}", "local.s"); - // Plain C: + // Plain C style dumping: run("B","{iname='local.s',addr='-',name='s',type='"NS"QString'," "value='{...}',numchild='5'}", "", 0); run("B","{iname='local.s',addr='-',name='s',type='"NS"QString'," - "value='{...}',numchild='5',children=[]}", "local.s", 0); -return; + "value='{...}',numchild='5',children=[" + "{iname='local.s.d',name='d',type='"NS"QString::Data *'," + "value='-',numchild='1'}]}", "local.s", 0); + run("B","{iname='local.s',addr='-',name='s',type='"NS"QString'," + "value='{...}',numchild='5'," + "children=[{iname='local.s.d',name='d'," + "type='"NS"QString::Data *',value='-',numchild='1'," + "children=[{iname='local.s.d.*',name='*d'," + "type='"NS"QString::Data',value='{...}',numchild='11'}]}]}", + "local.s,local.s.d", 0); next(); run("C","{iname='local.s',addr='-',name='s',type='"NS"QString'," "valueencoded='7',value='680061006c006c006f00',numchild='0'}"); @@ -2457,8 +2551,9 @@ void dumpQStringListTest() void tst_Gdb::dumpQStringList() { prepare("dumpQStringListTest"); - //run("A","{iname='local.s',addr='-',name='s',type='"NS"QStringList'," - // "value='',numchild='0'}"); + if (checkUninitialized) + run("A","{iname='local.s',addr='-',name='s',type='"NS"QStringList'," + "value='',numchild='0'}"); next(); run("B","{iname='local.s',addr='-',name='s',type='"NS"QStringList'," "value='<0 items>',numchild='0'}"); @@ -2472,7 +2567,6 @@ void tst_Gdb::dumpQStringList() "childnumchild='0',children=[{valueencoded='7'," "value='680065006c006c006f00'}]}", "local.s"); -return; next(); run("D","{iname='local.s',addr='-',name='s',type='"NS"QStringList'," "value='<2 items>',numchild='2'}"); From a06b3c15c892c7de03bb815473ac18f39f701b03 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 21 Oct 2009 14:42:02 +0200 Subject: [PATCH 11/91] debugger: remove two unused variables --- share/qtcreator/gdbmacros/gdbmacros.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index b5283d42e3f..ae677bcdb69 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -3120,7 +3120,6 @@ static void qDumpStdMapHelper(QDumper &d) const char *valueType = d.templateParameters[1]; const void *p = d.data; qCheckAccess(p); - p = deref(p); const int nn = map.size(); if (nn < 0) @@ -3236,7 +3235,6 @@ static void qDumpStdSetHelper(QDumper &d) const DummyType &set = *reinterpret_cast(d.data); const void *p = d.data; qCheckAccess(p); - p = deref(p); const int nn = set.size(); if (nn < 0) From 338f945ca183435aef81243daf14e27d26328220 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 21 Oct 2009 16:41:18 +0200 Subject: [PATCH 12/91] debugger: more autotests --- src/plugins/debugger/gdb/gdbengine.cpp | 2 +- src/plugins/debugger/watchutils.cpp | 7 ++ tests/auto/debugger/tst_gdb.cpp | 88 +++++++++++++++++++------- 3 files changed, 73 insertions(+), 24 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index d6462e9db41..67bb37d41c2 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -3453,7 +3453,7 @@ void GdbEngine::handleStackFrame1(const GdbResponse &response) //qDebug() << "FIRST CHUNK: " << out; m_firstChunk = out; } else { - QTC_ASSERT(false, /**/); + QTC_ASSERT(false, qDebug() << response.toString()); } } diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index 55e03207bdb..3e18cd43f7d 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -636,6 +636,12 @@ QString decodeData(const QByteArray &ba, int encoding) case 5: { // base64 encoded 8 bit data, without quotes (see 1) return quoteUnprintableLatin1(QByteArray::fromBase64(ba)); } + case 6: { // %02x encoded 8 bit data + const QChar doubleQuote(QLatin1Char('"')); + const QByteArray decodedBa = QByteArray::fromHex(ba); + //qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n"; + return doubleQuote + QString::fromLatin1(decodedBa) + doubleQuote; + } case 7: { // %04x encoded 16 bit data const QChar doubleQuote(QLatin1Char('"')); const QByteArray decodedBa = QByteArray::fromHex(ba); @@ -644,6 +650,7 @@ QString decodeData(const QByteArray &ba, int encoding) (decodedBa.data()), decodedBa.size() / 2) + doubleQuote; } } + qDebug() << "ENCODING ERROR: " << encoding; return QCoreApplication::translate("Debugger", ""); } diff --git a/tests/auto/debugger/tst_gdb.cpp b/tests/auto/debugger/tst_gdb.cpp index 9e2f62d73ec..bff9d166017 100644 --- a/tests/auto/debugger/tst_gdb.cpp +++ b/tests/auto/debugger/tst_gdb.cpp @@ -140,6 +140,7 @@ private slots: void dumpMisc(); void dumpQByteArray(); void dumpQChar(); + void dumpQList_char_star(); void dumpQList_char(); void dumpQList_int(); void dumpQList_QString(); @@ -2168,7 +2169,8 @@ void Thread::readStandardOutput() DEBUG(" LINE 2: " << m_line); } if (ba.startsWith("^error,msg=")) { - qWarning() << "ERROR: " << ba.mid(1, ba.size() - 3); + if (!ba.startsWith("^error,msg=\"The program being debugged stopped")) + qWarning() << "ERROR: " << ba.mid(1, ba.size() - 3); } if (ba.startsWith("~\"XXX: ")) { @@ -2237,7 +2239,6 @@ tst_Gdb::tst_Gdb() } } - void tst_Gdb::prepare(const QByteArray &function) { m_function = function; @@ -2245,6 +2246,11 @@ void tst_Gdb::prepare(const QByteArray &function) writeToGdb("call " + function + "()"); } +static bool isJoker(const QByteArray &ba) +{ + return ba.endsWith("'-'") || ba.contains("'-'}"); +} + void tst_Gdb::run(const QByteArray &label, const QByteArray &expected0, const QByteArray &expanded, bool fancy) { @@ -2273,7 +2279,7 @@ void tst_Gdb::run(const QByteArray &label, const QByteArray &expected0, if (ok) { for (int i = 0 ; i < l1.size(); ++i) { // Use "-" as joker. - if (l1.at(i) != l2.at(i) && !l2.at(i).endsWith("'-'")) + if (l1.at(i) != l2.at(i) && !isJoker(l2.at(i))) ok = false; } } else { @@ -2283,7 +2289,7 @@ void tst_Gdb::run(const QByteArray &label, const QByteArray &expected0, if (!ok) { int i = 0; for ( ; i < l1.size() && i < l2.size(); ++i) { - if (l1.at(i) == l2.at(i) || l2.at(i).endsWith("'-'")) { + if (l1.at(i) == l2.at(i) || isJoker(l2.at(i))) { qWarning() << "== " << l1.at(i); } else { //qWarning() << "!= " << l1.at(i).right(30) << l2.at(i).right(30); @@ -2336,40 +2342,41 @@ void tst_Gdb::cleanupTestCase() void dumpQList_int() { - /* A */ QList ilist; - /* B */ ilist.append(1); - /* C */ ilist.append(2); + /* A */ QList list; + /* B */ list.append(1); + /* C */ list.append(2); /* D */ (void) 0; } void tst_Gdb::dumpQList_int() { prepare("dumpQList_int"); - run("A","{iname='local.ilist',addr='-',name='ilist'," - "type='"NS"QList',value='',numchild='0'}"); + if (checkUninitialized) + run("A","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='',numchild='0'}"); next(); - run("B","{iname='local.ilist',addr='-',name='ilist'," + run("B","{iname='local.list',addr='-',name='list'," "type='"NS"QList',value='<0 items>',numchild='0'}"); next(); - run("C","{iname='local.ilist',addr='-',name='ilist'," + run("C","{iname='local.list',addr='-',name='list'," "type='"NS"QList',value='<1 items>',numchild='1'}"); - run("C","{iname='local.ilist',addr='-',name='ilist'," + run("C","{iname='local.list',addr='-',name='list'," "type='"NS"QList',value='<1 items>',numchild='1'," "childtype='int',childnumchild='0',children=[" - "{value='1'}]}", "local.ilist"); + "{value='1'}]}", "local.list"); next(); - run("D","{iname='local.ilist',addr='-',name='ilist'," + run("D","{iname='local.list',addr='-',name='list'," "type='"NS"QList',value='<2 items>',numchild='2'}"); - run("D","{iname='local.ilist',addr='-',name='ilist'," + run("D","{iname='local.list',addr='-',name='list'," "type='"NS"QList',value='<2 items>',numchild='2'," "childtype='int',childnumchild='0',children=[" - "{value='1'},{value='2'}]}", "local.ilist"); + "{value='1'},{value='2'}]}", "local.list"); } void dumpQList_char() { - /* A */ QList ilist; - /* B */ ilist.append('a'); + /* A */ QList list; + /* B */ list.append('a'); /* C */ (void) 0; } @@ -2377,18 +2384,53 @@ void tst_Gdb::dumpQList_char() { prepare("dumpQList_char"); if (checkUninitialized) - run("A","{iname='local.ilist',addr='-',name='ilist'," + run("A","{iname='local.list',addr='-',name='list'," "type='"NS"QList',value='',numchild='0'}"); next(); - run("B","{iname='local.ilist',addr='-',name='ilist'," + run("B","{iname='local.list',addr='-',name='list'," "type='"NS"QList',value='<0 items>',numchild='0'}"); next(); - run("C","{iname='local.ilist',addr='-',name='ilist'," + run("C","{iname='local.list',addr='-',name='list'," "type='"NS"QList',value='<1 items>',numchild='1'}"); - run("C","{iname='local.ilist',addr='-',name='ilist'," + run("C","{iname='local.list',addr='-',name='list'," "type='"NS"QList',value='<1 items>',numchild='1'," "childtype='char',childnumchild='0',children=[" - "{value='97 'a''}]}", "local.ilist"); + "{value='97 'a''}]}", "local.list"); +} + +void dumpQList_char_star() +{ + /* A */ QList list; + /* B */ list.append("a"); + /* C */ list.append(0); + /* D */ list.append("bc"); + /* E */ (void) 0; +} + +void tst_Gdb::dumpQList_char_star() +{ + prepare("dumpQList_char_star"); + if (checkUninitialized) + run("A","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='',numchild='0'}"); + next(); + run("B","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<0 items>',numchild='0'}"); + next(); + run("C","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<1 items>',numchild='1'}"); + run("C","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<1 items>',numchild='1'," + "childtype='const char *',childnumchild='1',children=[" + "{valueencoded='6',value='61',numchild='0'}]}", "local.list"); + next(); + next(); + run("E","{iname='local.list',addr='-',name='list'," + "type='"NS"QList',value='<3 items>',numchild='3'," + "childtype='const char *',childnumchild='1',children=[" + "{valueencoded='6',value='61',numchild='0'}," + "{value='0x0',numchild='0'}," + "{valueencoded='6',value='6263',numchild='0'}]}", "local.list"); } void dumpQList_QString() From 20edb02093f9f30e3a94c25bd237532c02eb08e2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 21 Oct 2009 16:48:46 +0200 Subject: [PATCH 13/91] S60: Use a DetailsWidget for the run configuration widgets, add info - Move the s60devicerunconfigurationwidget into a separate file, add an info button that connects to the device and displays CPU/Trk version for testing the connection. - give TrkLauncher a parent object and an acessor for the device description in formatted form. - Break deadlock when trying to terminate the Windows Trk writer thread with bytes pending by using a wait with timeout and termination flag. --- .../qt4projectmanager/qt-s60/qt-s60.pri | 2 + .../qt-s60/s60devicerunconfiguration.cpp | 141 +------- .../qt-s60/s60devicerunconfiguration.h | 32 -- .../s60devicerunconfigurationwidget.cpp | 318 ++++++++++++++++++ .../qt-s60/s60devicerunconfigurationwidget.h | 95 ++++++ .../qt-s60/s60emulatorrunconfiguration.cpp | 37 +- .../qt-s60/s60emulatorrunconfiguration.h | 13 +- src/shared/trk/launcher.cpp | 24 +- src/shared/trk/launcher.h | 6 +- src/shared/trk/trkdevice.cpp | 52 ++- src/shared/trk/trkutils.cpp | 69 ++++ src/shared/trk/trkutils.h | 32 +- 12 files changed, 600 insertions(+), 221 deletions(-) create mode 100644 src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp create mode 100644 src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.h diff --git a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri index d6663216928..8a445fa8de5 100644 --- a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri +++ b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri @@ -8,6 +8,7 @@ $$PWD/gccetoolchain.cpp \ $$PWD/s60emulatorrunconfiguration.cpp \ $$PWD/s60devicerunconfiguration.cpp \ + $$PWD/s60devicerunconfigurationwidget.cpp \ $$PWD/serialdevicelister.cpp \ $$PWD/rvcttoolchain.cpp HEADERS += $$PWD/s60devices.h \ @@ -17,6 +18,7 @@ $$PWD/gccetoolchain.h \ $$PWD/s60emulatorrunconfiguration.h \ $$PWD/s60devicerunconfiguration.h \ + $$PWD/s60devicerunconfigurationwidget.h \ $$PWD/serialdevicelister.h \ $$PWD/rvcttoolchain.h FORMS += $$PWD/s60devicespreferencepane.ui diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index 43606da69f9..dc3fa07748c 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -28,13 +28,12 @@ **************************************************************************/ #include "s60devicerunconfiguration.h" - +#include "s60devicerunconfigurationwidget.h" #include "qt4project.h" #include "qtversionmanager.h" #include "profilereader.h" #include "s60manager.h" #include "s60devices.h" -#include "serialdevicelister.h" #include #include @@ -48,11 +47,6 @@ #include -#include -#include -#include -#include - using namespace ProjectExplorer; using namespace Qt4ProjectManager::Internal; @@ -313,139 +307,6 @@ void S60DeviceRunConfiguration::invalidateCachedTargetInformation() emit targetInformationChanged(); } -// ======== S60DeviceRunConfigurationWidget - -S60DeviceRunConfigurationWidget::S60DeviceRunConfigurationWidget( - S60DeviceRunConfiguration *runConfiguration, - QWidget *parent) - : QWidget(parent), - m_runConfiguration(runConfiguration) -{ - QVBoxLayout *mainBoxLayout = new QVBoxLayout(); - mainBoxLayout->setMargin(0); - setLayout(mainBoxLayout); - QFormLayout *formLayout = new QFormLayout(); - formLayout->setMargin(0); - mainBoxLayout->addLayout(formLayout); - - QLabel *nameLabel = new QLabel(tr("Name:")); - m_nameLineEdit = new QLineEdit(m_runConfiguration->name()); - nameLabel->setBuddy(m_nameLineEdit); - formLayout->addRow(nameLabel, m_nameLineEdit); - - m_sisxFileLabel = new QLabel(m_runConfiguration->basePackageFilePath() + ".sisx"); - formLayout->addRow(tr("Install File:"), m_sisxFileLabel); - - m_serialPorts = new QComboBox; - updateSerialDevices(); - connect(S60Manager::instance()->serialDeviceLister(), SIGNAL(updated()), - this, SLOT(updateSerialDevices())); - connect(m_serialPorts, SIGNAL(activated(int)), this, SLOT(setSerialPort(int))); - formLayout->addRow(tr("Device on Serial Port:"), m_serialPorts); - - QWidget *signatureWidget = new QWidget(); - QVBoxLayout *layout = new QVBoxLayout(); - signatureWidget->setLayout(layout); - mainBoxLayout->addWidget(signatureWidget); - QRadioButton *selfSign = new QRadioButton(tr("Self-signed certificate")); - QHBoxLayout *customHBox = new QHBoxLayout(); - customHBox->setMargin(0); - QVBoxLayout *radioLayout = new QVBoxLayout(); - QRadioButton *customSignature = new QRadioButton(); - radioLayout->addWidget(customSignature); - radioLayout->addStretch(10); - customHBox->addLayout(radioLayout); - QFormLayout *customLayout = new QFormLayout(); - customLayout->setMargin(0); - customLayout->setLabelAlignment(Qt::AlignRight); - Utils::PathChooser *signaturePath = new Utils::PathChooser(); - signaturePath->setExpectedKind(Utils::PathChooser::File); - signaturePath->setPromptDialogTitle(tr("Choose certificate file (.cer)")); - customLayout->addRow(new QLabel(tr("Custom certificate:")), signaturePath); - Utils::PathChooser *keyPath = new Utils::PathChooser(); - keyPath->setExpectedKind(Utils::PathChooser::File); - keyPath->setPromptDialogTitle(tr("Choose key file (.key / .pem)")); - customLayout->addRow(new QLabel(tr("Key file:")), keyPath); - customHBox->addLayout(customLayout); - customHBox->addStretch(10); - layout->addWidget(selfSign); - layout->addLayout(customHBox); - layout->addStretch(10); - - switch (m_runConfiguration->signingMode()) { - case S60DeviceRunConfiguration::SignSelf: - selfSign->setChecked(true); - break; - case S60DeviceRunConfiguration::SignCustom: - customSignature->setChecked(true); - break; - } - - signaturePath->setPath(m_runConfiguration->customSignaturePath()); - keyPath->setPath(m_runConfiguration->customKeyPath()); - - connect(m_nameLineEdit, SIGNAL(textEdited(QString)), - this, SLOT(nameEdited(QString))); - connect(m_runConfiguration, SIGNAL(targetInformationChanged()), - this, SLOT(updateTargetInformation())); - connect(selfSign, SIGNAL(toggled(bool)), this, SLOT(selfSignToggled(bool))); - connect(customSignature, SIGNAL(toggled(bool)), this, SLOT(customSignatureToggled(bool))); - connect(signaturePath, SIGNAL(changed(QString)), this, SLOT(signaturePathChanged(QString))); - connect(keyPath, SIGNAL(changed(QString)), this, SLOT(keyPathChanged(QString))); -} - -void S60DeviceRunConfigurationWidget::updateSerialDevices() -{ - m_serialPorts->clear(); - QString runConfigurationPortName = m_runConfiguration->serialPortName(); - QList serialDevices = S60Manager::instance()->serialDeviceLister()->serialDevices(); - for (int i = 0; i < serialDevices.size(); ++i) { - const SerialDeviceLister::SerialDevice &device = serialDevices.at(i); - m_serialPorts->addItem(device.friendlyName, device.portName); - if (device.portName == runConfigurationPortName) - m_serialPorts->setCurrentIndex(i); - } - QString selectedPortName = m_serialPorts->itemData(m_serialPorts->currentIndex()).toString(); - if (m_serialPorts->count() > 0 && runConfigurationPortName != selectedPortName) - m_runConfiguration->setSerialPortName(selectedPortName); -} - -void S60DeviceRunConfigurationWidget::nameEdited(const QString &text) -{ - m_runConfiguration->setName(text); -} - -void S60DeviceRunConfigurationWidget::updateTargetInformation() -{ - m_sisxFileLabel->setText(m_runConfiguration->basePackageFilePath() + ".sisx"); -} - -void S60DeviceRunConfigurationWidget::setSerialPort(int index) -{ - m_runConfiguration->setSerialPortName(m_serialPorts->itemData(index).toString()); -} - -void S60DeviceRunConfigurationWidget::selfSignToggled(bool toggle) -{ - if (toggle) - m_runConfiguration->setSigningMode(S60DeviceRunConfiguration::SignSelf); -} - -void S60DeviceRunConfigurationWidget::customSignatureToggled(bool toggle) -{ - if (toggle) - m_runConfiguration->setSigningMode(S60DeviceRunConfiguration::SignCustom); -} - -void S60DeviceRunConfigurationWidget::signaturePathChanged(const QString &path) -{ - m_runConfiguration->setCustomSignaturePath(path); -} - -void S60DeviceRunConfigurationWidget::keyPathChanged(const QString &path) -{ - m_runConfiguration->setCustomKeyPath(path); -} // ======== S60DeviceRunConfigurationFactory diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h index 775804cb201..41b48a9e248 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h @@ -35,16 +35,8 @@ #include #include -#include - #include -QT_BEGIN_NAMESPACE -class QLabel; -class QLineEdit; -class QComboBox; -QT_END_NAMESPACE - namespace Debugger { class DebuggerStartParameters; } @@ -111,30 +103,6 @@ private: QString m_customKeyPath; }; -class S60DeviceRunConfigurationWidget : public QWidget -{ - Q_OBJECT -public: - explicit S60DeviceRunConfigurationWidget(S60DeviceRunConfiguration *runConfiguration, - QWidget *parent = 0); - -private slots: - void nameEdited(const QString &text); - void updateTargetInformation(); - void updateSerialDevices(); - void setSerialPort(int index); - void selfSignToggled(bool toggle); - void customSignatureToggled(bool toggle); - void signaturePathChanged(const QString &path); - void keyPathChanged(const QString &path); - -private: - S60DeviceRunConfiguration *m_runConfiguration; - QComboBox *m_serialPorts; - QLineEdit *m_nameLineEdit; - QLabel *m_sisxFileLabel; -}; - class S60DeviceRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory { Q_OBJECT diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp new file mode 100644 index 00000000000..40faa686c40 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp @@ -0,0 +1,318 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "s60devicerunconfigurationwidget.h" +#include "s60devicerunconfiguration.h" +#include "s60manager.h" +#include "launcher.h" +#include "serialdevicelister.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Qt4ProjectManager { +namespace Internal { + +S60DeviceRunConfigurationWidget::S60DeviceRunConfigurationWidget( + S60DeviceRunConfiguration *runConfiguration, + QWidget *parent) + : QWidget(parent), + m_runConfiguration(runConfiguration), + m_detailsWidget(new Utils::DetailsWidget), + m_serialPortsCombo(new QComboBox), + m_nameLineEdit(new QLineEdit(m_runConfiguration->name())), + m_sisxFileLabel(new QLabel(m_runConfiguration->basePackageFilePath() + QLatin1String(".sisx"))), + m_deviceInfoButton(new QToolButton), + m_deviceInfoDescriptionLabel(new QLabel(tr("Device:"))), + m_deviceInfoLabel(new QLabel), + m_infoTimeOutTimer(0) +{ + QVBoxLayout *mainBoxLayout = new QVBoxLayout(); + mainBoxLayout->setMargin(0); + setLayout(mainBoxLayout); + mainBoxLayout->addWidget(m_detailsWidget); + QWidget *detailsContainer = new QWidget; + m_detailsWidget->setWidget(detailsContainer); + + QVBoxLayout *detailsBoxLayout = new QVBoxLayout(); + detailsBoxLayout->setMargin(0); + detailsContainer->setLayout(detailsBoxLayout); + + QFormLayout *formLayout = new QFormLayout(); + formLayout->setMargin(0); + detailsBoxLayout->addLayout(formLayout); + // Name control + QLabel *nameLabel = new QLabel(tr("Name:")); + nameLabel->setBuddy(m_nameLineEdit); + formLayout->addRow(nameLabel, m_nameLineEdit); + formLayout->addRow(tr("Install File:"), m_sisxFileLabel); + + updateSerialDevices(); + connect(S60Manager::instance()->serialDeviceLister(), SIGNAL(updated()), + this, SLOT(updateSerialDevices())); + // Serial devices control + connect(m_serialPortsCombo, SIGNAL(activated(int)), this, SLOT(setSerialPort(int))); + QHBoxLayout *serialPortHBoxLayout = new QHBoxLayout; + serialPortHBoxLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); + serialPortHBoxLayout->addWidget(m_serialPortsCombo); + + formLayout->addRow(tr("Device on Serial Port:"), serialPortHBoxLayout); + + // Device Info with button. Widgets are enabled in above call to updateSerialDevices() + QHBoxLayout *infoHBoxLayout = new QHBoxLayout; + m_deviceInfoLabel->setWordWrap(true); + infoHBoxLayout->addWidget(m_deviceInfoLabel); + infoHBoxLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); + infoHBoxLayout->addWidget(m_deviceInfoButton); + m_deviceInfoButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MessageBoxInformation)); + m_deviceInfoButton->setToolTip(tr("Queries the device for information")); + connect(m_deviceInfoButton, SIGNAL(clicked()), this, SLOT(updateDeviceInfo())); + formLayout->addRow(m_deviceInfoDescriptionLabel, infoHBoxLayout); + + // Signature/certificate stuff. + QWidget *signatureWidget = new QWidget(); + QVBoxLayout *layout = new QVBoxLayout(); + signatureWidget->setLayout(layout); + detailsBoxLayout->addWidget(signatureWidget); + QRadioButton *selfSign = new QRadioButton(tr("Self-signed certificate")); + QHBoxLayout *customHBox = new QHBoxLayout(); + customHBox->setMargin(0); + QVBoxLayout *radioLayout = new QVBoxLayout(); + QRadioButton *customSignature = new QRadioButton(); + radioLayout->addWidget(customSignature); + radioLayout->addStretch(10); + customHBox->addLayout(radioLayout); + QFormLayout *customLayout = new QFormLayout(); + customLayout->setMargin(0); + customLayout->setLabelAlignment(Qt::AlignRight); + Utils::PathChooser *signaturePath = new Utils::PathChooser(); + signaturePath->setExpectedKind(Utils::PathChooser::File); + signaturePath->setPromptDialogTitle(tr("Choose certificate file (.cer)")); + customLayout->addRow(new QLabel(tr("Custom certificate:")), signaturePath); + Utils::PathChooser *keyPath = new Utils::PathChooser(); + keyPath->setExpectedKind(Utils::PathChooser::File); + keyPath->setPromptDialogTitle(tr("Choose key file (.key / .pem)")); + customLayout->addRow(new QLabel(tr("Key file:")), keyPath); + customHBox->addLayout(customLayout); + customHBox->addStretch(10); + layout->addWidget(selfSign); + layout->addLayout(customHBox); + layout->addStretch(10); + + switch (m_runConfiguration->signingMode()) { + case S60DeviceRunConfiguration::SignSelf: + selfSign->setChecked(true); + break; + case S60DeviceRunConfiguration::SignCustom: + customSignature->setChecked(true); + break; + } + + signaturePath->setPath(m_runConfiguration->customSignaturePath()); + keyPath->setPath(m_runConfiguration->customKeyPath()); + + connect(m_nameLineEdit, SIGNAL(textEdited(QString)), + this, SLOT(nameEdited(QString))); + connect(m_runConfiguration, SIGNAL(targetInformationChanged()), + this, SLOT(updateTargetInformation())); + connect(selfSign, SIGNAL(toggled(bool)), this, SLOT(selfSignToggled(bool))); + connect(customSignature, SIGNAL(toggled(bool)), this, SLOT(customSignatureToggled(bool))); + connect(signaturePath, SIGNAL(changed(QString)), this, SLOT(signaturePathChanged(QString))); + connect(keyPath, SIGNAL(changed(QString)), this, SLOT(keyPathChanged(QString))); + updateSummary(); +} + +void S60DeviceRunConfigurationWidget::updateSerialDevices() +{ + m_serialPortsCombo->clear(); + clearDeviceInfo(); + const QString previousRunConfigurationPortName = m_runConfiguration->serialPortName(); + const QList serialDevices = S60Manager::instance()->serialDeviceLister()->serialDevices(); + int newIndex = -1; + for (int i = 0; i < serialDevices.size(); ++i) { + const SerialDeviceLister::SerialDevice &device = serialDevices.at(i); + m_serialPortsCombo->addItem(device.friendlyName, device.portName); + if (device.portName == previousRunConfigurationPortName) + newIndex = i; + } + // Set new index: prefer to keep old or set to 0, if available. + if (newIndex == -1 && !serialDevices.empty()) + newIndex = 0; + m_serialPortsCombo->setCurrentIndex(newIndex); + if (newIndex == -1) { + m_deviceInfoButton->setEnabled(false); + m_runConfiguration->setSerialPortName(QString()); + } else { + m_deviceInfoButton->setEnabled(true); + const QString newPortName = portName(newIndex); + if (newPortName != previousRunConfigurationPortName) + m_runConfiguration->setSerialPortName(newPortName); + } +} + +QString S60DeviceRunConfigurationWidget::portName(int index) const +{ + return index >= 0 ? m_serialPortsCombo->itemData(index).toString() : QString(); +} + +QString S60DeviceRunConfigurationWidget::currentPortName() const +{ + return portName(m_serialPortsCombo->currentIndex()); +} + +void S60DeviceRunConfigurationWidget::nameEdited(const QString &text) +{ + m_runConfiguration->setName(text); +} + +void S60DeviceRunConfigurationWidget::updateTargetInformation() +{ + m_sisxFileLabel->setText(m_runConfiguration->basePackageFilePath() + QLatin1String(".sisx")); +} + +void S60DeviceRunConfigurationWidget::setSerialPort(int index) +{ + m_runConfiguration->setSerialPortName(portName(index)); + m_deviceInfoButton->setEnabled(index >= 0); + clearDeviceInfo(); + updateSummary(); +} + +void S60DeviceRunConfigurationWidget::selfSignToggled(bool toggle) +{ + if (toggle) + m_runConfiguration->setSigningMode(S60DeviceRunConfiguration::SignSelf); + updateSummary(); +} + +void S60DeviceRunConfigurationWidget::customSignatureToggled(bool toggle) +{ + if (toggle) + m_runConfiguration->setSigningMode(S60DeviceRunConfiguration::SignCustom); + updateSummary(); +} + +void S60DeviceRunConfigurationWidget::signaturePathChanged(const QString &path) +{ + m_runConfiguration->setCustomSignaturePath(path); + updateSummary(); +} + +void S60DeviceRunConfigurationWidget::keyPathChanged(const QString &path) +{ + m_runConfiguration->setCustomKeyPath(path); + updateSummary(); +} + +void S60DeviceRunConfigurationWidget::updateSummary() +{ + //: Summary text of S60 device run configuration + const QString device = m_serialPortsCombo->currentIndex() != -1 ? + m_serialPortsCombo->currentText() : + tr(""); + const QString signature = m_runConfiguration->signingMode() == S60DeviceRunConfiguration::SignCustom ? + tr("(custom certificate)") : + tr("(self-signed certificate)"); + m_detailsWidget->setSummaryText(tr("Summary: Run on '%1' %2").arg(device, signature)); +} + +void S60DeviceRunConfigurationWidget::clearDeviceInfo() +{ + // Restore text & color + m_deviceInfoLabel->clear(); + m_deviceInfoLabel->setStyleSheet(QString()); +} + +void S60DeviceRunConfigurationWidget::setDeviceInfoLabel(const QString &message, bool isError) +{ + m_deviceInfoLabel->setStyleSheet(isError ? + QString(QLatin1String("background-color: red;")) : + QString()); + m_deviceInfoLabel->setText(message); +} + +void S60DeviceRunConfigurationWidget::updateDeviceInfo() +{ + QString message; + setDeviceInfoLabel(tr("Connecting...")); + const bool ok = getDeviceInfo(&message); + setDeviceInfoLabel(message, !ok); +} + +bool S60DeviceRunConfigurationWidget::getDeviceInfo(QString *message) +{ + // Do a launcher run with the ping protocol. Instantiate launcher on heap + // as not to introduce delays when destructing a device with timeout + trk::Launcher *launcher = new trk::Launcher(trk::Launcher::ActionPingOnly, this); + launcher->setTrkServerName(currentPortName()); + if (!launcher->startServer(message)) { + launcher->deleteLater(); + return false; + } + // Set up event loop in the foreground with a timer to quit in case of timeout. + QEventLoop eventLoop; + if (!m_infoTimeOutTimer) { + m_infoTimeOutTimer = new QTimer(this); + m_infoTimeOutTimer->setInterval(3000); + m_infoTimeOutTimer->setSingleShot(true); + } + connect(m_infoTimeOutTimer, SIGNAL(timeout()), &eventLoop, SLOT(quit())); + connect(launcher, SIGNAL(finished()), &eventLoop, SLOT(quit())); + // Go! + QApplication::setOverrideCursor(Qt::BusyCursor); + m_infoTimeOutTimer->start(); + eventLoop.exec(QEventLoop::ExcludeUserInputEvents); + m_infoTimeOutTimer->disconnect(); + QApplication::restoreOverrideCursor(); + // Anything received? + *message = launcher->deviceDescription(); + launcher->deleteLater(); + if (message->isEmpty()) { + *message = tr("A timeout occurred while querying the device. Check whether Trk is running"); + return false; + } + return true; +} + +} // namespace Internal +} // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.h b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.h new file mode 100644 index 00000000000..65c5d192443 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.h @@ -0,0 +1,95 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef S60DEVICERUNCONFIGURATIONWIDGET_H +#define S60DEVICERUNCONFIGURATIONWIDGET_H + +#include + +QT_BEGIN_NAMESPACE +class QLabel; +class QTimer; +class QLineEdit; +class QComboBox; +class QToolButton; +QT_END_NAMESPACE + +namespace Utils { + class DetailsWidget; +} + +namespace Qt4ProjectManager { +namespace Internal { + +class S60DeviceRunConfiguration; + +/* Configuration widget for S60 devices on serial ports that are + * provided by the SerialDeviceLister class. Has an info/test + * button connecting to the device and showing info. */ +class S60DeviceRunConfigurationWidget : public QWidget +{ + Q_OBJECT +public: + explicit S60DeviceRunConfigurationWidget(S60DeviceRunConfiguration *runConfiguration, + QWidget *parent = 0); + +private slots: + void nameEdited(const QString &text); + void updateTargetInformation(); + void updateSerialDevices(); + void setSerialPort(int index); + void selfSignToggled(bool toggle); + void customSignatureToggled(bool toggle); + void signaturePathChanged(const QString &path); + void keyPathChanged(const QString &path); + void updateSummary(); + void updateDeviceInfo(); + void clearDeviceInfo(); + +private: + inline QString currentPortName() const; + inline QString portName(int index) const; + bool getDeviceInfo(QString *message); + void setDeviceInfoLabel(const QString &message, bool isError = false); + + S60DeviceRunConfiguration *m_runConfiguration; + Utils::DetailsWidget *m_detailsWidget; + QComboBox *m_serialPortsCombo; + QLineEdit *m_nameLineEdit; + QLabel *m_sisxFileLabel; + QToolButton *m_deviceInfoButton; + QLabel *m_deviceInfoDescriptionLabel; + QLabel *m_deviceInfoLabel; + QTimer *m_infoTimeOutTimer; +}; + +} // namespace Internal +} // namespace Qt4ProjectManager + +#endif // S60DEVICERUNCONFIGURATIONWIDGET_H diff --git a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp index aeabbebc24b..b1c65fa0e92 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp @@ -38,10 +38,14 @@ #include #include #include +#include #include #include #include +#include +#include + using namespace ProjectExplorer; using namespace Qt4ProjectManager::Internal; @@ -175,24 +179,34 @@ void S60EmulatorRunConfiguration::invalidateCachedTargetInformation() S60EmulatorRunConfigurationWidget::S60EmulatorRunConfigurationWidget(S60EmulatorRunConfiguration *runConfiguration, QWidget *parent) : QWidget(parent), - m_runConfiguration(runConfiguration) + m_runConfiguration(runConfiguration), + m_detailsWidget(new Utils::DetailsWidget), + m_nameLineEdit(new QLineEdit(m_runConfiguration->name())), + m_executableLabel(new QLabel(m_runConfiguration->executable())) { - QFormLayout *toplayout = new QFormLayout(); - toplayout->setMargin(0); - setLayout(toplayout); + QVBoxLayout *mainBoxLayout = new QVBoxLayout(); + mainBoxLayout->setMargin(0); + setLayout(mainBoxLayout); + mainBoxLayout->addWidget(m_detailsWidget); + QWidget *detailsContainer = new QWidget; + m_detailsWidget->setWidget(detailsContainer); + + QFormLayout *detailsFormLayout = new QFormLayout(); + detailsFormLayout->setMargin(0); + detailsContainer->setLayout(detailsFormLayout); QLabel *nameLabel = new QLabel(tr("Name:")); - m_nameLineEdit = new QLineEdit(m_runConfiguration->name()); - nameLabel->setBuddy(m_nameLineEdit); - toplayout->addRow(nameLabel, m_nameLineEdit); - m_executableLabel = new QLabel(m_runConfiguration->executable()); - toplayout->addRow(tr("Executable:"), m_executableLabel); + nameLabel->setBuddy(m_nameLineEdit); + detailsFormLayout->addRow(nameLabel, m_nameLineEdit); + + detailsFormLayout->addRow(tr("Executable:"), m_executableLabel); connect(m_nameLineEdit, SIGNAL(textEdited(QString)), this, SLOT(nameEdited(QString))); connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this, SLOT(updateTargetInformation())); + updateSummary(); } void S60EmulatorRunConfigurationWidget::nameEdited(const QString &text) @@ -205,6 +219,11 @@ void S60EmulatorRunConfigurationWidget::updateTargetInformation() m_executableLabel->setText(m_runConfiguration->executable()); } +void S60EmulatorRunConfigurationWidget::updateSummary() +{ + m_detailsWidget->setSummaryText(tr("Summary: Run %1 in emulator").arg(m_runConfiguration->executable())); +} + // ======== S60EmulatorRunConfigurationFactory S60EmulatorRunConfigurationFactory::S60EmulatorRunConfigurationFactory(QObject *parent) diff --git a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h index 1682478d95a..8ba0aeded4d 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h @@ -34,8 +34,15 @@ #include #include -#include -#include + +QT_BEGIN_NAMESPACE +class QLabel; +class QLineEdit; +QT_END_NAMESPACE + +namespace Utils { + class DetailsWidget; +} namespace Qt4ProjectManager { namespace Internal { @@ -79,9 +86,11 @@ public: private slots: void nameEdited(const QString &text); void updateTargetInformation(); + void updateSummary(); private: S60EmulatorRunConfiguration *m_runConfiguration; + Utils::DetailsWidget *m_detailsWidget; QLineEdit *m_nameLineEdit; QLabel *m_executableLabel; }; diff --git a/src/shared/trk/launcher.cpp b/src/shared/trk/launcher.cpp index 08af4a21535..cff53c02a18 100644 --- a/src/shared/trk/launcher.cpp +++ b/src/shared/trk/launcher.cpp @@ -73,7 +73,8 @@ LauncherPrivate::LauncherPrivate() : { } -Launcher::Launcher(Actions startupActions) : +Launcher::Launcher(Actions startupActions, QObject *parent) : + QObject(parent), d(new LauncherPrivate) { d->m_startupActions = startupActions; @@ -318,6 +319,11 @@ void Launcher::handleResult(const TrkResult &result) } } +QString Launcher::deviceDescription(unsigned verbose) const +{ + return d->m_session.deviceDescription(verbose); +} + void Launcher::handleTrkVersion(const TrkResult &result) { if (result.errorCode() || result.data.size() < 5) { @@ -325,19 +331,13 @@ void Launcher::handleTrkVersion(const TrkResult &result) emit finished(); return; } - const int trkMajor = result.data.at(1); - const int trkMinor = result.data.at(2); - const int protocolMajor = result.data.at(3); - const int protocolMinor = result.data.at(4); + d->m_session.trkAppVersion.trkMajor = result.data.at(1); + d->m_session.trkAppVersion.trkMinor = result.data.at(2); + d->m_session.trkAppVersion.protocolMajor = result.data.at(3); + d->m_session.trkAppVersion.protocolMinor = result.data.at(4); // Ping mode: Log & Terminate if (d->m_startupActions == ActionPingOnly) { - QString msg; - QTextStream(&msg) << "CPU: " << d->m_session.cpuMajor << '.' << d->m_session.cpuMinor << ' ' - << (d->m_session.bigEndian ? "big endian" : "little endian") - << " type size: " << d->m_session.defaultTypeSize - << " float size: " << d->m_session.fpTypeSize - << " Trk: v" << trkMajor << '.' << trkMinor << " Protocol: " << protocolMajor << '.' << protocolMinor; - qWarning("%s", qPrintable(msg)); + qWarning("%s", qPrintable(deviceDescription())); emit finished(); } } diff --git a/src/shared/trk/launcher.h b/src/shared/trk/launcher.h index a216b79fcb3..93f5d52923e 100644 --- a/src/shared/trk/launcher.h +++ b/src/shared/trk/launcher.h @@ -55,7 +55,8 @@ public: ActionCopyInstallRun = ActionCopy | ActionInstall | ActionRun }; - Launcher(trk::Launcher::Actions startupActions = trk::Launcher::ActionPingOnly); + explicit Launcher(trk::Launcher::Actions startupActions = trk::Launcher::ActionPingOnly, + QObject *parent = 0); ~Launcher(); void addStartupActions(trk::Launcher::Actions startupActions); void setTrkServerName(const QString &name); @@ -67,6 +68,9 @@ public: void setSerialFrame(bool b); bool serialFrame() const; + // becomes valid after successful execution of ActionPingOnly + QString deviceDescription(unsigned verbose = 0u) const; + signals: void copyingStarted(); void canNotConnect(const QString &errorMessage); diff --git a/src/shared/trk/trkdevice.cpp b/src/shared/trk/trkdevice.cpp index a303ba1c2d3..ef7bc8b34f8 100644 --- a/src/shared/trk/trkdevice.cpp +++ b/src/shared/trk/trkdevice.cpp @@ -436,15 +436,52 @@ void WriterThread::terminate() } #ifdef Q_OS_WIN -static inline bool overlappedSyncWrite(HANDLE file, const char *data, + +static inline QString msgTerminated(int size) +{ + return QString::fromLatin1("Terminated with %1 bytes pending.").arg(size); +} + +// Interruptible synchronous write function. +static inline bool overlappedSyncWrite(HANDLE file, + const bool &terminateFlag, + const char *data, DWORD size, DWORD *charsWritten, - OVERLAPPED *overlapped) + OVERLAPPED *overlapped, + QString *errorMessage) { if (WriteFile(file, data, size, charsWritten, overlapped)) return true; - if (GetLastError() != ERROR_IO_PENDING) + const DWORD writeError = GetLastError(); + if (writeError != ERROR_IO_PENDING) { + *errorMessage = QString::fromLatin1("WriteFile failed: %1").arg(winErrorMessage(writeError)); return false; - return GetOverlappedResult(file, overlapped, charsWritten, TRUE); + } + // Wait for written or thread terminated + const DWORD timeoutMS = 200; + const unsigned maxAttempts = 20; + DWORD wr = WaitForSingleObject(overlapped->hEvent, timeoutMS); + for (unsigned n = 0; wr == WAIT_TIMEOUT && n < maxAttempts && !terminateFlag; + wr = WaitForSingleObject(overlapped->hEvent, timeoutMS), n++); + if (terminateFlag) { + *errorMessage = msgTerminated(size); + return false; + } + switch (wr) { + case WAIT_OBJECT_0: + break; + case WAIT_TIMEOUT: + *errorMessage = QString::fromLatin1("Write timed out."); + return false; + default: + *errorMessage = QString::fromLatin1("Error while waiting for WriteFile results: %1").arg(winErrorMessage(GetLastError())); + return false; + } + if (!GetOverlappedResult(file, overlapped, charsWritten, TRUE)) { + *errorMessage = QString::fromLatin1("Error writing %1 bytes: %2").arg(size).arg(winErrorMessage(GetLastError())); + return false; + } + return true; } #endif @@ -453,8 +490,7 @@ bool WriterThread::write(const QByteArray &data, QString *errorMessage) QMutexLocker locker(&m_context->mutex); #ifdef Q_OS_WIN DWORD charsWritten; - if (!overlappedSyncWrite(m_context->device, data.data(), data.size(), &charsWritten, &m_context->writeOverlapped)) { - *errorMessage = QString::fromLatin1("Error writing data: %1").arg(winErrorMessage(GetLastError())); + if (!overlappedSyncWrite(m_context->device, m_terminate, data.data(), data.size(), &charsWritten, &m_context->writeOverlapped, errorMessage)) { return false; } FlushFileBuffers(m_context->device); @@ -473,8 +509,10 @@ bool WriterThread::trkWriteRawMessage(const TrkMessage &msg) const QByteArray ba = frameMessage(msg.code, msg.token, msg.data, m_context->serialFrame); QString errorMessage; const bool rc = write(ba, &errorMessage); - if (!rc) + if (!rc) { + qWarning("%s\n", qPrintable(errorMessage)); emit error(errorMessage); + } return rc; } diff --git a/src/shared/trk/trkutils.cpp b/src/shared/trk/trkutils.cpp index 463415e7c21..93df3937994 100644 --- a/src/shared/trk/trkutils.cpp +++ b/src/shared/trk/trkutils.cpp @@ -36,6 +36,75 @@ namespace trk { +TrkAppVersion::TrkAppVersion() +{ + reset(); +} + +void TrkAppVersion::reset() +{ + trkMajor = trkMinor= protocolMajor = protocolMinor = 0; +} + +Session::Session() +{ + reset(); +} + +void Session::reset() +{ + cpuMajor = 0; + cpuMinor = 0; + bigEndian = 0; + defaultTypeSize = 0; + fpTypeSize = 0; + extended1TypeSize = 0; + extended2TypeSize = 0; + pid = 0; + tid = 0; + codeseg = 0; + dataseg = 0; + + currentThread = 0; + libraries.clear(); + trkAppVersion.reset(); +} + +inline void formatCpu(QTextStream &str,int major, int minor) +{ + str << "CPU: v" << major << '.' << minor; + switch (major) { + case 0x04: + str << " ARM"; + break; + } + switch (minor) { + case 0x00: + str << " 920T"; + break; + } + } + +QString Session::deviceDescription(unsigned verbose) const +{ + QString msg; + if (cpuMajor) { + QTextStream str(&msg); + formatCpu(str, cpuMajor, cpuMinor); + str << ", " << (bigEndian ? "big endian" : "little endian"); + if (verbose) { + if (defaultTypeSize) + str << ", type size: " << defaultTypeSize; + if (fpTypeSize) + str << ", float size: " << fpTypeSize; + } + str << ", Trk: v" << trkAppVersion.trkMajor << '.' << trkAppVersion.trkMinor + << " Protocol: v" << trkAppVersion.protocolMajor << '.' << trkAppVersion.protocolMinor; + } + return msg; +} + + // FIXME: Use the QByteArray based version below? QString stringFromByte(byte c) { diff --git a/src/shared/trk/trkutils.h b/src/shared/trk/trkutils.h index e8388356c53..441a2ba2c2d 100644 --- a/src/shared/trk/trkutils.h +++ b/src/shared/trk/trkutils.h @@ -102,26 +102,21 @@ struct Library uint dataseg; }; +struct TrkAppVersion { + TrkAppVersion(); + void reset(); + + int trkMajor; + int trkMinor; + int protocolMajor; + int protocolMinor; +}; + struct Session { - Session() { reset(); } - - void reset() { - cpuMajor = 0; - cpuMinor = 0; - bigEndian = 0; - defaultTypeSize = 0; - fpTypeSize = 0; - extended1TypeSize = 0; - extended2TypeSize = 0; - pid = 0; - tid = 0; - codeseg = 0; - dataseg = 0; - - currentThread = 0; - libraries.clear(); - } + Session(); + void reset(); + QString deviceDescription(unsigned verbose) const; // Trk feedback byte cpuMajor; @@ -131,6 +126,7 @@ struct Session byte fpTypeSize; byte extended1TypeSize; byte extended2TypeSize; + TrkAppVersion trkAppVersion; uint pid; uint tid; uint codeseg; From 94226ceb5ec42860db0a618a31c1b86dd4319ff5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 21 Oct 2009 16:49:39 +0200 Subject: [PATCH 14/91] don't attempt to sync breakpoints at inopportune times e.g., when the engine is not ready --- src/plugins/debugger/gdb/gdbengine.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 67bb37d41c2..d635f30af0f 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2035,6 +2035,18 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response) void GdbEngine::attemptBreakpointSynchronization() { + switch (state()) { + case InferiorStarting: + case InferiorRunningRequested: + case InferiorRunning: + case InferiorStopping: + case InferiorStopped: + break; + default: + //qDebug() << "attempted breakpoint sync in state" << state(); + return; + } + BreakHandler *handler = manager()->breakHandler(); foreach (BreakpointData *data, handler->takeDisabledBreakpoints()) { From 8d3ca6424cdfea8ab7aceaf00e9207e5c0aaeeb3 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 21 Oct 2009 16:50:00 +0200 Subject: [PATCH 15/91] if 0 unused code --- src/plugins/debugger/gdb/gdbengine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index d635f30af0f..0b13b681dbe 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1267,6 +1267,7 @@ void GdbEngine::handleShowVersion(const GdbResponse &response) QRegExp supported(_("GNU gdb(.*) (\\d+)\\.(\\d+)(\\.(\\d+))?(-(\\d+))?")); if (supported.indexIn(msg) == -1) { debugMessage(_("UNSUPPORTED GDB VERSION ") + msg); +#if 0 QStringList list = msg.split(_c('\n')); while (list.size() > 2) list.removeLast(); @@ -1282,6 +1283,7 @@ void GdbEngine::handleShowVersion(const GdbResponse &response) err->showMessage(msg); #else //showMessageBox(QMessageBox::Information, tr("Warning"), msg); +#endif #endif } else { m_gdbVersion = 10000 * supported.cap(2).toInt() From 81235527265556b6128f740dc327aa8dbecd2112 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 21 Oct 2009 16:50:36 +0200 Subject: [PATCH 16/91] add a FIXME --- 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 0b13b681dbe..aa800d31bd4 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -705,7 +705,7 @@ void GdbEngine::postCommandHelper(const GdbCommand &cmd) showStatusMessage(tr("Stopping temporarily."), 1000); debugMessage(_("QUEUING COMMAND ") + cmd.command); m_commandsToRunOnTemporaryBreak.append(cmd); - interruptInferior(); + interruptInferior(); // FIXME: race condition between gdb and kill() } } else if (!cmd.command.isEmpty()) { flushCommand(cmd); From fc7219248b3be17b5d8ad57c241542d309e6dc90 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 21 Oct 2009 17:03:52 +0200 Subject: [PATCH 17/91] S60: Swap spacers in device run config widget. --- .../qt-s60/s60devicerunconfigurationwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp index 40faa686c40..b0b1b258300 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp @@ -93,8 +93,8 @@ S60DeviceRunConfigurationWidget::S60DeviceRunConfigurationWidget( // Serial devices control connect(m_serialPortsCombo, SIGNAL(activated(int)), this, SLOT(setSerialPort(int))); QHBoxLayout *serialPortHBoxLayout = new QHBoxLayout; - serialPortHBoxLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); serialPortHBoxLayout->addWidget(m_serialPortsCombo); + serialPortHBoxLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); formLayout->addRow(tr("Device on Serial Port:"), serialPortHBoxLayout); From c97427431f3718f0aea00a378f404149fc6398fc Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 16:42:23 +0200 Subject: [PATCH 18/91] Removed obsoleted code. --- src/plugins/qmleditor/parser/qmljsnodepool_p.h | 6 ------ src/plugins/qtscripteditor/parser/javascriptnodepool_p.h | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/plugins/qmleditor/parser/qmljsnodepool_p.h b/src/plugins/qmleditor/parser/qmljsnodepool_p.h index ba0c3678efd..30669b04d1b 100644 --- a/src/plugins/qmleditor/parser/qmljsnodepool_p.h +++ b/src/plugins/qmleditor/parser/qmljsnodepool_p.h @@ -104,17 +104,11 @@ public: inline QString fileName() const { return m_fileName; } inline Engine *engine() const { return m_engine; } -#ifndef J_SCRIPT_NO_EVENT_NOTIFY - inline qint64 id() const { return m_id; } -#endif private: QHash m_codeCache; QString m_fileName; Engine *m_engine; -#ifndef J_SCRIPT_NO_EVENT_NOTIFY - qint64 m_id; -#endif private: Q_DISABLE_COPY(NodePool) diff --git a/src/plugins/qtscripteditor/parser/javascriptnodepool_p.h b/src/plugins/qtscripteditor/parser/javascriptnodepool_p.h index d974ff01783..a0e7d649c69 100644 --- a/src/plugins/qtscripteditor/parser/javascriptnodepool_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptnodepool_p.h @@ -116,17 +116,11 @@ public: inline QString fileName() const { return m_fileName; } inline JavaScriptEnginePrivate *engine() const { return m_engine; } -#ifndef J_SCRIPT_NO_EVENT_NOTIFY - inline qint64 id() const { return m_id; } -#endif private: QHash m_codeCache; QString m_fileName; JavaScriptEnginePrivate *m_engine; -#ifndef J_SCRIPT_NO_EVENT_NOTIFY - qint64 m_id; -#endif private: Q_DISABLE_COPY(NodePool) From e9a97ea6a4fa4b45d25a8c49b2576cdaf131d49d Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 16:44:07 +0200 Subject: [PATCH 19/91] Initialize m_line and m_column --- src/plugins/cpptools/cpptoolseditorsupport.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/cpptools/cpptoolseditorsupport.cpp b/src/plugins/cpptools/cpptoolseditorsupport.cpp index db9e984b1ac..90811aad5a3 100644 --- a/src/plugins/cpptools/cpptoolseditorsupport.cpp +++ b/src/plugins/cpptools/cpptoolseditorsupport.cpp @@ -165,7 +165,8 @@ class CheckDocument: protected ASTVisitor public: CheckDocument(Document::Ptr doc, Snapshot snapshot) - : ASTVisitor(doc->control()), _doc(doc), _snapshot(snapshot) + : ASTVisitor(doc->control()), _doc(doc), _snapshot(snapshot), + _line(0), _column(0) { } QList operator()(QTextCursor tc) From 5f04a48f6bfde449522b234cc382f0ed878d5ccf Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 16:45:43 +0200 Subject: [PATCH 20/91] Removed unused member _node in QuickFixOperation --- src/plugins/cpptools/cpptoolseditorsupport.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/cpptools/cpptoolseditorsupport.h b/src/plugins/cpptools/cpptoolseditorsupport.h index d788ebbb282..86f5867493c 100644 --- a/src/plugins/cpptools/cpptoolseditorsupport.h +++ b/src/plugins/cpptools/cpptoolseditorsupport.h @@ -89,7 +89,6 @@ protected: QTextCursor moveAtEndOfToken(unsigned index) const; private: - CPlusPlus::AST *_node; CPlusPlus::Document::Ptr _doc; CPlusPlus::Snapshot _snapshot; QTextCursor _textCursor; From 250d947aa5027bda3295493e667f529ce920fdc6 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 16:47:28 +0200 Subject: [PATCH 21/91] Initialize members of ModelItemInfo. --- src/plugins/cpptools/searchsymbols.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/cpptools/searchsymbols.h b/src/plugins/cpptools/searchsymbols.h index 10ceeae373c..69df0bdc672 100644 --- a/src/plugins/cpptools/searchsymbols.h +++ b/src/plugins/cpptools/searchsymbols.h @@ -51,6 +51,8 @@ struct ModelItemInfo enum ItemType { Enum, Class, Method, Declaration }; ModelItemInfo() + : type(Declaration), + line(0) { } ModelItemInfo(const QString &symbolName, From 996866814aee66a0cc7a5f61af9306630bf96232 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 16:51:54 +0200 Subject: [PATCH 22/91] Initialize all the members of CppCodeCompletion --- src/plugins/cpptools/cppcodecompletion.cpp | 3 +++ src/plugins/cpptools/cppcodecompletion.h | 11 ++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index b62c421658d..1d77d7c8679 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -508,8 +508,11 @@ void CppQuickFixCollector::cleanup() CppCodeCompletion::CppCodeCompletion(CppModelManager *manager) : ICompletionCollector(manager), m_manager(manager), + m_editor(0), + m_startPosition(-1), m_caseSensitivity(Qt::CaseSensitive), m_autoInsertBrackets(true), + m_partialCompletionEnabled(true), m_forcedCompletion(false), m_completionOperator(T_EOF_SYMBOL) { diff --git a/src/plugins/cpptools/cppcodecompletion.h b/src/plugins/cpptools/cppcodecompletion.h index d2bf549b168..0b8350165e7 100644 --- a/src/plugins/cpptools/cppcodecompletion.h +++ b/src/plugins/cpptools/cppcodecompletion.h @@ -146,25 +146,22 @@ private: int findStartOfName(int pos = -1) const; - QList m_completions; - +private: + CppModelManager *m_manager; TextEditor::ITextEditable *m_editor; int m_startPosition; // Position of the cursor from which completion started - CppModelManager *m_manager; Qt::CaseSensitivity m_caseSensitivity; bool m_autoInsertBrackets; bool m_partialCompletionEnabled; - bool m_forcedCompletion; + unsigned m_completionOperator; CPlusPlus::Icons m_icons; CPlusPlus::Overview overview; CPlusPlus::TypeOfExpression typeOfExpression; - - unsigned m_completionOperator; - QPointer m_functionArgumentWidget; + QList m_completions; }; } // namespace Internal From de82f1e3f7d7327a8739ce5e642f390a6352cfe0 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 16:54:59 +0200 Subject: [PATCH 23/91] Initialize the pp's engine _dot member. --- src/libs/cplusplus/pp-engine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index d84722c3fd6..c2bb068bced 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -547,6 +547,7 @@ Preprocessor::Preprocessor(Client *client, Environment *env) _expand(env), _skipping(MAX_LEVEL), _trueTest(MAX_LEVEL), + _dot(_tokens.end()), _result(0), _markGeneratedTokens(false), _expandMacros(true) From c46dc2aae0f2150c8e923bbd63b03efbed454ea5 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 16:57:17 +0200 Subject: [PATCH 24/91] Added ctors for the pp-scanners. --- src/libs/cplusplus/pp-scanner.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libs/cplusplus/pp-scanner.h b/src/libs/cplusplus/pp-scanner.h index 16baa57c372..a7e00514602 100644 --- a/src/libs/cplusplus/pp-scanner.h +++ b/src/libs/cplusplus/pp-scanner.h @@ -54,6 +54,8 @@ namespace CPlusPlus { struct pp_skip_blanks { int lines; + + pp_skip_blanks(): lines(0) {} const char *operator () (const char *first, const char *last); }; @@ -61,6 +63,7 @@ struct pp_skip_whitespaces { int lines; + pp_skip_whitespaces(): lines(0) {} const char *operator () (const char *first, const char *last); }; @@ -68,6 +71,7 @@ struct pp_skip_comment_or_divop { int lines; + pp_skip_comment_or_divop(): lines(0) {} const char *operator () (const char *first, const char *last); }; @@ -75,6 +79,7 @@ struct pp_skip_identifier { int lines; + pp_skip_identifier(): lines(0) {} const char *operator () (const char *first, const char *last); }; @@ -82,6 +87,7 @@ struct pp_skip_number { int lines; + pp_skip_number(): lines(0) {} const char *operator () (const char *first, const char *last); }; @@ -89,6 +95,7 @@ struct pp_skip_string_literal { int lines; + pp_skip_string_literal(): lines(0) {} const char *operator () (const char *first, const char *last); }; @@ -96,6 +103,7 @@ struct pp_skip_char_literal { int lines; + pp_skip_char_literal(): lines(0) {} const char *operator () (const char *first, const char *last); }; @@ -108,6 +116,7 @@ struct pp_skip_argument pp_skip_comment_or_divop skip_comment_or_divop; int lines; + pp_skip_argument(): lines(0) {} const char *operator () (const char *first, const char *last); }; From 50d60e712c59e750bef59c1500d73d9371760adc Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 16:59:17 +0200 Subject: [PATCH 25/91] Initialize ExpressionUnderCursor's _jumpedComma. --- src/libs/cplusplus/ExpressionUnderCursor.cpp | 1 + src/libs/cplusplus/ExpressionUnderCursor.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libs/cplusplus/ExpressionUnderCursor.cpp b/src/libs/cplusplus/ExpressionUnderCursor.cpp index 26a2b3a961a..995eeace37d 100644 --- a/src/libs/cplusplus/ExpressionUnderCursor.cpp +++ b/src/libs/cplusplus/ExpressionUnderCursor.cpp @@ -38,6 +38,7 @@ using namespace CPlusPlus; ExpressionUnderCursor::ExpressionUnderCursor() + : _jumpedComma(false) { } ExpressionUnderCursor::~ExpressionUnderCursor() diff --git a/src/libs/cplusplus/ExpressionUnderCursor.h b/src/libs/cplusplus/ExpressionUnderCursor.h index b72f790f977..faf969662b8 100644 --- a/src/libs/cplusplus/ExpressionUnderCursor.h +++ b/src/libs/cplusplus/ExpressionUnderCursor.h @@ -59,6 +59,7 @@ private: int previousBlockState(const QTextBlock &block); bool isAccessToken(const SimpleToken &tk); +private: bool _jumpedComma; }; From 98bde3dda7277b8f8832281efa119d94698c0b44 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 17:00:20 +0200 Subject: [PATCH 26/91] Removed unused member _pool in LiteralTable. --- src/shared/cplusplus/LiteralTable.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/shared/cplusplus/LiteralTable.h b/src/shared/cplusplus/LiteralTable.h index 29de643002d..52816a5682e 100644 --- a/src/shared/cplusplus/LiteralTable.h +++ b/src/shared/cplusplus/LiteralTable.h @@ -175,8 +175,6 @@ protected: } protected: - MemoryPool *_pool; - _Literal **_literals; int _allocatedLiterals; int _literalCount; From 245a2ca2b3704b557dffafa44d63d76870db5e54 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 17:01:40 +0200 Subject: [PATCH 27/91] Initialize the members of List --- src/shared/cplusplus/AST.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h index 05a78b08322..6dced425a73 100644 --- a/src/shared/cplusplus/AST.h +++ b/src/shared/cplusplus/AST.h @@ -64,6 +64,7 @@ class List: public Managed public: List() + : value(_Tp()), next(0) { } _Tp value; From afcbb78999b16b70a3e647cb6ffcc93a92f491a0 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 21 Oct 2009 17:03:18 +0200 Subject: [PATCH 28/91] Initialize _isInterface of ObjCClass --- src/shared/cplusplus/Symbols.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/shared/cplusplus/Symbols.cpp b/src/shared/cplusplus/Symbols.cpp index aa15735410f..8ddaf3ef5dd 100644 --- a/src/shared/cplusplus/Symbols.cpp +++ b/src/shared/cplusplus/Symbols.cpp @@ -589,6 +589,7 @@ void ObjCBaseProtocol::visitSymbol0(SymbolVisitor *visitor) ObjCClass::ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): ScopedSymbol(translationUnit, sourceLocation, name), + _isInterface(false), _categoryName(0), _baseClass(0) { From da89dbb410ded7619a10cb6cb17aed2a2d407445 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Wed, 21 Oct 2009 17:06:15 +0200 Subject: [PATCH 29/91] Add "Inherits QObject" checkbox to Class Wizard. For now it is dumb, but it can be improved over time. --- src/libs/utils/newclasswidget.cpp | 24 +++++++++++++++ src/libs/utils/newclasswidget.h | 6 ++++ src/libs/utils/newclasswidget.ui | 39 ++++++++++++++++-------- src/plugins/cppeditor/cppclasswizard.cpp | 4 +++ src/plugins/cppeditor/cppclasswizard.h | 1 + 5 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/libs/utils/newclasswidget.cpp b/src/libs/utils/newclasswidget.cpp index 42265a062e1..b3378281a9d 100644 --- a/src/libs/utils/newclasswidget.cpp +++ b/src/libs/utils/newclasswidget.cpp @@ -57,6 +57,7 @@ struct NewClassWidgetPrivate { bool m_baseClassInputVisible; bool m_formInputVisible; bool m_pathInputVisible; + bool m_qobjectCheckBoxVisible; bool m_formInputCheckable; }; @@ -69,7 +70,9 @@ NewClassWidgetPrivate:: NewClassWidgetPrivate() : m_baseClassInputVisible(true), m_formInputVisible(true), m_pathInputVisible(true), + m_qobjectCheckBoxVisible(false), m_formInputCheckable(false) + { } @@ -169,6 +172,17 @@ void NewClassWidget::setBaseClassInputVisible(bool visible) m_d->m_ui.baseClassComboBox->setVisible(visible); } +void NewClassWidget::setQObjectCheckBoxVisible(bool visible) +{ + m_d->m_qobjectCheckBoxVisible = visible; + m_d->m_ui.qobjectCheckBox->setVisible(visible); +} + +bool NewClassWidget::isQObjectCheckBoxVisible() const +{ + return m_d->m_qobjectCheckBoxVisible; +} + void NewClassWidget::setBaseClassEditable(bool editable) { m_d->m_ui.baseClassComboBox->setEditable(editable); @@ -356,6 +370,16 @@ void NewClassWidget::setAllowDirectories(bool v) } } +bool NewClassWidget::inheritsQObject() const +{ + return m_d->m_ui.qobjectCheckBox->isChecked(); +} + +void NewClassWidget::setInheritsQObject(bool v) +{ + m_d->m_ui.qobjectCheckBox->setChecked(v); +} + bool NewClassWidget::lowerCaseFiles() const { return m_d->m_ui.classLineEdit->lowerCaseFileName(); diff --git a/src/libs/utils/newclasswidget.h b/src/libs/utils/newclasswidget.h index 52d03720a8e..1a43877761c 100644 --- a/src/libs/utils/newclasswidget.h +++ b/src/libs/utils/newclasswidget.h @@ -57,6 +57,7 @@ class QTCREATOR_UTILS_EXPORT NewClassWidget : public QWidget Q_PROPERTY(bool baseClassEditable READ isBaseClassEditable WRITE setBaseClassEditable DESIGNABLE false) Q_PROPERTY(bool formInputVisible READ isFormInputVisible WRITE setFormInputVisible DESIGNABLE true) Q_PROPERTY(bool pathInputVisible READ isPathInputVisible WRITE setPathInputVisible DESIGNABLE true) + Q_PROPERTY(bool qobjectCheckBoxVisible READ isQObjectCheckBoxVisible WRITE setQObjectCheckBoxVisible DESIGNABLE true) Q_PROPERTY(QString className READ className WRITE setClassName DESIGNABLE true) Q_PROPERTY(QString baseClassName READ baseClassName WRITE setBaseClassName DESIGNABLE true) Q_PROPERTY(QString sourceFileName READ sourceFileName DESIGNABLE false) @@ -70,6 +71,7 @@ class QTCREATOR_UTILS_EXPORT NewClassWidget : public QWidget Q_PROPERTY(bool formInputCheckable READ formInputCheckable WRITE setFormInputCheckable DESIGNABLE true) Q_PROPERTY(bool formInputChecked READ formInputChecked WRITE setFormInputChecked DESIGNABLE true) Q_PROPERTY(bool allowDirectories READ allowDirectories WRITE setAllowDirectories) + Q_PROPERTY(bool inheritsQObject READ inheritsQObject WRITE setInheritsQObject) Q_PROPERTY(bool lowerCaseFiles READ lowerCaseFiles WRITE setLowerCaseFiles) // Utility "USER" property for wizards containing file names. Q_PROPERTY(QStringList files READ files DESIGNABLE false USER true) @@ -82,6 +84,7 @@ public: bool isBaseClassEditable() const; bool isFormInputVisible() const; bool isPathInputVisible() const; + bool isQObjectCheckBoxVisible() const; bool formInputCheckable() const; bool formInputChecked() const; @@ -95,6 +98,7 @@ public: QString sourceExtension() const; QString headerExtension() const; QString formExtension() const; + bool inheritsQObject() const; bool allowDirectories() const; bool lowerCaseFiles() const; @@ -114,6 +118,7 @@ public slots: void setPathInputVisible(bool visible); void setFormInputCheckable(bool v); void setFormInputChecked(bool v); + void setQObjectCheckBoxVisible(bool v); /** * The name passed into the new class widget will be reformatted to be a @@ -126,6 +131,7 @@ public slots: void setSourceExtension(const QString &e); void setHeaderExtension(const QString &e); void setFormExtension(const QString &e); + void setInheritsQObject(bool v); void setAllowDirectories(bool v); void setLowerCaseFiles(bool v); diff --git a/src/libs/utils/newclasswidget.ui b/src/libs/utils/newclasswidget.ui index 76a093a76fb..bb2e465cc01 100644 --- a/src/libs/utils/newclasswidget.ui +++ b/src/libs/utils/newclasswidget.ui @@ -2,6 +2,14 @@ Utils::NewClassWidget + + + 0 + 0 + 213 + 190 + + QFormLayout::ExpandingFieldsGrow @@ -36,7 +44,7 @@ - + Qt::Vertical @@ -52,7 +60,7 @@ - + Qt::Vertical @@ -68,60 +76,67 @@ - + Header file: - + - + Source file: - + - + Generate form: - + Form file: - + - + Path: - + - + + + + + Inherits QObject + + + diff --git a/src/plugins/cppeditor/cppclasswizard.cpp b/src/plugins/cppeditor/cppclasswizard.cpp index 1c994c6ebcb..02ce50a5e1f 100644 --- a/src/plugins/cppeditor/cppclasswizard.cpp +++ b/src/plugins/cppeditor/cppclasswizard.cpp @@ -74,6 +74,7 @@ ClassNamePage::ClassNamePage(QWidget *parent) : m_newClassWidget->setFormInputVisible(false); m_newClassWidget->setNamespacesEnabled(true); m_newClassWidget->setAllowDirectories(true); + m_newClassWidget->setBaseClassInputVisible(true); connect(m_newClassWidget, SIGNAL(validChanged()), this, SLOT(slotValidChanged())); @@ -154,6 +155,7 @@ CppClassWizardParameters CppClassWizardDialog::parameters() const rc.sourceFile = ncw->sourceFileName(); rc.baseClass = ncw->baseClassName(); rc.path = ncw->path(); + rc.inheritsQObject = ncw->inheritsQObject(); return rc; } @@ -253,6 +255,8 @@ bool CppClassWizard::generateHeaderAndSource(const CppClassWizardParameters &par else headerStr << "\n"; headerStr << namespaceIndent << "{\n"; + if (params.inheritsQObject) + headerStr << namespaceIndent << "Q_OBJECT\n"; headerStr << namespaceIndent << "public:\n" << namespaceIndent << indent << unqualifiedClassName << "();\n"; headerStr << namespaceIndent << "};\n"; diff --git a/src/plugins/cppeditor/cppclasswizard.h b/src/plugins/cppeditor/cppclasswizard.h index 1bc26d1b56f..0d2f2ae11fa 100644 --- a/src/plugins/cppeditor/cppclasswizard.h +++ b/src/plugins/cppeditor/cppclasswizard.h @@ -74,6 +74,7 @@ struct CppClassWizardParameters QString sourceFile; QString baseClass; QString path; + bool inheritsQObject; }; class CppClassWizardDialog : public QWizard From 381a9480bfffc28ec9aa0a8ecb5469613b28794d Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Thu, 22 Oct 2009 14:23:30 +0200 Subject: [PATCH 30/91] Fix detection of Qt Versions added by installer. Now that we check for the qmake.exe location rather than for the path itself, we need to use QFile for the check. --- src/plugins/qt4projectmanager/qtversionmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 9dea8af0bdc..22f5663cc57 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -290,7 +290,7 @@ void QtVersionManager::addNewVersionsFromInstaller() foreach (QString newVersion, newVersionsList) { QStringList newVersionData = newVersion.split('='); if (newVersionData.count()>=2) { - if (QDir(newVersionData[1]).exists()) { + if (QFile::exists(newVersionData[1])) { QtVersion *version = new QtVersion(newVersionData[0], newVersionData[1], m_idcount++ ); if (newVersionData.count() >= 3) version->setMingwDirectory(newVersionData[2]); From c31795cb8911483cd6a2f2c22c8ca0f811651916 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Thu, 22 Oct 2009 14:23:46 +0200 Subject: [PATCH 31/91] Consistant naming with implementation. --- src/plugins/qt4projectmanager/qtversionmanager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index d79809bffe9..3e96ab5344b 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -48,12 +48,12 @@ class QtVersion { friend class QtVersionManager; public: - QtVersion(const QString &name, const QString &path, + QtVersion(const QString &name, const QString &qmakeCommand, bool isAutodetected = false, const QString &autodetectionSource = QString()); QtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); - QtVersion(const QString &name, const QString &path, int id, + QtVersion(const QString &name, const QString &qmakeCommand, int id, bool isAutodetected = false, const QString &autodetectionSource = QString()); QtVersion(); ~QtVersion(); From 8175e4e4c62bb5a587329ca5bb5c4c35508370d4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 22 Oct 2009 16:42:25 +0200 Subject: [PATCH 32/91] S60: Introduce a communications device type. - Introduce a communications device type flag, add stubs for Bluetooth to serialdevicelister and pass the device type in new struct CommunicationDevice along to run configuration and debugger start parameters (overriding the debugger settings). - Give the s60devices::Device a tooltip in the settings page --- src/plugins/debugger/debuggermanager.cpp | 1 + src/plugins/debugger/debuggermanager.h | 1 + src/plugins/debugger/gdb/trkgdbadapter.cpp | 28 ++++---- src/plugins/debugger/gdb/trkgdbadapter.h | 6 +- .../qt-s60/s60devicerunconfiguration.cpp | 25 ++++++- .../qt-s60/s60devicerunconfiguration.h | 8 ++- .../s60devicerunconfigurationwidget.cpp | 37 ++++++---- .../qt-s60/s60devicerunconfigurationwidget.h | 6 +- .../qt4projectmanager/qt-s60/s60devices.cpp | 67 ++++++++++++++++++- .../qt4projectmanager/qt-s60/s60devices.h | 12 ++++ .../qt-s60/s60devicespreferencepane.cpp | 9 ++- .../qt-s60/serialdevicelister.cpp | 51 ++++++++++++-- .../qt-s60/serialdevicelister.h | 38 ++++++----- src/shared/trk/trkdevice.cpp | 2 +- 14 files changed, 228 insertions(+), 63 deletions(-) diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 9c21448bfa6..51f7d210c11 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -216,6 +216,7 @@ static const char *stateName(int s) DebuggerStartParameters::DebuggerStartParameters() : attachPID(-1), useTerminal(false), + remoteChannelType(-1), toolChainType(ProjectExplorer::ToolChain::UNKNOWN), startMode(NoStartMode) {} diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index c82bacb1e0e..b2c5bb94f5b 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -113,6 +113,7 @@ public: QString crashParameter; // for AttachCrashedExternal // for remote debugging QString remoteChannel; + int remoteChannelType; QString remoteArchitecture; QString symbolFileName; QString serverStartScript; diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp index c62a31b9678..de7dfaebcf4 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp @@ -191,6 +191,7 @@ void Snapshot::insertMemory(const MemoryRange &range, const QByteArray &ba) TrkGdbAdapter::TrkGdbAdapter(GdbEngine *engine, const TrkOptionsPtr &options) : AbstractGdbAdapter(engine), m_options(options), + m_overrideTrkDeviceType(-1), m_running(false), m_gdbAckMode(true), m_verbose(2), @@ -225,7 +226,7 @@ TrkGdbAdapter::TrkGdbAdapter(GdbEngine *engine, const TrkOptionsPtr &options) : this, SLOT(handleTrkError(QString))); m_trkDevice.setVerbose(m_verbose); - m_trkDevice.setSerialFrame(m_options->mode != TrkOptions::BlueTooth); + m_trkDevice.setSerialFrame(effectiveTrkDeviceType() != TrkOptions::BlueTooth); connect(&m_trkDevice, SIGNAL(logMessage(QString)), this, SLOT(trkLogMessage(QString))); @@ -237,16 +238,6 @@ TrkGdbAdapter::~TrkGdbAdapter() logMessage("Shutting down.\n"); } -QString TrkGdbAdapter::overrideTrkDevice() const -{ - return m_overrideTrkDevice; -} - -void TrkGdbAdapter::setOverrideTrkDevice(const QString &d) -{ - m_overrideTrkDevice = d; -} - QString TrkGdbAdapter::effectiveTrkDevice() const { if (!m_overrideTrkDevice.isEmpty()) @@ -256,6 +247,13 @@ QString TrkGdbAdapter::effectiveTrkDevice() const return m_options->serialPort; } +int TrkGdbAdapter::effectiveTrkDeviceType() const +{ + if (m_overrideTrkDeviceType >= 0) + return m_overrideTrkDeviceType; + return m_options->mode; +} + void TrkGdbAdapter::trkLogMessage(const QString &msg) { logMessage("TRK " + msg); @@ -403,7 +401,7 @@ void TrkGdbAdapter::waitForTrkConnect() .arg(QChar("/-\\|"[direction]))); } // Do not loop forever - if (m_waitCount++ < (m_options->mode == TrkOptions::BlueTooth ? 60 : 5)) { + if (m_waitCount++ < (effectiveTrkDeviceType() == TrkOptions::BlueTooth ? 60 : 5)) { QTimer::singleShot(1000, this, SLOT(waitForTrkConnect())); } else { QString msg = _("Failed to connect to %1 after " @@ -1519,7 +1517,8 @@ void TrkGdbAdapter::startAdapter() { // Retrieve parameters const DebuggerStartParameters ¶meters = startParameters(); - setOverrideTrkDevice(parameters.remoteChannel); + m_overrideTrkDevice = parameters.remoteChannel; + m_overrideTrkDeviceType = parameters.remoteChannelType; m_remoteExecutable = parameters.executable; m_symbolFile = parameters.symbolFileName; // FIXME: testing hack, remove! @@ -1534,7 +1533,8 @@ void TrkGdbAdapter::startAdapter() setState(AdapterStarting); debugMessage(_("TRYING TO START ADAPTER")); logMessage(QLatin1String("### Starting TrkGdbAdapter")); - if (m_options->mode == TrkOptions::BlueTooth) { + m_trkDevice.setSerialFrame(effectiveTrkDeviceType() != TrkOptions::BlueTooth); + if (effectiveTrkDeviceType() == TrkOptions::BlueTooth) { const QString device = effectiveTrkDevice(); const QString blueToothListener = QLatin1String("rfcomm"); QStringList blueToothListenerArguments; diff --git a/src/plugins/debugger/gdb/trkgdbadapter.h b/src/plugins/debugger/gdb/trkgdbadapter.h index 9bc68b43098..2f73b7fa76d 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.h +++ b/src/plugins/debugger/gdb/trkgdbadapter.h @@ -142,16 +142,13 @@ public: void setBufferedMemoryRead(bool b) { m_bufferedMemoryRead = b; } trk::Session &session() { return m_session; } - // Set a device (from the project) to override the settings. - QString overrideTrkDevice() const; - void setOverrideTrkDevice(const QString &); - signals: void output(const QString &msg); private: const TrkOptionsPtr m_options; QString m_overrideTrkDevice; + int m_overrideTrkDeviceType; QString m_gdbServerName; // 127.0.0.1:(2222+uid) @@ -302,6 +299,7 @@ private: Q_SLOT void handleRfcommStateChanged(QProcess::ProcessState newState); QString effectiveTrkDevice() const; + int effectiveTrkDeviceType() const; // Debuggee state trk::Session m_session; // global-ish data (process id, target information) diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index dc3fa07748c..64b1ee120cf 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -34,6 +34,7 @@ #include "profilereader.h" #include "s60manager.h" #include "s60devices.h" +#include "serialdevicelister.h" #include #include @@ -59,12 +60,19 @@ static QString lsFile(const QString &f) str << fi.size() << ' ' << fi.lastModified().toString(Qt::ISODate) << ' ' << QDir::toNativeSeparators(fi.absoluteFilePath()); return rc; } + // ======== S60DeviceRunConfiguration S60DeviceRunConfiguration::S60DeviceRunConfiguration(Project *project, const QString &proFilePath) : RunConfiguration(project), m_proFilePath(proFilePath), m_cachedTargetInformationValid(false), - m_serialPortName("COM5"), +#ifdef Q_OS_WIN + m_serialPortName(QLatin1String("COM5")), + m_communicationType(SerialPortCommunication), +#else + m_serialPortName(QLatin1String(SerialDeviceLister::linuxBlueToothDeviceRootC) + QLatin1Char('0')), + m_communicationType(BlueToothCommunication), +#endif m_signingMode(SignSelf) { if (!m_proFilePath.isEmpty()) @@ -114,6 +122,7 @@ void S60DeviceRunConfiguration::save(PersistentSettingsWriter &writer) const writer.saveValue("CustomSignaturePath", m_customSignaturePath); writer.saveValue("CustomKeyPath", m_customKeyPath); writer.saveValue("SerialPortName", m_serialPortName); + writer.saveValue("CommunicationType", m_communicationType); RunConfiguration::save(writer); } @@ -126,6 +135,7 @@ void S60DeviceRunConfiguration::restore(const PersistentSettingsReader &reader) m_customSignaturePath = reader.restoreValue("CustomSignaturePath").toString(); m_customKeyPath = reader.restoreValue("CustomKeyPath").toString(); m_serialPortName = reader.restoreValue("SerialPortName").toString().trimmed(); + m_communicationType = reader.restoreValue("CommunicationType").toInt(); } QString S60DeviceRunConfiguration::serialPortName() const @@ -138,6 +148,16 @@ void S60DeviceRunConfiguration::setSerialPortName(const QString &name) m_serialPortName = name.trimmed(); } +int S60DeviceRunConfiguration::communicationType() const +{ + return m_communicationType; +} + +void S60DeviceRunConfiguration::setCommunicationType(int t) +{ + m_communicationType = t; +} + QString S60DeviceRunConfiguration::targetName() const { const_cast(this)->updateTarget(); @@ -393,6 +413,7 @@ S60DeviceRunControlBase::S60DeviceRunControlBase(const QSharedPointerserialPortName(); m_serialPortFriendlyName = S60Manager::instance()->serialDeviceLister()->friendlyNameForPort(m_serialPortName); + m_communicationType = s60runConfig->communicationType(); m_targetName = s60runConfig->targetName(); m_baseFileName = s60runConfig->basePackageFilePath(); m_symbianPlatform = s60runConfig->symbianPlatform(); @@ -542,6 +563,7 @@ void S60DeviceRunControlBase::signsisProcessFinished() //TODO sisx destination and file path user definable m_launcher->setTrkServerName(m_serialPortName); + m_launcher->setSerialFrame(m_communicationType == SerialPortCommunication); const QString copySrc(m_baseFileName + ".sisx"); const QString copyDst = QString("C:\\Data\\%1.sisx").arg(QFileInfo(m_baseFileName).fileName()); const QString runFileName = QString("C:\\sys\\bin\\%1.exe").arg(m_targetName); @@ -689,6 +711,7 @@ S60DeviceDebugRunControl::S60DeviceDebugRunControl(const QSharedPointerremoteChannel = rc->serialPortName(); + m_startParams->remoteChannelType = rc->communicationType(); m_startParams->startMode = Debugger::StartInternal; m_startParams->toolChainType = rc->toolChainType(); } diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h index 41b48a9e248..1efaca48f4a 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h @@ -64,6 +64,10 @@ public: QString serialPortName() const; void setSerialPortName(const QString &name); + // See SerialDeviceListener + int communicationType() const; + void setCommunicationType(int t); + QString targetName() const; QString basePackageFilePath() const; QString symbianPlatform() const; @@ -98,7 +102,8 @@ private: QString m_packageTemplateFileName; bool m_cachedTargetInformationValid; QString m_serialPortName; - SigningMode m_signingMode; + int m_communicationType; + SigningMode m_signingMode; QString m_customSignaturePath; QString m_customKeyPath; }; @@ -163,6 +168,7 @@ private: QString m_serialPortName; QString m_serialPortFriendlyName; + int m_communicationType; QString m_targetName; QString m_baseFileName; QString m_symbianPlatform; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp index b0b1b258300..c0964e6fbb9 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp @@ -50,6 +50,8 @@ #include #include +Q_DECLARE_METATYPE(Qt4ProjectManager::Internal::CommunicationDevice) + namespace Qt4ProjectManager { namespace Internal { @@ -167,16 +169,16 @@ void S60DeviceRunConfigurationWidget::updateSerialDevices() m_serialPortsCombo->clear(); clearDeviceInfo(); const QString previousRunConfigurationPortName = m_runConfiguration->serialPortName(); - const QList serialDevices = S60Manager::instance()->serialDeviceLister()->serialDevices(); + const QList devices = S60Manager::instance()->serialDeviceLister()->communicationDevices(); int newIndex = -1; - for (int i = 0; i < serialDevices.size(); ++i) { - const SerialDeviceLister::SerialDevice &device = serialDevices.at(i); - m_serialPortsCombo->addItem(device.friendlyName, device.portName); + for (int i = 0; i < devices.size(); ++i) { + const CommunicationDevice &device = devices.at(i); + m_serialPortsCombo->addItem(device.friendlyName, qVariantFromValue(device)); if (device.portName == previousRunConfigurationPortName) newIndex = i; } // Set new index: prefer to keep old or set to 0, if available. - if (newIndex == -1 && !serialDevices.empty()) + if (newIndex == -1 && !devices.empty()) newIndex = 0; m_serialPortsCombo->setCurrentIndex(newIndex); if (newIndex == -1) { @@ -184,20 +186,25 @@ void S60DeviceRunConfigurationWidget::updateSerialDevices() m_runConfiguration->setSerialPortName(QString()); } else { m_deviceInfoButton->setEnabled(true); - const QString newPortName = portName(newIndex); + const QString newPortName = device(newIndex).portName; if (newPortName != previousRunConfigurationPortName) m_runConfiguration->setSerialPortName(newPortName); } } -QString S60DeviceRunConfigurationWidget::portName(int index) const +CommunicationDevice S60DeviceRunConfigurationWidget::device(int i) const { - return index >= 0 ? m_serialPortsCombo->itemData(index).toString() : QString(); + if (i >= 0) { + const QVariant data = m_serialPortsCombo->itemData(i); + if (qVariantCanConvert(data)) + return qVariantValue(data); + } + return CommunicationDevice(SerialPortCommunication); } -QString S60DeviceRunConfigurationWidget::currentPortName() const +CommunicationDevice S60DeviceRunConfigurationWidget::currentDevice() const { - return portName(m_serialPortsCombo->currentIndex()); + return device(m_serialPortsCombo->currentIndex()); } void S60DeviceRunConfigurationWidget::nameEdited(const QString &text) @@ -212,7 +219,9 @@ void S60DeviceRunConfigurationWidget::updateTargetInformation() void S60DeviceRunConfigurationWidget::setSerialPort(int index) { - m_runConfiguration->setSerialPortName(portName(index)); + const CommunicationDevice d = device(index); + m_runConfiguration->setSerialPortName(d.portName); + m_runConfiguration->setCommunicationType(d.type); m_deviceInfoButton->setEnabled(index >= 0); clearDeviceInfo(); updateSummary(); @@ -252,7 +261,7 @@ void S60DeviceRunConfigurationWidget::updateSummary() tr(""); const QString signature = m_runConfiguration->signingMode() == S60DeviceRunConfiguration::SignCustom ? tr("(custom certificate)") : - tr("(self-signed certificate)"); + tr("(self-signed certificate)"); m_detailsWidget->setSummaryText(tr("Summary: Run on '%1' %2").arg(device, signature)); } @@ -284,7 +293,9 @@ bool S60DeviceRunConfigurationWidget::getDeviceInfo(QString *message) // Do a launcher run with the ping protocol. Instantiate launcher on heap // as not to introduce delays when destructing a device with timeout trk::Launcher *launcher = new trk::Launcher(trk::Launcher::ActionPingOnly, this); - launcher->setTrkServerName(currentPortName()); + const CommunicationDevice commDev = currentDevice(); + launcher->setSerialFrame(commDev.type == SerialPortCommunication); + launcher->setTrkServerName(commDev.portName); if (!launcher->startServer(message)) { launcher->deleteLater(); return false; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.h b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.h index 65c5d192443..1863f5d5e5e 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.h @@ -47,6 +47,7 @@ namespace Utils { namespace Qt4ProjectManager { namespace Internal { +struct CommunicationDevice; class S60DeviceRunConfiguration; /* Configuration widget for S60 devices on serial ports that are @@ -73,8 +74,9 @@ private slots: void clearDeviceInfo(); private: - inline QString currentPortName() const; - inline QString portName(int index) const; + inline CommunicationDevice device(int i) const; + inline CommunicationDevice currentDevice() const; + bool getDeviceInfo(QString *message); void setDeviceInfoLabel(const QString &message, bool isError = false); diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp index 08343e58d5d..a9aa6dceb58 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp @@ -31,8 +31,11 @@ #include #include +#include #include #include +#include +#include namespace { const char * const SYMBIAN_SDKS_KEY = "HKEY_LOCAL_MACHINE\\Software\\Symbian\\EPOC SDKs"; @@ -47,17 +50,58 @@ namespace { const char * const DEVICE_TOOLSROOT = "toolsroot"; } -using namespace Qt4ProjectManager::Internal; +namespace Qt4ProjectManager { +namespace Internal { + +S60Devices::Device::Device() : + isDefault(false) +{ +} + +QString S60Devices::Device::toHtml() const +{ + QString rc; + QTextStream str(&rc); + str << "" + << "" + << "" + << "" + << "" + << ""; + return rc; +} S60Devices::S60Devices(QObject *parent) : QObject(parent) { } +bool S60Devices::readLinux() +{ + m_errorString = QLatin1String("not implemented."); + return false; +} + bool S60Devices::read() { m_devices.clear(); - m_errorString = QString(); + m_errorString.clear(); +#ifdef Q_OS_WIN + return readWin(); +#else + return readLinux(); +#endif +} + +// Windows EPOC + +bool S60Devices::readWin() +{ // Check the windows registry via QSettings for devices.xml path QSettings settings(SYMBIAN_SDKS_KEY, QSettings::NativeFormat); QString devicesXmlPath = settings.value(SYMBIAN_PATH_KEY).toString(); @@ -180,3 +224,22 @@ QString S60Devices::cleanedRootPath(const QString &deviceRoot) } return path; } + +QDebug operator<<(QDebug db, const S60Devices::Device &d) +{ + QDebug nospace = db.nospace(); + nospace << "id='" << d.id << "' name='" << d.name << "' default=" + << d.isDefault << " Epoc='" << d.epocRoot << "' tools='" + << d.toolsRoot << "' Qt='" << d.qt << '\''; + return db; +} + +QDebug operator<<(QDebug dbg, const S60Devices &d) +{ + foreach(const S60Devices::Device &device, d.devices()) + dbg << device; + return dbg; +} + +} // namespace Internal +} // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devices.h b/src/plugins/qt4projectmanager/qt-s60/s60devices.h index cb57aac8a1b..839fd32967a 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devices.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60devices.h @@ -34,6 +34,10 @@ #include #include +QT_BEGIN_NAMESPACE +class QDebug; +QT_END_NAMESPACE + namespace Qt4ProjectManager { namespace Internal { @@ -42,6 +46,9 @@ class S60Devices : public QObject Q_OBJECT public: struct Device { + Device(); + QString toHtml() const; + QString id; QString name; bool isDefault; @@ -62,10 +69,15 @@ signals: void qtVersionsChanged(); private: + bool readLinux(); + bool readWin(); QString m_errorString; QList m_devices; }; +QDebug operator<<(QDebug dbg, const S60Devices::Device &d); +QDebug operator<<(QDebug dbg, const S60Devices &d); + } // namespace Internal } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp index f9a4f216e2d..81023915f02 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp @@ -64,8 +64,13 @@ void S60DevicesWidget::updateDevicesList() QList devices = m_devices->devices(); m_ui->list->clear(); foreach (const S60Devices::Device &device, devices) { - m_ui->list->addTopLevelItem(new QTreeWidgetItem(QStringList() << device.epocRoot - << (device.qt.isEmpty()?tr("No Qt installed"):device.qt))); + QStringList columns; + columns << device.epocRoot << (device.qt.isEmpty()?tr("No Qt installed"):device.qt); + QTreeWidgetItem *item = new QTreeWidgetItem(columns); + const QString tooltip = device.toHtml(); + item->setToolTip(0, tooltip); + item->setToolTip(1, tooltip); + m_ui->list->addTopLevelItem(item); } } diff --git a/src/plugins/qt4projectmanager/qt-s60/serialdevicelister.cpp b/src/plugins/qt4projectmanager/qt-s60/serialdevicelister.cpp index a1a0b7b8592..35e2b64254e 100644 --- a/src/plugins/qt4projectmanager/qt-s60/serialdevicelister.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/serialdevicelister.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -42,6 +43,17 @@ namespace { const char * const USBSER = "Services/usbser/Enum"; } +const char *SerialDeviceLister::linuxBlueToothDeviceRootC = "/dev/rfcomm"; + +CommunicationDevice::CommunicationDevice(DeviceCommunicationType t, + const QString &p, + const QString &f) : + portName(p), + friendlyName(f), + type(t) +{ +} + SerialDeviceLister::SerialDeviceLister(QObject *parent) : QObject(parent), m_initialized(false) @@ -53,18 +65,18 @@ SerialDeviceLister::~SerialDeviceLister() { } -QList SerialDeviceLister::serialDevices() const +QList SerialDeviceLister::communicationDevices() const { if (!m_initialized) { updateSilently(); m_initialized = true; } - return m_devices; + return m_devices2; } QString SerialDeviceLister::friendlyNameForPort(const QString &port) const { - foreach (const SerialDevice &device, m_devices) { + foreach (const CommunicationDevice &device, m_devices2) { if (device.portName == port) return device.friendlyName; } @@ -79,19 +91,44 @@ void SerialDeviceLister::update() void SerialDeviceLister::updateSilently() const { - m_devices.clear(); + m_devices2 = serialPorts() + blueToothDevices(); +} + +QList SerialDeviceLister::serialPorts() const +{ + QList rc; #ifdef Q_OS_WIN32 QSettings registry(REGKEY_CURRENT_CONTROL_SET, QSettings::NativeFormat); - int count = registry.value(QString::fromLatin1("%1/Count").arg(USBSER)).toInt(); + const int count = registry.value(QString::fromLatin1("%1/Count").arg(USBSER)).toInt(); for (int i = 0; i < count; ++i) { QString driver = registry.value(QString::fromLatin1("%1/%2").arg(USBSER).arg(i)).toString(); if (driver.contains("JAVACOMM")) { driver.replace('\\', '/'); - SerialDeviceLister::SerialDevice device; + CommunicationDevice device(SerialPortCommunication); device.friendlyName = registry.value(QString::fromLatin1("Enum/%1/FriendlyName").arg(driver)).toString(); device.portName = registry.value(QString::fromLatin1("Enum/%1/Device Parameters/PortName").arg(driver)).toString(); - m_devices.append(device); + rc.append(device); } } #endif + return rc; +} + +QList SerialDeviceLister::blueToothDevices() const +{ + QList rc; +#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) + // Bluetooth devices are created on connection. List the existing ones + // or at least the first one. + const QString prefix = QLatin1String(linuxBlueToothDeviceRootC); + const QString friendlyFormat = QLatin1String("Bluetooth device (%1)"); + for (int d = 0; d < 4; d++) { + CommunicationDevice device(BlueToothCommunication, prefix + QString::number(d)); + if (d == 0 || QFileInfo(device.portName).exists()) { + device.friendlyName = friendlyFormat.arg(device.portName); + rc.push_back(device); + } + } +#endif + return rc; } diff --git a/src/plugins/qt4projectmanager/qt-s60/serialdevicelister.h b/src/plugins/qt4projectmanager/qt-s60/serialdevicelister.h index f2f71842c69..b1fb65507ce 100644 --- a/src/plugins/qt4projectmanager/qt-s60/serialdevicelister.h +++ b/src/plugins/qt4projectmanager/qt-s60/serialdevicelister.h @@ -30,32 +30,36 @@ #ifndef SERIALDEVICELISTER_H #define SERIALDEVICELISTER_H -#include -#include #include -#include - -//#ifdef Q_OS_WIN32 -//#include -//#include -//#endif namespace Qt4ProjectManager { namespace Internal { +enum DeviceCommunicationType { + SerialPortCommunication = 0, + BlueToothCommunication = 1 +}; + +struct CommunicationDevice { + explicit CommunicationDevice(DeviceCommunicationType type = SerialPortCommunication, + const QString &portName = QString(), + const QString &friendlyName = QString()); + QString portName; + QString friendlyName; + DeviceCommunicationType type; +}; + class SerialDeviceLister : public QObject { Q_OBJECT public: + static const char *linuxBlueToothDeviceRootC; - struct SerialDevice { - QString portName; - QString friendlyName; - }; - - SerialDeviceLister(QObject *parent = 0); + explicit SerialDeviceLister(QObject *parent = 0); ~SerialDeviceLister(); - QList serialDevices() const; + + QList communicationDevices() const; + QString friendlyNameForPort(const QString &port) const; public slots: @@ -66,9 +70,11 @@ signals: private: void updateSilently() const; + QList serialPorts() const; + QList blueToothDevices() const; mutable bool m_initialized; - mutable QList m_devices; + mutable QList m_devices2; }; } // Internal diff --git a/src/shared/trk/trkdevice.cpp b/src/shared/trk/trkdevice.cpp index ef7bc8b34f8..7fb21c0069e 100644 --- a/src/shared/trk/trkdevice.cpp +++ b/src/shared/trk/trkdevice.cpp @@ -882,7 +882,7 @@ TrkDevice::~TrkDevice() bool TrkDevice::open(const QString &port, QString *errorMessage) { if (d->verbose) - qDebug() << "Opening" << port << "is open: " << isOpen(); + qDebug() << "Opening" << port << "is open: " << isOpen() << " serialFrame=" << serialFrame(); close(); #ifdef Q_OS_WIN d->deviceContext->device = CreateFile(port.toStdWString().c_str(), From 2a7fa04101bf487f4fd6dd04297573f62157d41a Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 22 Oct 2009 16:46:26 +0200 Subject: [PATCH 33/91] Released the memory allocated in the memory pool when backtracking from Parser::parseTemplateId(). --- src/shared/cplusplus/MemoryPool.cpp | 13 ++++++++++++ src/shared/cplusplus/MemoryPool.h | 16 +++++++++++++++ src/shared/cplusplus/Parser.cpp | 32 +++++++++++++++++++++++++++++ src/shared/cplusplus/Parser.h | 3 +++ 4 files changed, 64 insertions(+) diff --git a/src/shared/cplusplus/MemoryPool.cpp b/src/shared/cplusplus/MemoryPool.cpp index 2002a654350..1453c62cd69 100644 --- a/src/shared/cplusplus/MemoryPool.cpp +++ b/src/shared/cplusplus/MemoryPool.cpp @@ -110,6 +110,19 @@ void *MemoryPool::allocate_helper(size_t size) return addr; } +MemoryPool::State MemoryPool::state() const +{ return State(ptr, _blockCount); } + +void MemoryPool::rewind(const State &state) +{ + if (_blockCount == state.blockCount && state.ptr < ptr) { + if (_initializeAllocatedMemory) + memset(state.ptr, '\0', ptr - state.ptr); + + ptr = state.ptr; + } +} + Managed::Managed() { } diff --git a/src/shared/cplusplus/MemoryPool.h b/src/shared/cplusplus/MemoryPool.h index e0f1ff87017..5b6fae925ff 100644 --- a/src/shared/cplusplus/MemoryPool.h +++ b/src/shared/cplusplus/MemoryPool.h @@ -79,6 +79,22 @@ public: return allocate_helper(size); } + struct State + { + char *ptr; + char *end; + int blockCount; + + inline bool isValid() const + { return ptr != 0; } + + inline State(char *ptr = 0, int blockCount = 0) + : ptr(ptr), blockCount(blockCount) {} + }; + + State state() const; + void rewind(const State &state); + private: void *allocate_helper(size_t size); diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 8f3bd549ce4..24851c991da 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -88,6 +88,30 @@ int DebugRule::depth = 0; # define DEBUG_THIS_RULE() do {} while (0) #endif +class Parser::Rewind +{ + Parser *_parser; + MemoryPool::State _state; + +public: + inline Rewind(Parser *parser) + : _parser(parser) {} + + inline void operator()(unsigned tokenIndex) + { rewind(tokenIndex); } + + inline void mark() + { _state = _parser->_pool->state(); } + + inline void rewind(unsigned tokenIndex) + { + _parser->rewind(tokenIndex); + + if (_state.isValid()) + _parser->_pool->rewind(_state); + } +}; + Parser::Parser(TranslationUnit *unit) : _translationUnit(unit), _control(_translationUnit->control()), @@ -302,6 +326,11 @@ bool Parser::parseClassOrNamespaceName(NameAST *&node) bool Parser::parseTemplateId(NameAST *&node) { DEBUG_THIS_RULE(); + + const unsigned start = cursor(); + Rewind rewind(this); + rewind.mark(); + if (LA() == T_IDENTIFIER && LA(2) == T_LESS) { TemplateIdAST *ast = new (_pool) TemplateIdAST; ast->identifier_token = consumeToken(); @@ -315,6 +344,9 @@ bool Parser::parseTemplateId(NameAST *&node) } } } + + rewind(start); + return false; } diff --git a/src/shared/cplusplus/Parser.h b/src/shared/cplusplus/Parser.h index 3ca3371d815..2a7c15dfa3e 100644 --- a/src/shared/cplusplus/Parser.h +++ b/src/shared/cplusplus/Parser.h @@ -298,6 +298,9 @@ private: bool _inFunctionBody: 1; bool _inObjCImplementationContext: 1; + class Rewind; + friend class Rewind; + private: Parser(const Parser& source); void operator =(const Parser& source); From 60578cb556be583a54c2192f76a55dce97765dbe Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Thu, 22 Oct 2009 17:57:16 +0200 Subject: [PATCH 34/91] Add validChanged(bool) to PathChooser. This is useful when e.g. connecting directly to the setEnabled() slot of a Widget. --- src/libs/utils/basevalidatinglineedit.cpp | 4 +++- src/libs/utils/basevalidatinglineedit.h | 1 + src/libs/utils/pathchooser.cpp | 1 + src/libs/utils/pathchooser.h | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/basevalidatinglineedit.cpp b/src/libs/utils/basevalidatinglineedit.cpp index c70aa59e1f5..255c9e6a347 100644 --- a/src/libs/utils/basevalidatinglineedit.cpp +++ b/src/libs/utils/basevalidatinglineedit.cpp @@ -138,8 +138,10 @@ void BaseValidatingLineEdit::slotChanged(const QString &t) m_bd->m_state = newState; m_bd->m_firstChange = false; setTextColor(this, newState == Invalid ? m_bd->m_errorTextColor : m_bd->m_okTextColor); - if (validHasChanged) + if (validHasChanged) { + emit validChanged(newState == Valid); emit validChanged(); + } } } diff --git a/src/libs/utils/basevalidatinglineedit.h b/src/libs/utils/basevalidatinglineedit.h index 77031bbd96c..5773d4f7451 100644 --- a/src/libs/utils/basevalidatinglineedit.h +++ b/src/libs/utils/basevalidatinglineedit.h @@ -81,6 +81,7 @@ public: signals: void validChanged(); + void validChanged(bool validState); void validReturnPressed(); protected: diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp index c550ecbc39f..76e4247931b 100644 --- a/src/libs/utils/pathchooser.cpp +++ b/src/libs/utils/pathchooser.cpp @@ -108,6 +108,7 @@ PathChooser::PathChooser(QWidget *parent) : connect(m_d->m_lineEdit, SIGNAL(validReturnPressed()), this, SIGNAL(returnPressed())); connect(m_d->m_lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(changed(QString))); connect(m_d->m_lineEdit, SIGNAL(validChanged()), this, SIGNAL(validChanged())); + connect(m_d->m_lineEdit, SIGNAL(validChanged(bool)), this, SIGNAL(validChanged(bool))); connect(m_d->m_lineEdit, SIGNAL(editingFinished()), this, SIGNAL(editingFinished())); m_d->m_lineEdit->setMinimumWidth(200); diff --git a/src/libs/utils/pathchooser.h b/src/libs/utils/pathchooser.h index ee3e6eaf40c..d974e90d031 100644 --- a/src/libs/utils/pathchooser.h +++ b/src/libs/utils/pathchooser.h @@ -99,6 +99,7 @@ private: signals: void validChanged(); + void validChanged(bool validState); void changed(const QString &text); void editingFinished(); void beforeBrowsing(); From 81de0f86ba9cdbe52d2732e7c7407fb6ae25cc32 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Thu, 22 Oct 2009 17:59:17 +0200 Subject: [PATCH 35/91] Workaround for Linux Distro Qt where examples live in write-protected dirs. Offer to copy the project into an alternative root. --- .../gettingstartedwelcomepagewidget.cpp | 87 ++++++++++++++++++- 1 file changed, 84 insertions(+), 3 deletions(-) diff --git a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp index dca4ab11936..a85023a2404 100644 --- a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp +++ b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp @@ -33,6 +33,8 @@ #include #include +#include + #include #include @@ -42,8 +44,12 @@ #include #include #include +#include #include +#include #include +#include +#include namespace Qt4ProjectManager { namespace Internal { @@ -159,17 +165,92 @@ void GettingStartedWelcomePageWidget::slotEnableExampleButton(int index) ui->openExampleButton->setEnabled(!fileName.isEmpty()); } +namespace { +void copyRecursive(const QDir& from, const QDir& to, const QString& dir) +{ + QDir dest(to); + dest.mkdir(dir); + dest.cd(dir); + QDir src(from); + src.cd(dir); + foreach(const QFileInfo& roFile, src.entryInfoList(QDir::Files)) { + QFile::copy(roFile.absoluteFilePath(), dest.absolutePath() + '/' + roFile.fileName()); + } + foreach(const QString& roDir, src.entryList(QDir::NoDotAndDotDot|QDir::Dirs)) { + copyRecursive(src, dest, QDir(roDir).dirName()); + } +} +} // namespace + void GettingStartedWelcomePageWidget::slotOpenExample() { QComboBox *box = ui->examplesComboBox; QString proFile = box->itemData(box->currentIndex(), Qt::UserRole).toString(); QString helpFile = box->itemData(box->currentIndex(), Qt::UserRole + 1).toString(); QStringList files; - QFileInfo fi(proFile); - QString tryFile = fi.path() + "/main.cpp"; + QFileInfo proFileInfo(proFile); + // If the Qt is a distro Qt on Linux, it will not be writable, hence compilation will fail + if (!proFileInfo.isWritable()) + { + QDialog d; + QGridLayout *lay = new QGridLayout(&d); + QLabel *descrLbl = new QLabel; + d.setWindowTitle(tr("Copy Project to writable Location?")); + descrLbl->setTextFormat(Qt::RichText); + descrLbl->setWordWrap(true); + descrLbl->setText(tr("

The project you are about to open is located in the " + "write-protected location:

%1
" + "

Please select a writable location below and click \"Copy Project and Open\" " + "to open a modifiable copy of the project or click \"Keep Project and Open\" " + "to open the project in location.

Note: You will not " + "be able to alter or compile your project in the current location.

") + .arg(QDir::toNativeSeparators(proFileInfo.dir().absolutePath()))); + lay->addWidget(descrLbl, 0, 0, 1, 2); + QLabel *txt = new QLabel(tr("&Location:")); + Utils::PathChooser *chooser = new Utils::PathChooser; + txt->setBuddy(chooser); + chooser->setExpectedKind(Utils::PathChooser::Directory); + QSettings *settings = Core::ICore::instance()->settings(); + chooser->setPath(settings->value( + QString::fromLatin1("General/ProjectsFallbackRoot"), QDir::homePath()).toString()); + lay->addWidget(txt, 1, 0); + lay->addWidget(chooser, 1, 1); + QDialogButtonBox *bb = new QDialogButtonBox; + connect(bb, SIGNAL(accepted()), &d, SLOT(accept())); + connect(bb, SIGNAL(rejected()), &d, SLOT(reject())); + QPushButton *copyBtn = bb->addButton(tr("&Copy Project and Open"), QDialogButtonBox::AcceptRole); + copyBtn->setDefault(true); + bb->addButton(tr("&Keep Project and Open"), QDialogButtonBox::RejectRole); + lay->addWidget(bb, 2, 0, 1, 2); + connect(chooser, SIGNAL(validChanged(bool)), copyBtn, SLOT(setEnabled(bool))); + if (d.exec() == QDialog::Accepted) { + QString exampleDirName = proFileInfo.dir().dirName(); + QString toDir = chooser->path(); + settings->setValue(QString::fromLatin1("General/ProjectsFallbackRoot"), toDir); + QDir toDirWithExamplesDir(toDir); + if (toDirWithExamplesDir.cd(exampleDirName)) { + toDirWithExamplesDir.cdUp(); // step out, just to not be in the way + QMessageBox::warning(topLevelWidget(), tr("Warning"), + tr("The specified location already exists. " + "Please specify a valid location."), + QMessageBox::Ok, QMessageBox::NoButton); + return; + } else { + QDir from = proFileInfo.dir(); + from.cdUp(); + copyRecursive(from, toDir, exampleDirName); + // set vars to new location + proFileInfo = QFileInfo(toDir + '/'+ exampleDirName + '/' + proFileInfo.fileName()); + proFile = proFileInfo.absoluteFilePath(); + } + } + } + + + QString tryFile = proFileInfo.path() + "/main.cpp"; files << proFile; if(!QFile::exists(tryFile)) - tryFile = fi.path() + '/' + fi.baseName() + ".cpp"; + tryFile = proFileInfo.path() + '/' + proFileInfo.baseName() + ".cpp"; if(QFile::exists(tryFile)) files << tryFile; Core::ICore::instance()->openFiles(files); From 8c52cca63617d2c0764946f600aeaa9069d35ebb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 17:36:18 +0200 Subject: [PATCH 36/91] generate install targets also for the not-yet-built QM files --- share/qtcreator/translations/translations.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/share/qtcreator/translations/translations.pro b/share/qtcreator/translations/translations.pro index 46fb2242527..5c384ccb7f0 100644 --- a/share/qtcreator/translations/translations.pro +++ b/share/qtcreator/translations/translations.pro @@ -61,4 +61,5 @@ isEmpty(vcproj) { qmfiles.files = $$prependAll(LANGUAGES, $$OUT_PWD/qtcreator_,.qm) qmfiles.path = /share/qtcreator/translations +qmfiles.CONFIG += no_check_exist INSTALLS += qmfiles From 89bc59907575f0b6b733442958f306253e5152a0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 17:53:36 +0200 Subject: [PATCH 37/91] fix spurious assertion failure --- src/plugins/debugger/gdb/gdbengine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index aa800d31bd4..cbbeb1cbef8 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1529,7 +1529,8 @@ void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp) void GdbEngine::continueInferiorInternal() { - QTC_ASSERT(state() == InferiorStopped, qDebug() << state()); + QTC_ASSERT(state() == InferiorStopped || state() == InferiorStarting, + qDebug() << state()); setState(InferiorRunningRequested); postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue)); } From 920ed112963678463e8b94eebd8a95a37067333d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 14:18:07 +0200 Subject: [PATCH 38/91] reloadSourceFiles() may be called while the inferior is running --- 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 cbbeb1cbef8..8572cbfa893 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2221,7 +2221,7 @@ void GdbEngine::handleModulesList(const GdbResponse &response) void GdbEngine::reloadSourceFiles() { - postCommand(_("-file-list-exec-source-files"), CB(handleQuerySources)); + postCommand(_("-file-list-exec-source-files"), NeedsStop, CB(handleQuerySources)); } From 4d5c81ac520712bde98b09c66a7d8207e14fa223 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 11:04:55 +0200 Subject: [PATCH 39/91] remove unneeded code --- src/plugins/debugger/gdb/gdbengine.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 8572cbfa893..187381ac6ee 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -3889,10 +3889,8 @@ void GdbEngine::tryLoadDebuggingHelpers() postCommand(_("call (void)dlopen(\"") + GdbMi::escapeCString(lib) + _("\", " STRINGIFY(RTLD_NOW) ")"), CB(handleDebuggingHelperSetup)); //postCommand(_("sharedlibrary ") + dotEscape(lib)); - m_debuggingHelperState = DebuggingHelperLoadTried; #else //postCommand(_("p dlopen")); - QString flag = QString::number(RTLD_NOW); postCommand(_("sharedlibrary libc")); // for malloc postCommand(_("sharedlibrary libdl")); // for dlopen postCommand(_("call (void*)dlopen(\"") + GdbMi::escapeCString(lib) + _("\", " STRINGIFY(RTLD_NOW) ")"), From 5b01cbcb2b6ec3027622fa1c3d89eb5e44e266c8 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 11:08:06 +0200 Subject: [PATCH 40/91] run-time detection of apple gdb in theory, we should support fsf gdb on apple now. this also cleans and documents some execution paths. --- src/plugins/debugger/gdb/gdbengine.cpp | 99 +++++++++++--------------- src/plugins/debugger/gdb/gdbengine.h | 3 +- 2 files changed, 44 insertions(+), 58 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 187381ac6ee..49842b4bc6f 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -250,6 +250,7 @@ void GdbEngine::initializeVariables() m_debuggingHelperState = DebuggingHelperUninitialized; m_gdbVersion = 100; m_gdbBuildVersion = -1; + m_isMacGdb = false; m_isSynchroneous = false; m_fullToShortName.clear(); @@ -1263,6 +1264,7 @@ void GdbEngine::handleShowVersion(const GdbResponse &response) if (response.resultClass == GdbResultDone) { m_gdbVersion = 100; m_gdbBuildVersion = -1; + m_isMacGdb = false; QString msg = QString::fromLocal8Bit(response.data.findChild("consolestreamoutput").data()); QRegExp supported(_("GNU gdb(.*) (\\d+)\\.(\\d+)(\\.(\\d+))?(-(\\d+))?")); if (supported.indexIn(msg) == -1) { @@ -1290,8 +1292,9 @@ void GdbEngine::handleShowVersion(const GdbResponse &response) + 100 * supported.cap(3).toInt() + 1 * supported.cap(5).toInt(); m_gdbBuildVersion = supported.cap(7).toInt(); - debugMessage(_("GDB VERSION: %1, BUILD: %2 ").arg(m_gdbVersion) - .arg(m_gdbBuildVersion)); + m_isMacGdb = msg.contains(__("Apple version")); + debugMessage(_("GDB VERSION: %1, BUILD: %2%3").arg(m_gdbVersion) + .arg(m_gdbBuildVersion).arg(_(m_isMacGdb ? " (APPLE)" : ""))); } //qDebug () << "VERSION 3:" << m_gdbVersion << m_gdbBuildVersion; } @@ -1805,21 +1808,15 @@ void GdbEngine::sendInsertBreakpoint(int index) // set up fallback in case of pending breakpoints which aren't handled // by the MI interface -#if defined(Q_OS_WIN) - QString cmd = _("-break-insert "); - //if (!data->condition.isEmpty()) - // cmd += "-c " + data->condition + " "; -#elif defined(Q_OS_MAC) - QString cmd = _("-break-insert -l -1 "); - //if (!data->condition.isEmpty()) - // cmd += "-c " + data->condition + " "; -#else - QString cmd = _("-break-insert -f "); - if (m_gdbAdapter->isTrkAdapter()) + QString cmd; + if (m_isMacGdb) + cmd = _("-break-insert -l -1 "); + else if (m_gdbVersion >= 60800) // Probably some earlier version would work as well ... + cmd = _("-break-insert -f "); + else cmd = _("-break-insert "); //if (!data->condition.isEmpty()) - // cmd += _("-c ") + data->condition + ' '; -#endif + // cmd += _("-c ") + data->condition + _c(' '); cmd += where; gdbOutputAvailable(LogStatus, _("Current state: %1").arg(state())); postCommand(cmd, NeedsStop, CB(handleBreakInsert), index); @@ -1942,20 +1939,18 @@ void GdbEngine::handleBreakInsert(const GdbResponse &response) attemptBreakpointSynchronization(); handler->updateMarkers(); } else { - const BreakpointData *data = handler->at(index); - // Note that it is perfectly correct that the file name is put - // in quotes but not escaped. GDB simply is like that. -#if defined(Q_OS_WIN) || defined(Q_OS_MAC) - QFileInfo fi(data->fileName); - QString where = _c('"') + fi.fileName() + _("\":") - + data->lineNumber; -#else - QString where = _c('"') + data->fileName + _("\":") - + data->lineNumber; - // Should not happen with -break-insert -f. gdb older than 6.8? - QTC_ASSERT(false, /**/); -#endif - postCommand(_("break ") + where, CB(handleBreakInsert1), index); + if (m_gdbVersion < 60800 && !m_isMacGdb) { + // Note that it is perfectly correct that the file name is put + // in quotes but not escaped. GDB simply is like that. + const BreakpointData *data = handler->at(index); + QFileInfo fi(data->fileName); + QString where = _c('"') + fi.fileName() + _("\":") + + data->lineNumber; + postCommand(_("break ") + where, CB(handleBreakInsert1), index); + } else { + // The breakpoint would be pending even if the path simply cannot be found. + QTC_ASSERT(false, /**/); + } } } @@ -2296,11 +2291,7 @@ StackFrame GdbEngine::parseStackFrame(const GdbMi &frameMi, int level) void GdbEngine::handleStackListFrames(const GdbResponse &response) { - #if defined(Q_OS_MAC) - bool handleIt = true; - #else - bool handleIt = response.resultClass == GdbResultDone; - #endif + bool handleIt = (m_isMacGdb || response.resultClass == GdbResultDone); if (!handleIt) { // That always happens on symbian gdb with // ^error,data={msg="Previous frame identical to this frame (corrupt stack?)" @@ -2371,15 +2362,11 @@ void GdbEngine::handleStackListFrames(const GdbResponse &response) if (targetFrame == -1) targetFrame = 0; - #ifdef Q_OS_MAC // Mac gdb does not add the location to the "stopped" message, // so the early gotoLocation() was not triggered. Force it here. - bool jump = true; - #else // For targetFrame == 0 we already issued a 'gotoLocation' // when reading the *stopped message. - bool jump = targetFrame != 0; - #endif + bool jump = (m_isMacGdb || targetFrame != 0); manager()->stackHandler()->setCurrentIndex(targetFrame); if (jump || cookie.gotoLocation) { @@ -2520,12 +2507,9 @@ void GdbEngine::handleRegisterListValues(const GdbResponse &response) bool GdbEngine::supportsThreads() const { -#ifdef Q_OS_MAC - return true; -#endif // FSF gdb 6.3 crashes happily on -thread-list-ids. So don't use it. // The test below is a semi-random pick, 6.8 works fine - return m_gdbVersion > 60500; + return m_isMacGdb || m_gdbVersion > 60500; } @@ -3588,16 +3572,17 @@ WatchData GdbEngine::localVariable(const GdbMi &item, // numchild="1",type="const QtSharedPointer::Basic 1) - return WatchData(); - QByteArray name = item.findChild("exp").data(); -#else - QByteArray name = item.findChild("name").data(); -#endif + QByteArray name; + if (m_isMacGdb) { + int numExps = 0; + foreach (const GdbMi &child, item.children()) + numExps += int(child.name() == "exp"); + if (numExps > 1) + return WatchData(); + name = item.findChild("exp").data(); + } else { + name = item.findChild("name").data(); + } const QMap::iterator it = seen->find(name); if (it != seen->end()) { const int n = it.value(); @@ -4260,9 +4245,9 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb) postCommand(_("set width 0")); postCommand(_("set height 0")); - #ifdef Q_OS_MAC - postCommand(_("-gdb-set inferior-auto-start-cfm off")); - postCommand(_("-gdb-set sharedLibrary load-rules " + if (m_isMacGdb) { + postCommand(_("-gdb-set inferior-auto-start-cfm off")); + postCommand(_("-gdb-set sharedLibrary load-rules " "dyld \".*libSystem.*\" all " "dyld \".*libauto.*\" all " "dyld \".*AppKit.*\" all " @@ -4271,7 +4256,7 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb) "dyld \".*CFDataFormatters.*\" all " "dyld \".*libobjc.*\" all " "dyld \".*CarbonDataFormatters.*\" all")); - #endif + } QString scriptFileName = theDebuggerStringSetting(GdbScriptFile); if (!scriptFileName.isEmpty()) { diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index a891a557472..6e6db609c48 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -260,8 +260,9 @@ private: ////////// Gdb Output, State & Capability Handling ////////// void handleShowVersion(const GdbResponse &response); void handleIsSynchroneous(const GdbResponse &response); - int m_gdbVersion; // 6.8.0 is 680 + int m_gdbVersion; // 6.8.0 is 60800 int m_gdbBuildVersion; // MAC only? + bool m_isMacGdb; bool m_isSynchroneous; // Can act synchroneously? private: ////////// Inferior Management ////////// From 231eac88cb76e112de0ea7b88f1001371652874a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 14:17:17 +0200 Subject: [PATCH 41/91] even apple gdb wants -f for setting a pending breakpoint --- 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 49842b4bc6f..8ba7d7d6cd8 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1810,7 +1810,7 @@ void GdbEngine::sendInsertBreakpoint(int index) // by the MI interface QString cmd; if (m_isMacGdb) - cmd = _("-break-insert -l -1 "); + cmd = _("-break-insert -l -1 -f "); else if (m_gdbVersion >= 60800) // Probably some earlier version would work as well ... cmd = _("-break-insert -f "); else From 8882e8e4a42a8bf0d06a5930e7f67bd7db44117c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 20:04:59 +0200 Subject: [PATCH 42/91] clearer and less inefficient --- src/plugins/debugger/gdb/gdbengine.cpp | 32 ++++++++++++++------------ 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 8ba7d7d6cd8..605e3a9a3c3 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -489,12 +489,13 @@ void GdbEngine::handleResponse(const QByteArray &buff) } // Show some messages to give the impression something happens. - if (data.startsWith("Reading symbols from ")) + if (data.startsWith("Reading symbols from ")) { showStatusMessage(tr("Reading %1...").arg(_(data.mid(21))), 1000); - if (data.endsWith('\n')) - data.chop(1); - if (data.startsWith("[New ") || data.startsWith("[Thread ")) + } else if (data.startsWith("[New ") || data.startsWith("[Thread ")) { + if (data.endsWith('\n')) + data.chop(1); showStatusMessage(_(data), 1000); + } break; } @@ -875,13 +876,15 @@ void GdbEngine::handleQuerySources(const GdbResponse &response) foreach (const GdbMi &item, files.children()) { QString fileName = QString::fromLocal8Bit(item.findChild("file").data()); GdbMi fullName = item.findChild("fullname"); - QString full = QString::fromLocal8Bit(fullName.data()); - #ifdef Q_OS_WIN - full = QDir::cleanPath(full); - #endif - if (fullName.isValid() && QFileInfo(full).isReadable()) { - m_shortToFullName[fileName] = full; - m_fullToShortName[full] = fileName; + if (fullName.isValid()) { + QString full = QString::fromLocal8Bit(fullName.data()); + if (QFileInfo(full).isReadable()) { + #ifdef Q_OS_WIN + full = QDir::cleanPath(full); + #endif + m_shortToFullName[fileName] = full; + m_fullToShortName[full] = fileName; + } } } if (m_shortToFullName != oldShortToFull) @@ -1150,12 +1153,11 @@ void GdbEngine::handleStop1(const GdbResponse &response) void GdbEngine::handleStop1(const GdbMi &data) { - QByteArray reason = data.findChild("reason").data(); if (m_modulesListOutdated) { reloadModules(); m_modulesListOutdated = false; } - // Need another round trip + QByteArray reason = data.findChild("reason").data(); if (reason == "breakpoint-hit") { showStatusMessage(tr("Stopped at breakpoint.")); GdbMi frame = data.findChild("frame"); @@ -4064,14 +4066,14 @@ QString GdbEngine::parseDisassembler(const GdbMi &lines) foreach (const GdbMi &child, lines.children()) { if (child.hasName("src_and_asm_line")) { // mixed mode - int line = child.findChild("line").data().toInt(); - QString fileName = QFile::decodeName(child.findChild("file").data()); if (!fileLoaded) { + QString fileName = QFile::decodeName(child.findChild("file").data()); QFile file(fullName(fileName)); file.open(QIODevice::ReadOnly); fileContents = file.readAll().split('\n'); fileLoaded = true; } + int line = child.findChild("line").data().toInt(); if (line >= 0 && line < fileContents.size()) ba += " " + fileContents.at(line) + '\n'; GdbMi insn = child.findChild("line_asm_insn"); From 03e3a92806f4c60b02a41ba59dfad8babf6e8ed2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 15:46:49 +0200 Subject: [PATCH 43/91] try harder to keep m_modulesListOutdated in sync with reality this is an epic fail for older gdbs which don't report library events, but at least we tried. --- src/plugins/debugger/gdb/gdbengine.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 605e3a9a3c3..9146e293832 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -417,12 +417,14 @@ void GdbEngine::handleResponse(const QByteArray &buff) QByteArray id = result.findChild("id").data(); if (!id.isEmpty()) showStatusMessage(tr("Library %1 loaded.").arg(_(id))); + m_modulesListOutdated = true; } else if (asyncClass == "library-unloaded") { // Archer has 'id="/usr/lib/libdrm.so.2", // target-name="/usr/lib/libdrm.so.2", // host-name="/usr/lib/libdrm.so.2" QByteArray id = result.findChild("id").data(); showStatusMessage(tr("Library %1 unloaded.").arg(_(id))); + m_modulesListOutdated = true; } else if (asyncClass == "thread-group-created") { // Archer has "{id="28902"}" QByteArray id = result.findChild("id").data(); @@ -451,6 +453,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) #if defined(Q_OS_MAC) } else if (asyncClass == "shlibs-updated") { // MAC announces updated libs + m_modulesListOutdated = true; } else if (asyncClass == "shlibs-added") { // MAC announces added libs // {shlib-info={num="2", name="libmathCommon.A_debug.dylib", @@ -458,6 +461,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) // state="Y", path="/usr/lib/system/libmathCommon.A_debug.dylib", // description="/usr/lib/system/libmathCommon.A_debug.dylib", // loaded_addr="0x7f000", slide="0x7f000", prefix=""}} + m_modulesListOutdated = true; #endif } else { qDebug() << "IGNORED ASYNC OUTPUT" @@ -491,6 +495,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) // Show some messages to give the impression something happens. if (data.startsWith("Reading symbols from ")) { showStatusMessage(tr("Reading %1...").arg(_(data.mid(21))), 1000); + m_modulesListOutdated = true; } else if (data.startsWith("[New ") || data.startsWith("[Thread ")) { if (data.endsWith('\n')) data.chop(1); @@ -1052,6 +1057,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data) const QByteArray &msg = data.findChild("consolestreamoutput").data(); if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) { + m_modulesListOutdated = true; if (theDebuggerBoolSetting(SelectedPluginBreakpoints)) { QString dataStr = _(data.toString()); debugMessage(_("SHARED LIBRARY EVENT: ") + dataStr); @@ -1062,7 +1068,6 @@ void GdbEngine::handleStopResponse(const GdbMi &data) showStatusMessage(tr("Loading %1...").arg(dataStr)); return; } - m_modulesListOutdated = true; // fall through } @@ -1153,10 +1158,8 @@ void GdbEngine::handleStop1(const GdbResponse &response) void GdbEngine::handleStop1(const GdbMi &data) { - if (m_modulesListOutdated) { + if (m_modulesListOutdated) reloadModules(); - m_modulesListOutdated = false; - } QByteArray reason = data.findChild("reason").data(); if (reason == "breakpoint-hit") { showStatusMessage(tr("Stopped at breakpoint.")); @@ -2166,6 +2169,7 @@ QList GdbEngine::moduleSymbols(const QString &moduleName) void GdbEngine::reloadModules() { + m_modulesListOutdated = false; postCommand(_("info shared"), CB(handleModulesList)); } From 07c2451abd28dd2598f0570622b4324288cbaccc Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 23 Oct 2009 11:21:36 +0200 Subject: [PATCH 44/91] Use memoization to reduce the backtracking when parsing template arguments. --- src/shared/cplusplus/Parser.cpp | 25 +++++++++++++++++++++++-- src/shared/cplusplus/Parser.h | 14 +++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 24851c991da..67e260230c0 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -328,8 +328,6 @@ bool Parser::parseTemplateId(NameAST *&node) DEBUG_THIS_RULE(); const unsigned start = cursor(); - Rewind rewind(this); - rewind.mark(); if (LA() == T_IDENTIFIER && LA(2) == T_LESS) { TemplateIdAST *ast = new (_pool) TemplateIdAST; @@ -692,8 +690,26 @@ bool Parser::parseOperatorFunctionId(NameAST *&node) return true; } +Parser::TemplateArgumentListEntry *Parser::templateArgumentListEntry(unsigned tokenIndex) +{ + for (unsigned i = 0; i < _templateArgumentList.size(); ++i) { + TemplateArgumentListEntry *entry = &_templateArgumentList[i]; + if (entry->index == tokenIndex) + return entry; + } + + return 0; +} + bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node) { + if (TemplateArgumentListEntry *entry = templateArgumentListEntry(cursor())) { + rewind(entry->cursor); + return entry->ast; + } + + unsigned start = cursor(); + DEBUG_THIS_RULE(); TemplateArgumentListAST **template_argument_ptr = &node; ExpressionAST *template_argument = 0; @@ -711,8 +727,13 @@ bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node) template_argument_ptr = &(*template_argument_ptr)->next; } } + + _templateArgumentList.push_back(TemplateArgumentListEntry(start, cursor(), node)); return true; } + + _templateArgumentList.push_back(TemplateArgumentListEntry(start, cursor(), 0)); + return false; } diff --git a/src/shared/cplusplus/Parser.h b/src/shared/cplusplus/Parser.h index 2a7c15dfa3e..d9ccf6ab490 100644 --- a/src/shared/cplusplus/Parser.h +++ b/src/shared/cplusplus/Parser.h @@ -54,7 +54,6 @@ #include "Token.h" #include "TranslationUnit.h" - namespace CPlusPlus { class CPLUSPLUS_EXPORT Parser @@ -287,6 +286,17 @@ private: inline void rewind(unsigned cursor) { _tokenIndex = cursor; } + struct TemplateArgumentListEntry { + unsigned index; + unsigned cursor; + TemplateArgumentListAST *ast; + + TemplateArgumentListEntry(unsigned index = 0, unsigned cursor = 0, TemplateArgumentListAST *ast = 0) + : index(index), cursor(cursor), ast(ast) {} + }; + + TemplateArgumentListEntry *templateArgumentListEntry(unsigned tokenIndex); + private: TranslationUnit *_translationUnit; Control *_control; @@ -298,6 +308,8 @@ private: bool _inFunctionBody: 1; bool _inObjCImplementationContext: 1; + Array _templateArgumentList; + class Rewind; friend class Rewind; From 4c85511d5506d51de1bd987534d99bbf1e2da6ef Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 23 Oct 2009 09:49:59 +0200 Subject: [PATCH 45/91] Search qmlviewer binary also in creator/bin --- src/plugins/qmlprojectmanager/qmlproject.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index 4e891641d19..43707de1ad4 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -338,7 +338,12 @@ QmlRunConfiguration::QmlRunConfiguration(QmlProject *pro) { setName(tr("QML Viewer")); - m_qmlViewer = Utils::SynchronousProcess::locateBinary(QLatin1String("qmlviewer")); + // append creator/bin dir to search path (only useful for special creator-qml package) + const QString searchPath = QString(qgetenv("PATH")) + + Utils::SynchronousProcess::pathSeparator() + + QCoreApplication::applicationDirPath() +; + m_qmlViewer = Utils::SynchronousProcess::locateBinary(searchPath, QLatin1String("qmlviewer")); } QmlRunConfiguration::~QmlRunConfiguration() From e036b011c9d4b0cc1c3f63ba6af9c82b5a3fade0 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 23 Oct 2009 11:07:35 +0200 Subject: [PATCH 46/91] Register qml.qch file automatically in help collection Automatically register qml.qch if found in shared/help/qtcreator. This is needed for the special 'creator-qml' package. --- src/plugins/qmleditor/QmlEditor.pluginspec | 1 + src/plugins/qmleditor/qmleditor.pro | 1 + .../qmleditor/qmleditor_dependencies.pri | 1 + src/plugins/qmleditor/qmleditorplugin.cpp | 24 +++++++++++++++++++ .../qmlprojectmanager/qmlprojectplugin.cpp | 1 - 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmleditor/QmlEditor.pluginspec b/src/plugins/qmleditor/QmlEditor.pluginspec index 4571ae218a7..cb4a47607e7 100644 --- a/src/plugins/qmleditor/QmlEditor.pluginspec +++ b/src/plugins/qmleditor/QmlEditor.pluginspec @@ -21,5 +21,6 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + diff --git a/src/plugins/qmleditor/qmleditor.pro b/src/plugins/qmleditor/qmleditor.pro index 1399b679e1e..415acf8f526 100644 --- a/src/plugins/qmleditor/qmleditor.pro +++ b/src/plugins/qmleditor/qmleditor.pro @@ -47,3 +47,4 @@ SOURCES += qmleditor.cpp \ qmlsymbol.cpp \ qmlfilewizard.cpp RESOURCES += qmleditor.qrc +OTHER_FILES += QmlEditor.pluginspec diff --git a/src/plugins/qmleditor/qmleditor_dependencies.pri b/src/plugins/qmleditor/qmleditor_dependencies.pri index 6163cfc764f..885ef8bc1ec 100644 --- a/src/plugins/qmleditor/qmleditor_dependencies.pri +++ b/src/plugins/qmleditor/qmleditor_dependencies.pri @@ -1,5 +1,6 @@ include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/texteditor/texteditor.pri) +include(../../plugins/help/help.pri) include(../../shared/qscripthighlighter/qscripthighlighter.pri) include(../../shared/indenter/indenter.pri) diff --git a/src/plugins/qmleditor/qmleditorplugin.cpp b/src/plugins/qmleditor/qmleditorplugin.cpp index 474268a6946..47b71b9af18 100644 --- a/src/plugins/qmleditor/qmleditorplugin.cpp +++ b/src/plugins/qmleditor/qmleditorplugin.cpp @@ -51,11 +51,14 @@ #include #include #include +#include #include #include #include #include +#include +#include #include using namespace QmlEditor; @@ -132,6 +135,27 @@ bool QmlEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err void QmlEditorPlugin::extensionsInitialized() { + // + // Explicitly register qml.qch if located in creator directory. + // + // This is only needed for the creator-qml package, were we + // want to ship the documentation without a qt development version. + // + + ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance(); + Help::HelpManager *helpManager = pluginManager->getObject(); + + Q_ASSERT(helpManager); + + const QString qmlHelpFile = + QDir::cleanPath(QCoreApplication::applicationDirPath() +#if defined(Q_OS_MAC) + + QLatin1String("/../Resources/doc/qml.qch")); +#else + + QLatin1String("../../share/doc/qtcreator/qml.qch")); +#endif + + helpManager->registerDocumentation(QStringList(qmlHelpFile)); } void QmlEditorPlugin::initializeEditor(QmlEditor::Internal::ScriptEditor *editor) diff --git a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp index 836db091a99..5d21971a354 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp @@ -42,7 +42,6 @@ #include #include -#include using namespace QmlProjectManager; using namespace QmlProjectManager::Internal; From 8353f29474571a1c3d91434375960e6f1dfc5d4a Mon Sep 17 00:00:00 2001 From: dt Date: Fri, 23 Oct 2009 12:37:53 +0200 Subject: [PATCH 47/91] Fix wrong scoping in qtcreator.pri Reported-By: Tasuku Suzuki --- qtcreator.pri | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qtcreator.pri b/qtcreator.pri index 42fb50e36cf..f78baa33f0d 100644 --- a/qtcreator.pri +++ b/qtcreator.pri @@ -93,11 +93,11 @@ DEFINES += QT_NO_CAST_TO_ASCII #DEFINES += QT_USE_FAST_CONCATENATION unix { - debug:OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared - release:OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared + CONFIG(debug, debug|release):OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared + CONFIG(release, debug|release):OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared - debug:MOC_DIR = $${OUT_PWD}/.moc/debug-shared - release:MOC_DIR = $${OUT_PWD}/.moc/release-shared + CONFIG(debug, debug|release):MOC_DIR = $${OUT_PWD}/.moc/debug-shared + CONFIG(release, debug|release):MOC_DIR = $${OUT_PWD}/.moc/release-shared RCC_DIR = $${OUT_PWD}/.rcc UI_DIR = $${OUT_PWD}/.uic From 021beed90c79d4f7557aeb9d2072aa9e6b2381c2 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 23 Oct 2009 12:58:39 +0200 Subject: [PATCH 48/91] Added plain-cplusplus manual test. --- tests/manual/plain-cplusplus/main.cpp | 79 +++++++++++++++++++ .../plain-cplusplus/plain-cplusplus.pro | 23 ++++++ 2 files changed, 102 insertions(+) create mode 100644 tests/manual/plain-cplusplus/main.cpp create mode 100644 tests/manual/plain-cplusplus/plain-cplusplus.pro diff --git a/tests/manual/plain-cplusplus/main.cpp b/tests/manual/plain-cplusplus/main.cpp new file mode 100644 index 00000000000..e975897d21d --- /dev/null +++ b/tests/manual/plain-cplusplus/main.cpp @@ -0,0 +1,79 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace CPlusPlus; + +int main(int argc, char *argv[]) +{ + std::string cmdline; + cmdline += "gcc -E -xc++ -U__BLOCKS__"; + + for (int i = 1; i < argc; ++i) { + cmdline += ' '; + cmdline += argv[i]; + } + + enum { BLOCK_SIZE = 4 * 1024}; + char block[BLOCK_SIZE]; + + std::string source; + + if (FILE *fp = popen(cmdline.c_str(), "r")) { + while (size_t sz = fread(block, 1, BLOCK_SIZE, fp)) + source.append(block, sz); + + pclose(fp); + + } else { + fprintf(stderr, "c++: No such file or directory\n"); + return EXIT_FAILURE; + } + + Control control; + TranslationUnit unit(&control, control.findOrInsertStringLiteral("")); + unit.setSource(source.c_str(), source.size()); + unit.parse(); + + return EXIT_SUCCESS; +} diff --git a/tests/manual/plain-cplusplus/plain-cplusplus.pro b/tests/manual/plain-cplusplus/plain-cplusplus.pro new file mode 100644 index 00000000000..d77e233f863 --- /dev/null +++ b/tests/manual/plain-cplusplus/plain-cplusplus.pro @@ -0,0 +1,23 @@ +QT -= core gui +TARGET = plain-c++ + +macx { + CONFIG -= app_bundle + release:LIBS += -Wl,-exported_symbol -Wl,_main +} + +include(../../../src/shared/cplusplus/cplusplus.pri) + +# Input +SOURCES += main.cpp + +unix { + debug:OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared + release:OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared + + debug:MOC_DIR = $${OUT_PWD}/.moc/debug-shared + release:MOC_DIR = $${OUT_PWD}/.moc/release-shared + + RCC_DIR = $${OUT_PWD}/.rcc/ + UI_DIR = $${OUT_PWD}/.uic/ +} From 935642b1bcb68f5bb3edd22a28f4bbbdf23f3347 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 23 Oct 2009 14:31:55 +0200 Subject: [PATCH 49/91] Return the cached AST node. --- src/shared/cplusplus/Parser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 67e260230c0..4fffd4818dd 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -705,7 +705,8 @@ bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node) { if (TemplateArgumentListEntry *entry = templateArgumentListEntry(cursor())) { rewind(entry->cursor); - return entry->ast; + node = entry->ast; + return entry->ast != 0; } unsigned start = cursor(); From 4fb4705791bf4ef8e5583f4b7db74623b35d5b5c Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 23 Oct 2009 14:53:44 +0200 Subject: [PATCH 50/91] Resolve the conditional and new-expressions --- src/libs/cplusplus/ResolveExpression.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 7c9eedebd56..aff38db4b3f 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -286,9 +286,14 @@ bool ResolveExpression::visit(ConditionAST *) return false; } -bool ResolveExpression::visit(ConditionalExpressionAST *) +bool ResolveExpression::visit(ConditionalExpressionAST *ast) { - // nothing to do. + if (ast->left_expression) + accept(ast->left_expression); + + else if (ast->right_expression) + accept(ast->right_expression); + return false; } @@ -300,7 +305,8 @@ bool ResolveExpression::visit(CppCastExpressionAST *ast) bool ResolveExpression::visit(DeleteExpressionAST *) { - // nothing to do. + FullySpecifiedType ty(control()->voidType()); + addResult(ty); return false; } @@ -310,8 +316,15 @@ bool ResolveExpression::visit(ArrayInitializerAST *) return false; } -bool ResolveExpression::visit(NewExpressionAST *) +bool ResolveExpression::visit(NewExpressionAST *ast) { + if (ast->new_type_id) { + Scope *scope = _context.expressionDocument()->globalSymbols(); + FullySpecifiedType ty = sem.check(ast->new_type_id->type_specifier, scope); + ty = sem.check(ast->new_type_id->ptr_operators, ty, scope); + FullySpecifiedType ptrTy(control()->pointerType(ty)); + addResult(ptrTy); + } // nothing to do. return false; } From 41603f5b7c52d4bbce87a666ad3e2e6271e0e5dd Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Fri, 23 Oct 2009 15:26:45 +0200 Subject: [PATCH 51/91] Trk: Checking for NULL-pointers. --- src/shared/trk/trkdevice.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shared/trk/trkdevice.cpp b/src/shared/trk/trkdevice.cpp index 7fb21c0069e..a76cff79c2d 100644 --- a/src/shared/trk/trkdevice.cpp +++ b/src/shared/trk/trkdevice.cpp @@ -955,8 +955,10 @@ void TrkDevice::close() { if (!isOpen()) return; - d->readerThread->terminate(); - d->writerThread->terminate(); + if (d->readerThread) + d->readerThread->terminate(); + if (d->writerThread) + d->writerThread->terminate(); #ifdef Q_OS_WIN CloseHandle(d->deviceContext->device); d->deviceContext->device = INVALID_HANDLE_VALUE; From a39e074ae0bb610f68c781a5916e5d481b95e8bc Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 21 Oct 2009 18:21:20 +0200 Subject: [PATCH 52/91] debugger: more autotest work autotest for QStack dumper custom structure array --- tests/auto/debugger/tst_gdb.cpp | 862 +++++++++++++++++++++----------- 1 file changed, 579 insertions(+), 283 deletions(-) diff --git a/tests/auto/debugger/tst_gdb.cpp b/tests/auto/debugger/tst_gdb.cpp index bff9d166017..f40b0756c7d 100644 --- a/tests/auto/debugger/tst_gdb.cpp +++ b/tests/auto/debugger/tst_gdb.cpp @@ -47,6 +47,46 @@ using namespace Debugger; using namespace Debugger::Internal; +class Foo +{ +public: + Foo(int i = 0) + : a(i), b(2) + {} + + ~Foo() + { + } + void doit() + { + static QObject ob; + m["1"] = "2"; + h[&ob] = m.begin(); + + a += 1; + --b; + //s += 'x'; + } + + + struct Bar { + Bar() : ob(0) {} + QObject *ob; + }; + +public: + int a, b; + char x[6]; + +private: + //QString s; + typedef QMap Map; + Map m; + QHash h; +}; + + + ///////////////////////////////////////////////////////////////////////// // // Helper stuff @@ -137,7 +177,9 @@ signals: void writeToGdb(const QByteArray &ba); private slots: + void dumpArray(); void dumpMisc(); + void dumpFoo(); void dumpQByteArray(); void dumpQChar(); void dumpQList_char_star(); @@ -146,8 +188,11 @@ private slots: void dumpQList_QString(); void dumpQList_QString3(); void dumpQList_Int3(); + void dumpQStack(); void dumpQString(); void dumpQStringList(); + void dumpQWeakPointer(); + void dumpQVector(); public slots: void dumperCompatibility(); @@ -181,7 +226,6 @@ public slots: void dumpQVariant_QString(); void dumpQVariant_QStringList(); void dumpStdVector(); - void dumpQWeakPointer(); #endif private: @@ -401,6 +445,357 @@ void getMapNodeParams(size_t &nodeSize, size_t &valOffset) } #endif + + +///////////////////////////////////////////////////////////////////////// +// +// Gdb Thread +// +///////////////////////////////////////////////////////////////////////// + +Thread::Thread(tst_Gdb *test) +{ + moveToThread(this); + m_test = test; + m_proc = 0; + m_proc = new QProcess; + m_proc->moveToThread(this); + qDebug() << "\nTHREAD CREATED" << getpid() << gettid(); + connect(m_test, SIGNAL(writeToGdb(QByteArray)), + this, SLOT(writeToGdbRequested(QByteArray))); + connect(m_proc, SIGNAL(error(QProcess::ProcessError)), + this, SLOT(handleGdbError(QProcess::ProcessError))); + connect(m_proc, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(handleGdbFinished(int, QProcess::ExitStatus))); + connect(m_proc, SIGNAL(started()), + this, SLOT(handleGdbStarted())); + connect(m_proc, SIGNAL(readyReadStandardOutput()), + this, SLOT(readStandardOutput())); + connect(m_proc, SIGNAL(readyReadStandardError()), + this, SLOT(readStandardError())); + start(); +} + +void Thread::handleGdbError(QProcess::ProcessError error) +{ + qDebug() << "GDB ERROR: " << error; + //this->exit(); +} + +void Thread::handleGdbFinished(int code, QProcess::ExitStatus st) +{ + qDebug() << "GDB FINISHED: " << code << st; + //m_waitCondition.wakeAll(); + //this->exit(); + throw 42; +} + +void Thread::readStandardOutput() +{ + QByteArray ba = m_proc->readAllStandardOutput(); + DEBUG("THREAD GDB OUT: " << ba); + // =library-loaded... + if (ba.startsWith("=")) + return; + if (ba.startsWith("*stopped")) { + m_lastStopped = ba; + //qDebug() << "THREAD GDB OUT: " << ba; + if (!ba.contains("func=\"main\"")) { + int pos1 = ba.indexOf(",line=\"") + 7; + int pos2 = ba.indexOf("\"", pos1); + m_line = ba.mid(pos1, pos2 - pos1).toInt(); + DEBUG(" LINE 1: " << m_line); + } + } + + // The "call" is always aborted with a message like: + // "~"2321\t /* A */ QString s;\n" " + // "&"The program being debugged stopped while in a function called ..." + // "^error,msg="The program being debugged stopped ..." + // Extract the "2321" from this + static QByteArray lastText; + if (ba.startsWith("~")) { + lastText = ba; + if (ba.size() > 8 + && (ba.at(2) < 'a' || ba.at(2) > 'z') + && (ba.at(2) < '0' || ba.at(2) > '9') + && !ba.startsWith("~\"Breakpoint ") + && !ba.startsWith("~\" at ") + && !ba.startsWith("~\" locals=") + && !ba.startsWith("~\"XXX:")) { + QByteArray ba1 = ba.mid(2, ba.size() - 6); + if (ba1.startsWith(" File ")) + ba1 = ba1.replace(2, ba1.indexOf(','), ""); + qWarning() << "OUT: " << ba1; + } + } + if (ba.startsWith("&\"The program being debugged")) { + int pos1 = 2; + int pos2 = lastText.indexOf("\\", pos1); + m_line = lastText.mid(pos1, pos2 - pos1).toInt(); + DEBUG(" LINE 2: " << m_line); + } + if (ba.startsWith("^error,msg=")) { + if (!ba.startsWith("^error,msg=\"The program being debugged stopped")) + qWarning() << "ERROR: " << ba.mid(1, ba.size() - 3); + } + + if (ba.startsWith("~\"XXX: ")) { + QByteArray ba1 = ba.mid(7, ba.size() - 11); + qWarning() << "MESSAGE: " << ba.mid(7, ba.size() - 12); + } + if (!ba.contains("locals={iname=")) + return; + //m_output += ba; + ba = ba.mid(2, ba.size() - 4); + ba = ba.replace("\\\"", "\""); + m_output = ba; + m_waitCondition.wakeAll(); +} + +void Thread::readStandardError() +{ + QByteArray ba = m_proc->readAllStandardOutput(); + qDebug() << "THREAD GDB ERR: " << ba; +} + +void Thread::handleGdbStarted() +{ + //qDebug() << "\n\nGDB STARTED" << getpid() << gettid() << "\n\n"; +} + +void Thread::run() +{ + //qDebug() << "\nTHREAD RUN" << getpid() << gettid(); + m_proc->start("./gdb -i mi --args ./tst_gdb run"); + m_proc->waitForStarted(); + m_proc->write("break main\n"); + m_proc->write("run\n"); + m_proc->write("handle SIGSTOP stop pass\n"); + //qDebug() << "\nTHREAD RUNNING"; + exec(); +} + + +///////////////////////////////////////////////////////////////////////// +// +// Test Class Framework Implementation +// +///////////////////////////////////////////////////////////////////////// + +tst_Gdb::tst_Gdb() + : m_thread(this) +{ + // FIXME: Wait until gdb proc is running. + QTest::qWait(600); + + QFile file("tst_gdb.cpp"); + Q_ASSERT(file.open(QIODevice::ReadOnly)); + QByteArray funcName; + const QByteArrayList bal = file.readAll().split('\n'); + Q_ASSERT(bal.size() > 100); + for (int i = 0; i != bal.size(); ++i) { + const QByteArray &ba = bal.at(i); + if (ba.startsWith("void dump")) { + int pos = ba.indexOf('('); + funcName = ba.mid(5, pos - 5) + '@'; + } else if (ba.startsWith(" /*")) { + int pos = ba.indexOf('*', 7); + m_lineForLabel[funcName + ba.mid(7, pos - 8)] = i + 1; + } + } +} + +void tst_Gdb::prepare(const QByteArray &function) +{ + m_function = function; + writeToGdb("b " + function); + writeToGdb("call " + function + "()"); +} + +static bool isJoker(const QByteArray &ba) +{ + return ba.endsWith("'-'") || ba.contains("'-'}"); +} + +void tst_Gdb::run(const QByteArray &label, const QByteArray &expected0, + const QByteArray &expanded, bool fancy) +{ + //qDebug() << "\nABOUT TO RUN TEST: " << expanded; + qWarning() << label << "..."; + writeToGdb("bb " + QByteArray::number(int(fancy)) + " " + expanded); + m_mutex.lock(); + m_waitCondition.wait(&m_mutex); + QByteArray ba = m_thread.m_output; + m_mutex.unlock(); + //GdbMi locals; + //locals.fromString("{" + ba + "}"); + QByteArray received = ba.replace("\"", "'"); + //qDebug() << "OUTPUT: " << ba << "\n\n"; + //qDebug() << "OUTPUT: " << locals.toString() << "\n\n"; + + QByteArray actual = received.trimmed(); + if (actual.endsWith("\\n")) + actual.chop(2); + QByteArray expected = "locals={iname='local',name='Locals',value=' ',type=' '," + "children=[" + expected0 + "]}"; + int line = m_thread.m_line; + + QByteArrayList l1 = actual.split(','); + QByteArrayList l2 = expected.split(','); + + bool ok = l1.size() == l2.size(); + if (ok) { + for (int i = 0 ; i < l1.size(); ++i) { + // Use "-" as joker. + if (l1.at(i) != l2.at(i) && !isJoker(l2.at(i))) + ok = false; + } + } else { + qWarning() << "!= size: " << l1.size() << l2.size(); + } + + if (!ok) { + int i = 0; + for ( ; i < l1.size() && i < l2.size(); ++i) { + if (l1.at(i) == l2.at(i) || isJoker(l2.at(i))) { + qWarning() << "== " << l1.at(i); + } else { + //qWarning() << "!= " << l1.at(i).right(30) << l2.at(i).right(30); + qWarning() << "!= " << l1.at(i) << l2.at(i); + ok = false; + } + } + for ( ; i < l2.size(); ++i) + qWarning() << "!= " << "-----" << l2.at(i); + for ( ; i < l1.size(); ++i) + qWarning() << "!= " << l1.at(i) << "-----"; + if (l1.size() != l2.size()) { + ok = false; + qWarning() << "!= size: " << l1.size() << l2.size(); + } + qWarning() << "RECEIVED: " << received; + } + QCOMPARE(ok, true); + //qWarning() << "LINE: " << line << "ACT/EXP" << m_function + '@' + label; + //QCOMPARE(actual, expected); + + + int expline = m_lineForLabel.value(m_function + '@' + label); + int actline = line; + if (actline != expline) { + qWarning() << "LAST STOPPED: " << m_thread.m_lastStopped; + } + QCOMPARE(actline, expline); +} + +void tst_Gdb::next(int n) +{ + for (int i = 0; i != n; ++i) + writeToGdb("next"); +} + +void tst_Gdb::cleanupTestCase() +{ + writeToGdb("kill"); + writeToGdb("quit"); + //m_thread.m_proc->waitForFinished(); +} + + +///////////////////////////////////////////////////////////////////////// +// +// Dumper Tests +// +///////////////////////////////////////////////////////////////////////// + +///////////////////////////// Foo structure ///////////////////////////////// + +void dumpFoo() +{ + /* A */ Foo f; + /* B */ f.doit(); + /* D */ (void) 0; +} + +void tst_Gdb::dumpFoo() +{ + prepare("dumpFoo"); + next(); + run("B","{iname='local.f',addr='-',name='f',type='Foo'," + "value='-',numchild='5'}", "", 0); + run("B","{iname='local.f',addr='-',name='f',type='Foo'," + "value='-',numchild='5',children=[" + "{iname='local.f.a',name='a',type='int',value='0',numchild='0'}," + "{iname='local.f.b',name='b',type='int',value='2',numchild='0'}," + "{iname='local.f.x',name='x',type='char [6]'," + "value='{...}',numchild='1'}," + "{iname='local.f.m',name='m',type='"NS"QMap<"NS"QString, "NS"QString>'," + "value='{...}',numchild='1'}," + "{iname='local.f.h',name='h',type='"NS"QHash<"NS"QObject*, " + ""NS"QMap<"NS"QString, "NS"QString>::iterator>'," + "value='{...}',numchild='1'}]}", + "local.f", 0); +} + + +///////////////////////////// Array /////////////////////////////////////// + +void dumpArray_char() +{ + /* A */ const char s[] = "XYZ"; + /* B */ (void) &s; } + +void dumpArray_int() +{ + /* A */ int s[] = {1, 2, 3}; + /* B */ (void) s; } + +void tst_Gdb::dumpArray() +{ + prepare("dumpArray_char"); + next(); + // FIXME: numchild should be '4', not '1' + run("B","{iname='local.s',addr='-',name='s',type='char [4]'," + "value='-',numchild='1'}", ""); + run("B","{iname='local.s',addr='-',name='s',type='char [4]'," + "value='-',numchild='1',childtype='char',childnumchild='0'," + "children=[{value='88 'X''},{value='89 'Y''},{value='90 'Z''}," + "{value='0 '\\\\000''}]}", + "local.s"); + + prepare("dumpArray_int"); + next(); + // FIXME: numchild should be '3', not '1' + run("B","{iname='local.s',addr='-',name='s',type='int [3]'," + "value='-',numchild='1'}", ""); + run("B","{iname='local.s',addr='-',name='s',type='int [3]'," + "value='-',numchild='1',childtype='int',childnumchild='0'," + "children=[{value='1'},{value='2'},{value='3'}]}", + "local.s"); +} + + +///////////////////////////// Misc stuff ///////////////////////////////// + +void dumpMisc() +{ + /* A */ int *s = new int(1); + /* B */ *s += 1; + /* D */ (void) 0; +} + +void tst_Gdb::dumpMisc() +{ + prepare("dumpMisc"); + next(); + run("B","{iname='local.s',addr='-',name='s',type='int *'," + "value='-',numchild='1'}", "", 0); + run("B","{iname='local.s',addr='-',name='s',type='int *'," + "value='-',numchild='1',children=[{iname='local.s.*'," + "name='*s',type='int',value='1',numchild='0'}]}", "local.s", 0); +} + #if 0 void tst_Gdb::dumpQAbstractItemHelper(QModelIndex &index) { @@ -667,7 +1062,7 @@ void dumpQByteArrayTest() void tst_Gdb::dumpQByteArray() { prepare("dumpQByteArrayTest"); - if (checkUninitialized) + if (1 || checkUninitialized) run("A","{iname='local.ba',addr='-',name='ba',type='"NS"QByteArray'," "value='',numchild='0'}"); next(); @@ -2046,19 +2441,102 @@ void tst_Gdb::dumpQWeakPointerHelper(QWeakPointer &ptr) testDumper(expected, &ptr, NS"QWeakPointer", true, typeToString()); } #endif +#endif // #if 0 + +///////////////////////////// QWeakPointer ///////////////////////////////// + +#if QT_VERSION >= 0x040500 +void dumpQWeakPointer_11() +{ + // Case 1: Simple type. + // Case 1.1: Null pointer. + /* A */ QSharedPointer sp; + /* */ QWeakPointer wp = sp.toWeakRef(); + /* B */ (void) 0; +} + +void dumpQWeakPointer_12() +{ + // Case 1.2: Weak pointer is unique. + /* A */ QSharedPointer sp(new int(99)); + /* */ QWeakPointer wp = sp.toWeakRef(); + /* B */ (void) 0; +} + +void dumpQWeakPointer_13() +{ + // Case 1.3: There are other weak pointers. + /* A */ QSharedPointer sp(new int(99)); + /* */ QWeakPointer wp = sp.toWeakRef(); + /* B */ (void) 0; +} + +void dumpQWeakPointer_14() +{ + // Case 1.4: There are other strong shared pointers as well. + /* A */ QSharedPointer sp(new int(99)); + /* */ QSharedPointer sp2(sp); + /* B */ (void) 0; +} + +void dumpQWeakPointer_2() +{ + // Case 2: Composite type. + /* A */ QSharedPointer sp(new QString("Test")); + /* */ QWeakPointer wp = sp.toWeakRef(); + /* B */ (void) 0; +} +#endif void tst_Gdb::dumpQWeakPointer() { #if QT_VERSION >= 0x040500 - // Case 1: Simple type. + +return; // Case 1.1: Null pointer. - QSharedPointer spNull; - QWeakPointer wp = spNull.toWeakRef(); - testDumper("value='',valuedisabled='true',numchild='0'", - &wp, NS"QWeakPointer", true, "int"); + prepare("dumpQWeakPointer_11"); + if (checkUninitialized) + run("A","{iname='local.sp',addr='-',name='sp'," + "type='"NS"QSharedPointer',value='',numchild='0'}"); + next(); + run("B","{iname='local.sp',addr='-',name='sp'," + "type='"NS"QSharedPointer',value='<0 items>',numchild='1'}"); + +/* + //,numchild='1',children=[{name='data',addr='"). + append(ptrToBa(data)).append("',type='").append(typeToString()). + append("',value='").append(dataStr).append("'},{name='weakref',value='"). + append(valToString(*weakRefPtr)).append("',type='int',addr='"). + append(ptrToBa(weakRefPtr)).append("',numchild='0'},{name='strongref',value='"). + append(valToString(*strongRefPtr)).append("',type='int',addr='"). + append(ptrToBa(strongRefPtr)).append("',numchild='0'}]"); // Case 1.2: Weak pointer is unique. +void tst_Gdb::dumpQWeakPointerHelper(QWeakPointer &ptr) +{ + typedef QtSharedPointer::ExternalRefCountData Data; + const size_t dataOffset = 0; + const Data *d = *reinterpret_cast( + reinterpret_cast(&ptr) + dataOffset); + const int *weakRefPtr = reinterpret_cast(&d->weakref); + const int *strongRefPtr = reinterpret_cast(&d->strongref); + T *data = ptr.toStrongRef().data(); + const QString dataStr = valToString(*data); + QByteArray expected("value='"); + if (isSimpleType()) + expected.append(dataStr); + expected.append("',valuedisabled='true',numchild='1',children=[{name='data',addr='"). + append(ptrToBa(data)).append("',type='").append(typeToString()). + append("',value='").append(dataStr).append("'},{name='weakref',value='"). + append(valToString(*weakRefPtr)).append("',type='int',addr='"). + append(ptrToBa(weakRefPtr)).append("',numchild='0'},{name='strongref',value='"). + append(valToString(*strongRefPtr)).append("',type='int',addr='"). + append(ptrToBa(strongRefPtr)).append("',numchild='0'}]"); + testDumper(expected, &ptr, NS"QWeakPointer", true, typeToString()); +} + + QSharedPointer sp(new int(99)); wp = sp.toWeakRef(); dumpQWeakPointerHelper(wp); @@ -2075,270 +2553,11 @@ void tst_Gdb::dumpQWeakPointer() QSharedPointer spS(new QString("Test")); QWeakPointer wpS = spS.toWeakRef(); dumpQWeakPointerHelper(wpS); +*/ #endif } -#endif // #if 0 - -///////////////////////////////////////////////////////////////////////// -// -// Gdb Thread -// -///////////////////////////////////////////////////////////////////////// - -Thread::Thread(tst_Gdb *test) -{ - moveToThread(this); - m_test = test; - m_proc = 0; - m_proc = new QProcess; - m_proc->moveToThread(this); - qDebug() << "\nTHREAD CREATED" << getpid() << gettid(); - connect(m_test, SIGNAL(writeToGdb(QByteArray)), - this, SLOT(writeToGdbRequested(QByteArray))); - connect(m_proc, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(handleGdbError(QProcess::ProcessError))); - connect(m_proc, SIGNAL(finished(int, QProcess::ExitStatus)), - this, SLOT(handleGdbFinished(int, QProcess::ExitStatus))); - connect(m_proc, SIGNAL(started()), - this, SLOT(handleGdbStarted())); - connect(m_proc, SIGNAL(readyReadStandardOutput()), - this, SLOT(readStandardOutput())); - connect(m_proc, SIGNAL(readyReadStandardError()), - this, SLOT(readStandardError())); - start(); -} - -void Thread::handleGdbError(QProcess::ProcessError error) -{ - qDebug() << "GDB ERROR: " << error; - //this->exit(); -} - -void Thread::handleGdbFinished(int code, QProcess::ExitStatus st) -{ - qDebug() << "GDB FINISHED: " << code << st; - //m_waitCondition.wakeAll(); - //this->exit(); - throw 42; -} - -void Thread::readStandardOutput() -{ - QByteArray ba = m_proc->readAllStandardOutput(); - DEBUG("THREAD GDB OUT: " << ba); - // =library-loaded... - if (ba.startsWith("=")) - return; - if (ba.startsWith("*stopped")) { - m_lastStopped = ba; - //qDebug() << "THREAD GDB OUT: " << ba; - if (!ba.contains("func=\"main\"")) { - int pos1 = ba.indexOf(",line=\"") + 7; - int pos2 = ba.indexOf("\"", pos1); - m_line = ba.mid(pos1, pos2 - pos1).toInt(); - DEBUG(" LINE 1: " << m_line); - } - } - - // The "call" is always aborted with a message like: - // "~"2321\t /* A */ QString s;\n" " - // "&"The program being debugged stopped while in a function called ..." - // "^error,msg="The program being debugged stopped ..." - // Extract the "2321" from this - static QByteArray lastText; - if (ba.startsWith("~")) { - lastText = ba; - if (ba.size() > 8 - && (ba.at(2) < 'a' || ba.at(2) > 'z') - && (ba.at(2) < '0' || ba.at(2) > '9') - && !ba.startsWith("~\"Breakpoint ") - && !ba.startsWith("~\" at ") - && !ba.startsWith("~\" locals=") - && !ba.startsWith("~\"XXX:")) { - QByteArray ba1 = ba.mid(2, ba.size() - 6); - if (ba1.startsWith(" File ")) - ba1 = ba1.replace(2, ba1.indexOf(','), ""); - qWarning() << "OUT: " << ba1; - } - } - if (ba.startsWith("&\"The program being debugged")) { - int pos1 = 2; - int pos2 = lastText.indexOf("\\", pos1); - m_line = lastText.mid(pos1, pos2 - pos1).toInt(); - DEBUG(" LINE 2: " << m_line); - } - if (ba.startsWith("^error,msg=")) { - if (!ba.startsWith("^error,msg=\"The program being debugged stopped")) - qWarning() << "ERROR: " << ba.mid(1, ba.size() - 3); - } - - if (ba.startsWith("~\"XXX: ")) { - QByteArray ba1 = ba.mid(7, ba.size() - 11); - qWarning() << "MESSAGE: " << ba.mid(7, ba.size() - 12); - } - if (!ba.contains("locals={iname=")) - return; - //m_output += ba; - ba = ba.mid(2, ba.size() - 4); - ba = ba.replace("\\\"", "\""); - m_output = ba; - m_waitCondition.wakeAll(); -} - -void Thread::readStandardError() -{ - QByteArray ba = m_proc->readAllStandardOutput(); - qDebug() << "THREAD GDB ERR: " << ba; -} - -void Thread::handleGdbStarted() -{ - //qDebug() << "\n\nGDB STARTED" << getpid() << gettid() << "\n\n"; -} - -void Thread::run() -{ - //qDebug() << "\nTHREAD RUN" << getpid() << gettid(); - m_proc->start("./gdb -i mi --args ./tst_gdb run"); - m_proc->waitForStarted(); - m_proc->write("break main\n"); - m_proc->write("run\n"); - m_proc->write("handle SIGSTOP stop pass\n"); - //qDebug() << "\nTHREAD RUNNING"; - exec(); -} - - -///////////////////////////////////////////////////////////////////////// -// -// Test Class Framework Implementation -// -///////////////////////////////////////////////////////////////////////// - -tst_Gdb::tst_Gdb() - : m_thread(this) -{ - // FIXME: Wait until gdb proc is running. - QTest::qWait(600); - - QFile file("tst_gdb.cpp"); - Q_ASSERT(file.open(QIODevice::ReadOnly)); - QByteArray funcName; - const QByteArrayList bal = file.readAll().split('\n'); - Q_ASSERT(bal.size() > 100); - for (int i = 0; i != bal.size(); ++i) { - const QByteArray &ba = bal.at(i); - if (ba.startsWith("void dump")) { - int pos = ba.indexOf('('); - funcName = ba.mid(5, pos - 5) + '@'; - } else if (ba.startsWith(" /*")) { - int pos = ba.indexOf('*', 7); - m_lineForLabel[funcName + ba.mid(7, pos - 8)] = i + 1; - } - } -} - -void tst_Gdb::prepare(const QByteArray &function) -{ - m_function = function; - writeToGdb("b " + function); - writeToGdb("call " + function + "()"); -} - -static bool isJoker(const QByteArray &ba) -{ - return ba.endsWith("'-'") || ba.contains("'-'}"); -} - -void tst_Gdb::run(const QByteArray &label, const QByteArray &expected0, - const QByteArray &expanded, bool fancy) -{ - //qDebug() << "\nABOUT TO RUN TEST: " << expanded; - qWarning() << label << "..."; - writeToGdb("bb " + QByteArray::number(int(fancy)) + " " + expanded); - m_mutex.lock(); - m_waitCondition.wait(&m_mutex); - QByteArray ba = m_thread.m_output; - m_mutex.unlock(); - //GdbMi locals; - //locals.fromString("{" + ba + "}"); - QByteArray received = ba.replace("\"", "'"); - //qDebug() << "OUTPUT: " << ba << "\n\n"; - //qDebug() << "OUTPUT: " << locals.toString() << "\n\n"; - - QByteArray actual____ = received.trimmed(); - QByteArray expected = "locals={iname='local',name='Locals',value=' ',type=' '," - "children=[" + expected0 + "]}"; - int line = m_thread.m_line; - - QByteArrayList l1 = actual____.split(','); - QByteArrayList l2 = expected.split(','); - - bool ok = l1.size() == l2.size(); - if (ok) { - for (int i = 0 ; i < l1.size(); ++i) { - // Use "-" as joker. - if (l1.at(i) != l2.at(i) && !isJoker(l2.at(i))) - ok = false; - } - } else { - qWarning() << "!= size: " << l1.size() << l2.size(); - } - - if (!ok) { - int i = 0; - for ( ; i < l1.size() && i < l2.size(); ++i) { - if (l1.at(i) == l2.at(i) || isJoker(l2.at(i))) { - qWarning() << "== " << l1.at(i); - } else { - //qWarning() << "!= " << l1.at(i).right(30) << l2.at(i).right(30); - qWarning() << "!= " << l1.at(i) << l2.at(i); - ok = false; - } - } - for ( ; i < l2.size(); ++i) - qWarning() << "!= " << "-----" << l2.at(i); - for ( ; i < l1.size(); ++i) - qWarning() << "!= " << l1.at(i) << "-----"; - if (l1.size() != l2.size()) { - ok = false; - qWarning() << "!= size: " << l1.size() << l2.size(); - } - qWarning() << "RECEIVED: " << received; - } - QCOMPARE(ok, true); - //qWarning() << "LINE: " << line << "ACT/EXP" << m_function + '@' + label; - //QCOMPARE(actual____, expected); - - - int expline = m_lineForLabel.value(m_function + '@' + label); - int actline = line; - if (actline != expline) { - qWarning() << "LAST STOPPED: " << m_thread.m_lastStopped; - } - QCOMPARE(actline, expline); -} - -void tst_Gdb::next(int n) -{ - for (int i = 0; i != n; ++i) - writeToGdb("next"); -} - -void tst_Gdb::cleanupTestCase() -{ - writeToGdb("kill"); - writeToGdb("quit"); - //m_thread.m_proc->waitForFinished(); -} - - -///////////////////////////////////////////////////////////////////////// -// -// Dumper Tests -// -///////////////////////////////////////////////////////////////////////// +///////////////////////////// QList ///////////////////////////////// void dumpQList_int() { @@ -2373,6 +2592,9 @@ void tst_Gdb::dumpQList_int() "{value='1'},{value='2'}]}", "local.list"); } + +///////////////////////////// QList ///////////////////////////////// + void dumpQList_char() { /* A */ QList list; @@ -2398,6 +2620,9 @@ void tst_Gdb::dumpQList_char() "{value='97 'a''}]}", "local.list"); } + +///////////////////////////// QList ///////////////////////////////// + void dumpQList_char_star() { /* A */ QList list; @@ -2433,6 +2658,9 @@ void tst_Gdb::dumpQList_char_star() "{valueencoded='6',value='6263',numchild='0'}]}", "local.list"); } + +///////////////////////////// QList ///////////////////////////////////// + void dumpQList_QString() { /* A */ QList list; @@ -2458,6 +2686,9 @@ void tst_Gdb::dumpQList_QString() "{valueencoded='7',value='480061006c006c006f00'}]}", "local.list"); } + +///////////////////////////// QList /////////////////////////////////// + void dumpQList_QString3() { /* A */ QList list; @@ -2493,6 +2724,9 @@ void tst_Gdb::dumpQList_QString3() "local.list,local.list.0"); } + +///////////////////////////// QList ///////////////////////////////////// + void dumpQList_Int3() { /* A */ QList list; @@ -2525,25 +2759,47 @@ void tst_Gdb::dumpQList_Int3() "local.list,local.list.0"); } -void dumpMisc() +///////////////////////////// QVector ///////////////////////////////// + +void dumpQStack() { - /* A */ int *s = new int(1); - /* B */ *s += 1; - /* D */ (void) s; + /* A */ QStack v; + /* B */ v.append(3); + /* C */ v.append(2); + /* D */ (void) 0; } -void tst_Gdb::dumpMisc() +void tst_Gdb::dumpQStack() { - prepare("dumpMisc"); + prepare("dumpQStack"); + if (checkUninitialized) + run("A","{iname='local.v',addr='-',name='v',type='"NS"QStack'," + "value='',numchild='0'}"); next(); - run("B","{iname='local.s',addr='-',name='s',type='int *'," - "value='-',numchild='1'}", "", 0); - run("B","{iname='local.s',addr='-',name='s',type='int *'," - "value='-',numchild='1',children=[{iname='local.s.*'," - "name='*s',type='int',value='1',numchild='0'}]}", "local.s", 0); + run("B","{iname='local.v',addr='-',name='v',type='"NS"QStack'," + "value='<0 items>',numchild='0'}"); + run("B","{iname='local.v',addr='-',name='v',type='"NS"QStack'," + "value='<0 items>',numchild='0',children=[]}", "local.v"); + next(); + run("C","{iname='local.v',addr='-',name='v',type='"NS"QStack'," + "value='<1 items>',numchild='1'}"); + run("C","{iname='local.v',addr='-',name='v',type='"NS"QStack'," + "value='<1 items>',numchild='1',childtype='int'," + "childnumchild='0',children=[{value='3'}]}", // rounding... + "local.v"); + next(); + run("D","{iname='local.v',addr='-',name='v',type='"NS"QStack'," + "value='<2 items>',numchild='2'}"); + run("D","{iname='local.v',addr='-',name='v',type='"NS"QStack'," + "value='<2 items>',numchild='2',childtype='int'," + "childnumchild='0',children=[{value='3'},{value='2'}]}", + "local.v"); } -void dumpQStringTest() + +///////////////////////////// QString ///////////////////////////////////// + +void dumpQString() { /* A */ QString s; /* B */ s = "hallo"; @@ -2553,7 +2809,7 @@ void dumpQStringTest() void tst_Gdb::dumpQString() { - prepare("dumpQStringTest"); + prepare("dumpQString"); if (checkUninitialized) run("A","{iname='local.s',addr='-',name='s',type='"NS"QString'," "value='',numchild='0'}"); @@ -2582,7 +2838,10 @@ void tst_Gdb::dumpQString() "valueencoded='7',value='680061006c006c006f007800',numchild='0'}"); } -void dumpQStringListTest() + +///////////////////////////// QStringList ///////////////////////////////// + +void dumpQStringList() { /* A */ QStringList s; /* B */ s.append("hello"); @@ -2592,7 +2851,7 @@ void dumpQStringListTest() void tst_Gdb::dumpQStringList() { - prepare("dumpQStringListTest"); + prepare("dumpQStringList"); if (checkUninitialized) run("A","{iname='local.s',addr='-',name='s',type='"NS"QStringList'," "value='',numchild='0'}"); @@ -2621,6 +2880,43 @@ void tst_Gdb::dumpQStringList() } +///////////////////////////// QVector ///////////////////////////////// + +void dumpQVector() +{ + /* A */ QVector v; + /* B */ v.append(3.14); + /* C */ v.append(2.81); + /* D */ (void) 0; +} + +void tst_Gdb::dumpQVector() +{ + prepare("dumpQVector"); + if (checkUninitialized) + run("A","{iname='local.v',addr='-',name='v',type='"NS"QVector'," + "value='',numchild='0'}"); + next(); + run("B","{iname='local.v',addr='-',name='v',type='"NS"QVector'," + "value='<0 items>',numchild='0'}"); + run("B","{iname='local.v',addr='-',name='v',type='"NS"QVector'," + "value='<0 items>',numchild='0',children=[]}", "local.v"); + next(); + run("C","{iname='local.v',addr='-',name='v',type='"NS"QVector'," + "value='<1 items>',numchild='1'}"); + run("C","{iname='local.v',addr='-',name='v',type='"NS"QVector'," + "value='<1 items>',numchild='1',childtype='double'," + "childnumchild='0',children=[{value='-'}]}", // rounding... + "local.v"); + next(); + run("D","{iname='local.v',addr='-',name='v',type='"NS"QVector'," + "value='<2 items>',numchild='2'}"); + run("D","{iname='local.v',addr='-',name='v',type='"NS"QVector'," + "value='<2 items>',numchild='2',childtype='double'," + "childnumchild='0',children=[{value='-'},{value='-'}]}", + "local.v"); +} + ///////////////////////////////////////////////////////////////////////// // // Main From 83cc22b23358a87249462e842d70745c91333572 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 23 Oct 2009 14:36:36 +0200 Subject: [PATCH 53/91] fakevim: fix QTCREATORBUG-152 It took two 'u' to undo a '~'. --- src/plugins/fakevim/fakevimhandler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index abec06d97ea..d9f6a7c103e 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -1574,6 +1574,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, } else if (key == 'Z') { m_submode = CapitalZSubMode; } else if (key == '~' && !atEndOfLine()) { + beginEditBlock(); setAnchor(); moveRight(qMin(count(), rightDist())); QString str = selectedText(); @@ -1583,6 +1584,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, str[i] = c.isUpper() ? c.toLower() : c.toUpper(); } m_tc.insertText(str); + endEditBlock(); } else if (key == Key_PageDown || key == control('f')) { moveDown(count() * (linesOnScreen() - 2) - cursorLineOnScreen()); scrollToLineInDocument(cursorLineInDocument()); From 50038d591c3873d2ea0963346341544c976a0f44 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 23 Oct 2009 15:46:39 +0200 Subject: [PATCH 54/91] debugger: first shot at supporting qfDllInfo (only present in 6.4 symbianelf) --- src/plugins/debugger/gdb/gdbengine.cpp | 18 ++++++++++----- src/plugins/debugger/gdb/trkgdbadapter.cpp | 27 +++++++++++++++++++--- src/shared/trk/trkutils.h | 2 +- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 9146e293832..299cb97dfd0 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2183,15 +2183,21 @@ void GdbEngine::handleModulesList(const GdbResponse &response) QTextStream ts(&data, QIODevice::ReadOnly); while (!ts.atEnd()) { QString line = ts.readLine(); - if (!line.startsWith(__("0x"))) - continue; Module module; QString symbolsRead; QTextStream ts(&line, QIODevice::ReadOnly); - ts >> module.startAddress >> module.endAddress >> symbolsRead; - module.moduleName = ts.readLine().trimmed(); - module.symbolsRead = (symbolsRead == __("Yes")); - modules.append(module); + if (line.startsWith(__("0x"))) { + ts >> module.startAddress >> module.endAddress >> symbolsRead; + module.moduleName = ts.readLine().trimmed(); + module.symbolsRead = (symbolsRead == __("Yes")); + modules.append(module); + } else if (line.trimmed().startsWith(__("No"))) { + // gdb 6.4 symbianelf + ts >> symbolsRead; + QTC_ASSERT(symbolsRead == __("No"), continue); + module.moduleName = ts.readLine().trimmed(); + modules.append(module); + } } if (modules.isEmpty()) { // Mac has^done,shlib-info={num="1",name="dyld",kind="-", diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp index de7dfaebcf4..1c812e60af1 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp @@ -800,8 +800,26 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd) } else if (cmd == "qfDllInfo") { - // happens with gdb 6.4.50.20060226-cvs / CodeSourcery - // never made it into FSF gdb? + // That's the _first_ query package. + // Happens with gdb 6.4.50.20060226-cvs / CodeSourcery. + // Never made it into FSF gdb that got qXfer:libraries:read instead. + // http://sourceware.org/ml/gdb/2007-05/msg00038.html + // Name=hexname,TextSeg=textaddr[,DataSeg=dataaddr] + sendGdbServerAck(); + QByteArray response; // = "m"; + // FIXME: Limit packet length by using qsDllInfo packages? + foreach (const Library &lib, m_session.libraries) { + response += "Name=" + lib.name.toHex() + + ",TextSeg=" + hexNumber(lib.codeseg) + + ",DataSeg=" + hexNumber(lib.dataseg); + response += ';'; + } + response += "l"; + sendGdbServerMessage(response, "library information transfered"); + } + + else if (cmd == "qsDllInfo") { + // That's a following query package sendGdbServerAck(); sendGdbServerMessage("", "FIXME: nothing?"); } @@ -1067,7 +1085,10 @@ void TrkGdbAdapter::handleTrkResult(const TrkResult &result) // With CS gdb 6.4 we get a non-standard $qfDllInfo#7f+ request // afterwards, so don't use it for now. //sendGdbServerMessage("T05library:;"); - sendTrkMessage(0x18, TrkCallback(), trkContinueMessage(), "CONTINUE"); + sendGdbServerMessage("T05load:Name=" + lib.name.toHex() + + ",TextSeg=" + hexNumber(lib.codeseg) + + ",DataSeg=" + hexNumber(lib.dataseg) + ';'); + //sendTrkMessage(0x18, TrkCallback(), trkContinueMessage(), "CONTINUE"); break; } case 0xa1: { // NotifyDeleted diff --git a/src/shared/trk/trkutils.h b/src/shared/trk/trkutils.h index 441a2ba2c2d..aec86a17309 100644 --- a/src/shared/trk/trkutils.h +++ b/src/shared/trk/trkutils.h @@ -97,7 +97,7 @@ struct Library { Library() {} - QString name; + QByteArray name; uint codeseg; uint dataseg; }; From 33996aa12ec563c62f581aecb479f8a538897a5c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Oct 2009 16:59:27 +0200 Subject: [PATCH 55/91] remove bogus assertion the state check is in higher-level functions already --- src/plugins/debugger/gdb/trkgdbadapter.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp index 1c812e60af1..e17223bf223 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp @@ -1529,8 +1529,6 @@ void TrkGdbAdapter::readMemory(uint addr, uint len, bool buffered) void TrkGdbAdapter::interruptInferior() { - QTC_ASSERT(state() == AdapterStarted, qDebug() << state()); - logMessage("TRYING TO INTERRUPT INFERIOR"); sendTrkMessage(0x1a, TrkCallback(), trkInterruptMessage(), "Interrupting..."); } From 44cf1c46359b3cc28315b583cc6c70a4d5dcf787 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Oct 2009 17:03:45 +0200 Subject: [PATCH 56/91] no need for a real state check here - an assert will do and fix typo in debug message :)= --- src/plugins/debugger/gdb/gdbengine.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 299cb97dfd0..715e70d4962 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -615,18 +615,12 @@ void GdbEngine::readGdbStandardOutput() void GdbEngine::interruptInferior() { - QTC_ASSERT(state() == InferiorRunning, qDebug() << state()); - - if (state() == DebuggerNotReady) { - debugMessage(_("TRYING TO INTERRUPT INFERIOR WITHOUT RUNNING GDB")); - shutdown(); - return; - } + QTC_ASSERT(state() == InferiorRunning, qDebug() << state(); return); setState(InferiorStopping); showStatusMessage(tr("Stop requested..."), 5000); - debugMessage(_("TRYING TO INTERUPT INFERIOR")); + debugMessage(_("TRYING TO INTERRUPT INFERIOR")); m_gdbAdapter->interruptInferior(); } From d35dcd8dbef7e5dc6f2d87870267231f99379082 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 23 Oct 2009 17:06:25 +0200 Subject: [PATCH 57/91] debugger: better handling of qfDllInfo packet --- src/plugins/debugger/gdb/trkgdbadapter.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp index e17223bf223..c3604a80319 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp @@ -806,22 +806,23 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd) // http://sourceware.org/ml/gdb/2007-05/msg00038.html // Name=hexname,TextSeg=textaddr[,DataSeg=dataaddr] sendGdbServerAck(); - QByteArray response; // = "m"; + QByteArray response = "m"; // FIXME: Limit packet length by using qsDllInfo packages? - foreach (const Library &lib, m_session.libraries) { + for (int i = 0; i != m_session.libraries.size(); ++i) { + if (i) + response += ';'; + const Library &lib = m_session.libraries.at(i); response += "Name=" + lib.name.toHex() + ",TextSeg=" + hexNumber(lib.codeseg) + ",DataSeg=" + hexNumber(lib.dataseg); - response += ';'; } - response += "l"; sendGdbServerMessage(response, "library information transfered"); } else if (cmd == "qsDllInfo") { // That's a following query package sendGdbServerAck(); - sendGdbServerMessage("", "FIXME: nothing?"); + sendGdbServerMessage("l", "library information transfer finished"); } else if (cmd == "qPacketInfo") { From 1af61fefa8f22932cc0db0559782ec11b0e39fd0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Oct 2009 18:00:20 +0200 Subject: [PATCH 58/91] S60: Add startup logic for Bluetooth to the project/run configuration Prepare trk::Launcher to deal with a shared trkdevice. Add encapsulation for the rfcomm listener process and helper classes for prompting the user to connect the Bluetooth device. Add a command line prompt to the trklauncher test. --- src/plugins/coreplugin/messagemanager.cpp | 11 + src/plugins/coreplugin/messagemanager.h | 4 +- src/plugins/debugger/gdb/gdb.pri | 2 + .../gdb/s60debuggerbluetoothstarter.cpp | 51 +++ .../gdb/s60debuggerbluetoothstarter.h | 55 +++ .../qt4projectmanager/qt-s60/qt-s60.pri | 8 +- .../qt-s60/s60devicerunconfiguration.cpp | 17 + .../s60devicerunconfigurationwidget.cpp | 24 +- .../qt-s60/s60runconfigbluetoothstarter.cpp | 52 +++ .../qt-s60/s60runconfigbluetoothstarter.h | 53 +++ src/shared/trk/bluetoothlistener.cpp | 383 ++++++++++++++++++ src/shared/trk/bluetoothlistener.h | 174 ++++++++ src/shared/trk/bluetoothlistener_gui.cpp | 74 ++++ src/shared/trk/bluetoothlistener_gui.h | 58 +++ src/shared/trk/launcher.cpp | 112 +++-- src/shared/trk/launcher.h | 13 + src/shared/trk/trk.pri | 19 +- tests/manual/trklauncher/main.cpp | 103 +++-- tests/manual/trklauncher/trklauncher.pro | 2 +- 19 files changed, 1132 insertions(+), 83 deletions(-) create mode 100644 src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp create mode 100644 src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h create mode 100644 src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp create mode 100644 src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h create mode 100644 src/shared/trk/bluetoothlistener.cpp create mode 100644 src/shared/trk/bluetoothlistener.h create mode 100644 src/shared/trk/bluetoothlistener_gui.cpp create mode 100644 src/shared/trk/bluetoothlistener_gui.h diff --git a/src/plugins/coreplugin/messagemanager.cpp b/src/plugins/coreplugin/messagemanager.cpp index 6252d119d48..7ff9cee01cd 100644 --- a/src/plugins/coreplugin/messagemanager.cpp +++ b/src/plugins/coreplugin/messagemanager.cpp @@ -82,3 +82,14 @@ void MessageManager::printToOutputPane(const QString &text, bool bringToForegrou m_messageOutputWindow->popup(false); m_messageOutputWindow->append(text); } + +void MessageManager::printToOutputPanePopup(const QString &text) +{ + printToOutputPane(text, true); +} + +void MessageManager::printToOutputPane(const QString &text) +{ + printToOutputPane(text, false); +} + diff --git a/src/plugins/coreplugin/messagemanager.h b/src/plugins/coreplugin/messagemanager.h index 664269cda67..4191145cd88 100644 --- a/src/plugins/coreplugin/messagemanager.h +++ b/src/plugins/coreplugin/messagemanager.h @@ -55,7 +55,9 @@ public: void showOutputPane(); public slots: - void printToOutputPane(const QString &text, bool bringToForeground = true); + void printToOutputPane(const QString &text, bool bringToForeground); + void printToOutputPanePopup(const QString &text); // pops up + void printToOutputPane(const QString &text); private: Internal::MessageOutputWindow *m_messageOutputWindow; diff --git a/src/plugins/debugger/gdb/gdb.pri b/src/plugins/debugger/gdb/gdb.pri index e7763cecb6f..19f453ba7d6 100644 --- a/src/plugins/debugger/gdb/gdb.pri +++ b/src/plugins/debugger/gdb/gdb.pri @@ -19,6 +19,7 @@ HEADERS += \ $$PWD/termgdbadapter.h \ $$PWD/remotegdbadapter.h \ $$PWD/trkgdbadapter.h \ + $$PWD/s60debuggerbluetoothstarter.h SOURCES += \ $$PWD/gdbmi.cpp \ @@ -34,6 +35,7 @@ SOURCES += \ $$PWD/termgdbadapter.cpp \ $$PWD/remotegdbadapter.cpp \ $$PWD/trkgdbadapter.cpp \ + $$PWD/s60debuggerbluetoothstarter.cpp FORMS += $$PWD/gdboptionspage.ui \ $$PWD/trkoptionswidget.ui diff --git a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp new file mode 100644 index 00000000000..b1d34f4ff3a --- /dev/null +++ b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp @@ -0,0 +1,51 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "s60debuggerbluetoothstarter.h" +#include "debuggermanager.h" + +namespace Debugger { +namespace Internal { + +S60DebuggerBluetoothStarter::S60DebuggerBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent) : + trk::AbstractBluetoothStarter(trkDevice, parent) +{ +} + +trk::BluetoothListener *S60DebuggerBluetoothStarter::createListener() +{ + DebuggerManager *dm = DebuggerManager::instance(); + trk::BluetoothListener *rc = new trk::BluetoothListener(dm); + rc->setMode(trk::BluetoothListener::Listen); + connect(rc, SIGNAL(message(QString)), dm, SLOT(showDebuggerOutput(QString))); + return rc; +} + +} // namespace Internal +} // namespace Debugger diff --git a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h new file mode 100644 index 00000000000..216ab80a4b9 --- /dev/null +++ b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h @@ -0,0 +1,55 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef S60DEBUGGERBLUETOOTHSTARTER_H +#define S60DEBUGGERBLUETOOTHSTARTER_H + +#include "bluetoothlistener.h" + +namespace Debugger { +namespace Internal { + +/* S60DebuggerBluetoothStarter: Creates a listener in 'Listen' mode + * parented on the Debugger manager which outputs to the debugger window. + * Note: This is a "last resort" starter, normally, the run configuration + * should have already started a listener. */ + +class S60DebuggerBluetoothStarter : public trk::AbstractBluetoothStarter +{ +public: + explicit S60DebuggerBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); + +protected: + virtual trk::BluetoothListener *createListener(); +}; + +} // namespace Internal +} // namespace Debugger + +#endif // S60DEBUGGERBLUETOOTHSTARTER_H diff --git a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri index 8a445fa8de5..c1f2e857652 100644 --- a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri +++ b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri @@ -10,7 +10,9 @@ $$PWD/s60devicerunconfiguration.cpp \ $$PWD/s60devicerunconfigurationwidget.cpp \ $$PWD/serialdevicelister.cpp \ - $$PWD/rvcttoolchain.cpp + $$PWD/rvcttoolchain.cpp \ + $$PWD/s60runconfigbluetoothstarter.cpp + HEADERS += $$PWD/s60devices.h \ $$PWD/s60devicespreferencepane.h \ $$PWD/s60manager.h \ @@ -20,7 +22,9 @@ $$PWD/s60devicerunconfiguration.h \ $$PWD/s60devicerunconfigurationwidget.h \ $$PWD/serialdevicelister.h \ - $$PWD/rvcttoolchain.h + $$PWD/rvcttoolchain.h \ + $$PWD/s60runconfigbluetoothstarter.h + FORMS += $$PWD/s60devicespreferencepane.ui OTHER_FILES += $$PWD/qt-s60-todo.txt include(../../../shared/trk/trk.pri)||error("could not include trk.pri") diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index 64b1ee120cf..9ab5d93b3b7 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -34,6 +34,8 @@ #include "profilereader.h" #include "s60manager.h" #include "s60devices.h" +#include "s60runconfigbluetoothstarter.h" +#include "bluetoothlistener_gui.h" #include "serialdevicelister.h" #include @@ -572,6 +574,21 @@ void S60DeviceRunControlBase::signsisProcessFinished() initLauncher(runFileName, m_launcher); emit addToOutputWindow(this, tr("Package: %1\nDeploying application to '%2'...").arg(lsFile(copySrc), m_serialPortFriendlyName)); QString errorMessage; + // Prompt the user to start up the Blue tooth connection + if (m_communicationType == BlueToothCommunication) { + S60RunConfigBluetoothStarter starter(m_launcher->trkDevice()); + switch (trk::startBluetoothGui(starter, 0, &errorMessage)) { + case trk::BluetoothGuiConnected: + break; + case trk::BluetoothGuiCanceled: + case trk::BluetoothGuiError: + delete m_launcher; + m_launcher = 0; + error(this, errorMessage); + emit finished(); + return; + }; + } if (!m_launcher->startServer(&errorMessage)) { delete m_launcher; m_launcher = 0; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp index c0964e6fbb9..71369923abd 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp @@ -29,8 +29,12 @@ #include "s60devicerunconfigurationwidget.h" #include "s60devicerunconfiguration.h" +#include "s60runconfigbluetoothstarter.h" +#include "bluetoothlistener_gui.h" #include "s60manager.h" #include "launcher.h" +#include "bluetoothlistener.h" +#include "bluetoothlistener_gui.h" #include "serialdevicelister.h" #include @@ -278,6 +282,7 @@ void S60DeviceRunConfigurationWidget::setDeviceInfoLabel(const QString &message, QString(QLatin1String("background-color: red;")) : QString()); m_deviceInfoLabel->setText(message); + m_deviceInfoLabel->adjustSize(); } void S60DeviceRunConfigurationWidget::updateDeviceInfo() @@ -290,12 +295,29 @@ void S60DeviceRunConfigurationWidget::updateDeviceInfo() bool S60DeviceRunConfigurationWidget::getDeviceInfo(QString *message) { + message->clear(); // Do a launcher run with the ping protocol. Instantiate launcher on heap // as not to introduce delays when destructing a device with timeout - trk::Launcher *launcher = new trk::Launcher(trk::Launcher::ActionPingOnly, this); + trk::Launcher *launcher = new trk::Launcher(trk::Launcher::ActionPingOnly, QSharedPointer(), this); const CommunicationDevice commDev = currentDevice(); launcher->setSerialFrame(commDev.type == SerialPortCommunication); launcher->setTrkServerName(commDev.portName); + // Prompt the user to start + if (commDev.type == BlueToothCommunication) { + S60RunConfigBluetoothStarter starter(launcher->trkDevice()); + starter.setDevice(launcher->trkServerName()); + const trk::StartBluetoothGuiResult src = trk::startBluetoothGui(starter, this, message); + switch (src) { + case trk::BluetoothGuiConnected: + break; + case trk::BluetoothGuiCanceled: + launcher->deleteLater(); + return true; + case trk::BluetoothGuiError: + launcher->deleteLater(); + return false; + }; + } if (!launcher->startServer(message)) { launcher->deleteLater(); return false; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp new file mode 100644 index 00000000000..305d917597d --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp @@ -0,0 +1,52 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "s60runconfigbluetoothstarter.h" + +#include +#include + +namespace Qt4ProjectManager { +namespace Internal { + +S60RunConfigBluetoothStarter::S60RunConfigBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent) : + trk::AbstractBluetoothStarter(trkDevice, parent) +{ +} + +trk::BluetoothListener *S60RunConfigBluetoothStarter::createListener() +{ + Core::ICore *core = Core::ICore::instance(); + trk::BluetoothListener *rc = new trk::BluetoothListener(core); + rc->setMode(trk::BluetoothListener::Listen); + connect(rc, SIGNAL(message(QString)), core->messageManager(), SLOT(printToOutputPane(QString))); + return rc; +} +} // namespace Internal +} // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h new file mode 100644 index 00000000000..340f74082f4 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h @@ -0,0 +1,53 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef S60RUNCONFIGBLUETOOTHSTARTER_H +#define S60RUNCONFIGBLUETOOTHSTARTER_H + +#include "bluetoothlistener.h" + +namespace Qt4ProjectManager { +namespace Internal { + +/* S60RunConfigBluetoothStarter: Creates a listener in 'Listen' mode + * parented on the Qt Creator core which outputs to the message manager. */ + +class S60RunConfigBluetoothStarter : public trk::AbstractBluetoothStarter +{ +public: + explicit S60RunConfigBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); + +protected: + virtual trk::BluetoothListener *createListener(); +}; + +} // namespace Internal +} // namespace Qt4ProjectManager + +#endif // S60RUNCONFIGBLUETOOTHSTARTER_H diff --git a/src/shared/trk/bluetoothlistener.cpp b/src/shared/trk/bluetoothlistener.cpp new file mode 100644 index 00000000000..b395131ad39 --- /dev/null +++ b/src/shared/trk/bluetoothlistener.cpp @@ -0,0 +1,383 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "bluetoothlistener.h" +#include "trkdevice.h" + +#include +#include +#include + +#ifdef Q_OS_UNIX +# include +# include +#endif + +enum { debug = 0 }; + +namespace trk { + +struct BluetoothListenerPrivate { + BluetoothListenerPrivate(); + QString device; + QProcess process; + Q_PID pid; + bool printConsoleMessages; + BluetoothListener::Mode mode; +}; + +BluetoothListenerPrivate::BluetoothListenerPrivate() : + pid(0), + printConsoleMessages(false), + mode(BluetoothListener::Listen) +{ +} + +BluetoothListener::BluetoothListener(QObject *parent) : + QObject(parent), + d(new BluetoothListenerPrivate) +{ + d->process.setProcessChannelMode(QProcess::MergedChannels); + + connect(&d->process, SIGNAL(readyReadStandardError()), + this, SLOT(slotStdError())); + connect(&d->process, SIGNAL(readyReadStandardOutput()), + this, SLOT(slotStdOutput())); + connect(&d->process, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(slotProcessFinished(int,QProcess::ExitStatus))); + connect(&d->process, SIGNAL(error(QProcess::ProcessError)), + this, SLOT(slotProcessError(QProcess::ProcessError))); +} + +BluetoothListener::~BluetoothListener() +{ + const int trc = terminateProcess(); + if (debug) + qDebug() << "~BluetoothListener: terminated" << trc; + delete d; +} + +BluetoothListener::Mode BluetoothListener::mode() const +{ + return d->mode; +} + +void BluetoothListener::setMode(Mode m) +{ + d->mode = m; +} + +bool BluetoothListener::printConsoleMessages() const +{ + return d->printConsoleMessages; +} + +void BluetoothListener::setPrintConsoleMessages(bool p) +{ + d->printConsoleMessages = p; +} + +int BluetoothListener::terminateProcess() +{ + enum { TimeOutMS = 200 }; + if (debug) + qDebug() << "terminateProcess" << d->process.pid() << d->process.state(); + if (d->process.state() == QProcess::NotRunning) + return -1; + emitMessage(tr("%1: Stopping listener %2...").arg(d->device).arg(d->process.pid())); + // When listening, the process should terminate by itself after closing the connection + if (mode() == Listen && d->process.waitForFinished(TimeOutMS)) + return 0; +#ifdef Q_OS_UNIX + kill(d->process.pid(), SIGHUP); // Listens for SIGHUP + if (d->process.waitForFinished(TimeOutMS)) + return 1; +#endif + d->process.terminate(); + if (d->process.waitForFinished(TimeOutMS)) + return 2; + d->process.kill(); + return 3; +} + +bool BluetoothListener::start(const QString &device, QString *errorMessage) +{ + if (d->process.state() != QProcess::NotRunning) { + *errorMessage = QLatin1String("Internal error: Still running."); + return false; + } + d->device = device; + const QString binary = QLatin1String("rfcomm"); + QStringList arguments; + arguments << QLatin1String("-r") + << (d->mode == Listen ? QLatin1String("listen") : QLatin1String("watch")) + << device << QString(QLatin1Char('1')); + if (debug) + qDebug() << binary << arguments; + emitMessage(tr("%1: Starting Bluetooth listener %2...").arg(device, binary)); + d->pid = 0; + d->process.start(binary, arguments); + if (!d->process.waitForStarted()) { + *errorMessage = tr("Unable to run '%1': %2").arg(binary, d->process.errorString()); + return false; + } + d->pid = d->process.pid(); // Forgets it after crash/termination + emitMessage(tr("%1: Bluetooth listener running (%2).").arg(device).arg(d->process.pid())); + return true; +} + +void BluetoothListener::slotStdOutput() +{ + emitMessage(QString::fromLocal8Bit(d->process.readAllStandardOutput())); +} + +void BluetoothListener::emitMessage(const QString &m) +{ + if (d->printConsoleMessages || debug) + qDebug("%s\n", qPrintable(m)); + emit message(m); +} + +void BluetoothListener::slotStdError() +{ + emitMessage(QString::fromLocal8Bit(d->process.readAllStandardError())); +} + +void BluetoothListener::slotProcessFinished(int ex, QProcess::ExitStatus state) +{ + switch (state) { + case QProcess::NormalExit: + emitMessage(tr("%1: Process %2 terminated with exit code %3.") + .arg(d->device).arg(d->pid).arg(ex)); + break; + case QProcess::CrashExit: + emitMessage(tr("%1: Process %2 crashed.").arg(d->device).arg(d->pid)); + break; + } + emit terminated(); +} + +void BluetoothListener::slotProcessError(QProcess::ProcessError error) +{ + emitMessage(tr("%1: Process error %2: %3") + .arg(d->device).arg(error).arg(d->process.errorString())); +} + +// --------------- AbstractBluetoothStarter +struct AbstractBluetoothStarterPrivate { + explicit AbstractBluetoothStarterPrivate(const AbstractBluetoothStarter::TrkDevicePtr &d); + + const AbstractBluetoothStarter::TrkDevicePtr trkDevice; + BluetoothListener *listener; + QTimer *timer; + int intervalMS; + int attempts; + int n; + QString device; + QString errorString; + AbstractBluetoothStarter::State state; +}; + +AbstractBluetoothStarterPrivate::AbstractBluetoothStarterPrivate(const AbstractBluetoothStarter::TrkDevicePtr &d) : + + trkDevice(d), + listener(0), + timer(0), + intervalMS(1000), + attempts(-1), + n(0), + device(QLatin1String("/dev/rfcomm0")), + state(AbstractBluetoothStarter::TimedOut) +{ +} + +AbstractBluetoothStarter::AbstractBluetoothStarter(const TrkDevicePtr &trkDevice, QObject *parent) : + QObject(parent), + d(new AbstractBluetoothStarterPrivate(trkDevice)) +{ +} + +AbstractBluetoothStarter::~AbstractBluetoothStarter() +{ + stopTimer(); + delete d; +} + +void AbstractBluetoothStarter::stopTimer() +{ + if (d->timer && d->timer->isActive()) + d->timer->stop(); +} + +AbstractBluetoothStarter::StartResult AbstractBluetoothStarter::start() +{ + if (state() == Running) { + d->errorString = QLatin1String("Internal error, attempt to re-start AbstractBluetoothStarter.\n"); + return StartError; + } + // Before we instantiate timers, and such, try to open the device, + // which should succeed if another listener is already running in + // 'Watch' mode + if (d->trkDevice->open(d->device , &(d->errorString))) + return ConnectionSucceeded; + // Fire up the listener + d->n = 0; + d->listener = createListener(); + if (!d->listener->start(d->device, &(d->errorString))) + return StartError; + // Start timer + if (!d->timer) { + d->timer = new QTimer; + connect(d->timer, SIGNAL(timeout()), this, SLOT(slotTimer())); + } + d->timer->setInterval(d->intervalMS); + d->timer->setSingleShot(false); + d->timer->start(); + d->state = Running; + return Started; +} + +AbstractBluetoothStarter::State AbstractBluetoothStarter::state() const +{ + return d->state; +} + +int AbstractBluetoothStarter::intervalMS() const +{ + return d->intervalMS; +} + +void AbstractBluetoothStarter::setIntervalMS(int i) +{ + d->intervalMS = i; + if (d->timer) + d->timer->setInterval(i); +} + +int AbstractBluetoothStarter::attempts() const +{ + return d->attempts; +} + +void AbstractBluetoothStarter::setAttempts(int a) +{ + d->attempts = a; +} + +QString AbstractBluetoothStarter::device() const +{ + return d->device; +} + +void AbstractBluetoothStarter::setDevice(const QString &dv) +{ + d->device = dv; +} + +QString AbstractBluetoothStarter::errorString() const +{ + return d->errorString; +} + +void AbstractBluetoothStarter::slotTimer() +{ + ++d->n; + // Check for timeout + if (d->attempts >= 0 && d->n >= d->attempts) { + stopTimer(); + d->errorString = tr("%1: timed out after %n attempts using an interval of %2ms.", 0, d->n) + .arg(d->device).arg(d->intervalMS); + d->state = TimedOut; + emit timeout(); + } else { + // Attempt n to connect? + if (d->trkDevice->open(d->device , &(d->errorString))) { + stopTimer(); + const QString msg = tr("%1: Connection attempt %2 succeeded.").arg(d->device).arg(d->n); + d->listener->emitMessage(msg); + d->state = Connected; + emit connected(); + } else { + const QString msg = tr("%1: Connection attempt %2 failed: %3 (retrying)...") + .arg(d->device).arg(d->n).arg(d->errorString); + d->listener->emitMessage(msg); + } + } +} + +// -------- ConsoleBluetoothStarter +ConsoleBluetoothStarter::ConsoleBluetoothStarter(const TrkDevicePtr &trkDevice, + QObject *listenerParent, + QObject *parent) : + AbstractBluetoothStarter(trkDevice, parent), + m_listenerParent(listenerParent) +{ +} + +BluetoothListener *ConsoleBluetoothStarter::createListener() +{ + BluetoothListener *rc = new BluetoothListener(m_listenerParent); + rc->setMode(BluetoothListener::Listen); + rc->setPrintConsoleMessages(true); + return rc; +} + +bool ConsoleBluetoothStarter::startBluetooth(const TrkDevicePtr &trkDevice, + QObject *listenerParent, + const QString &device, + int attempts, + QString *errorMessage) +{ + // Set up a console starter to print to stdout. + ConsoleBluetoothStarter starter(trkDevice, listenerParent); + starter.setDevice(device); + starter.setAttempts(attempts); + switch (starter.start()) { + case Started: + break; + case ConnectionSucceeded: + return true; + case StartError: + *errorMessage = starter.errorString(); + return false; + } + // Run the starter with an event loop. @ToDo: Implement + // some asynchronous keypress read to cancel. + QEventLoop eventLoop; + connect(&starter, SIGNAL(connected()), &eventLoop, SLOT(quit())); + connect(&starter, SIGNAL(timeout()), &eventLoop, SLOT(quit())); + eventLoop.exec(QEventLoop::ExcludeUserInputEvents); + if (starter.state() != AbstractBluetoothStarter::Connected) { + *errorMessage = starter.errorString(); + return false; + } + return true; +} + +} // namespace trk diff --git a/src/shared/trk/bluetoothlistener.h b/src/shared/trk/bluetoothlistener.h new file mode 100644 index 00000000000..581a32cde1a --- /dev/null +++ b/src/shared/trk/bluetoothlistener.h @@ -0,0 +1,174 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef BLUETOOTHLISTENER_H +#define BLUETOOTHLISTENER_H + +#include +#include +#include + +namespace trk { +class TrkDevice; +struct BluetoothListenerPrivate; +struct AbstractBluetoothStarterPrivate; + +/* BluetoothListener: Starts a helper process watching connections on a + * Bluetooth device, Linux only: + * The rfcomm command is used. It process can be started in the background + * while connection attempts (TrkDevice::open()) are made in the foreground. */ + +class BluetoothListener : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(BluetoothListener) +public: + // The Mode property must be set before calling start(). + enum Mode { + Listen, /* Terminate after client closed (read: Trk app + * on the phone terminated or disconnected).*/ + Watch // Keep running, watch for next connection from client + }; + + explicit BluetoothListener(QObject *parent = 0); + virtual ~BluetoothListener(); + + Mode mode() const; + void setMode(Mode m); + + bool start(const QString &device, QString *errorMessage); + + // Print messages on the console. + bool printConsoleMessages() const; + void setPrintConsoleMessages(bool p); + +signals: + void terminated(); + void message(const QString &); + +public slots: + void emitMessage(const QString &m); // accessed by starter + +private slots: + void slotStdOutput(); + void slotStdError(); + void slotProcessFinished(int, QProcess::ExitStatus); + void slotProcessError(QProcess::ProcessError error); + +private: + int terminateProcess(); + + BluetoothListenerPrivate *d; +}; + +/* AbstractBluetoothStarter: Repeatedly tries to open a trk device + * until a connection succeeds, allowing to do something else in the + * foreground (local event loop or asynchronous operation). + * Note that in case a Listener is already running in watch mode, it might + * also happen that connection succeeds immediately. + * Implementations must provide a factory function that creates and sets up the + * listener (mode, message connection, etc). */ + +class AbstractBluetoothStarter : public QObject { + Q_OBJECT + Q_DISABLE_COPY(AbstractBluetoothStarter) +public: + typedef QSharedPointer TrkDevicePtr; + + enum State { Running, Connected, TimedOut }; + + virtual ~AbstractBluetoothStarter(); + + int intervalMS() const; + void setIntervalMS(int i); + + int attempts() const; + void setAttempts(int a); + + QString device() const; + void setDevice(const QString &); + + State state() const; + QString errorString() const; + + enum StartResult { + Started, // Starter is now running. + ConnectionSucceeded, /* Initial connection attempt succeeded, + * no need to keep running. */ + StartError // Error occurred during start. + }; + + StartResult start(); + +signals: + void connected(); + void timeout(); + +private slots: + void slotTimer(); + +protected: + explicit AbstractBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); + // Overwrite to create and parametrize the listener. + virtual BluetoothListener *createListener() = 0; + +private: + inline void stopTimer(); + + AbstractBluetoothStarterPrivate *d; +}; + +/* ConsoleBluetoothStarter: Convenience class for console processes. Creates a + * listener in "Listen" mode with the messages redirected to standard output. */ + +class ConsoleBluetoothStarter : public AbstractBluetoothStarter { + Q_OBJECT + Q_DISABLE_COPY(ConsoleBluetoothStarter) +public: + + static bool startBluetooth(const TrkDevicePtr& trkDevice, + QObject *listenerParent, + const QString &device, + int attempts, + QString *errorMessage); + +protected: + virtual BluetoothListener *createListener(); + +private: + explicit ConsoleBluetoothStarter(const TrkDevicePtr& trkDevice, + QObject *listenerParent, + QObject *parent = 0); + + QObject *m_listenerParent; +}; + +} // namespace trk + +#endif // BLUETOOTHLISTENER_H diff --git a/src/shared/trk/bluetoothlistener_gui.cpp b/src/shared/trk/bluetoothlistener_gui.cpp new file mode 100644 index 00000000000..9723a36d9d6 --- /dev/null +++ b/src/shared/trk/bluetoothlistener_gui.cpp @@ -0,0 +1,74 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "bluetoothlistener_gui.h" +#include "bluetoothlistener.h" + +#include +#include +#include +#include + +namespace trk { + +StartBluetoothGuiResult + startBluetoothGui(AbstractBluetoothStarter &starter, + QWidget *msgBoxParent, + QString *errorMessage) +{ + errorMessage->clear(); + switch (starter.start()) { + case AbstractBluetoothStarter::Started: + break; + case AbstractBluetoothStarter::ConnectionSucceeded: + return BluetoothGuiConnected; + case AbstractBluetoothStarter::StartError: + *errorMessage = starter.errorString(); + return BluetoothGuiError; + } + // Run the starter with the event loop of a message box, close it + // with the finished signals. + const QString title = QCoreApplication::translate("trk::startBluetoothGui", "Waiting for Bluetooth Connection"); + const QString message = QCoreApplication::translate("trk::startBluetoothGui", "Connecting to %1...").arg(starter.device()); + QMessageBox messageBox(QMessageBox::Information, title, message, QMessageBox::Cancel, msgBoxParent); + QObject::connect(&starter, SIGNAL(connected()), &messageBox, SLOT(close())); + QObject::connect(&starter, SIGNAL(timeout()), &messageBox, SLOT(close())); + messageBox.exec(); + // Only starter.state() is reliable here. + if (starter.state() == AbstractBluetoothStarter::Running) { + *errorMessage = QCoreApplication::translate("trk::startBluetoothGui", "Connection on %1 canceled.").arg(starter.device()); + return BluetoothGuiCanceled; + } + if (starter.state() != AbstractBluetoothStarter::Connected) { + *errorMessage = starter.errorString(); + return BluetoothGuiError; + } + return BluetoothGuiConnected; +} +} // namespace trk diff --git a/src/shared/trk/bluetoothlistener_gui.h b/src/shared/trk/bluetoothlistener_gui.h new file mode 100644 index 00000000000..2a7c57e291a --- /dev/null +++ b/src/shared/trk/bluetoothlistener_gui.h @@ -0,0 +1,58 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef BLUETOOTHLISTENER_GUI_H +#define BLUETOOTHLISTENER_GUI_H + +#include + +QT_BEGIN_NAMESPACE +class QWidget; +QT_END_NAMESPACE + +namespace trk { + class AbstractBluetoothStarter; + + /* startBluetoothGui(): Prompt the user to start a Bluetooth + * connection with a message box he can cancel. Pass in + * the starter with device and parameters set up. */ + + enum StartBluetoothGuiResult { + BluetoothGuiConnected, + BluetoothGuiCanceled, + BluetoothGuiError + }; + + StartBluetoothGuiResult + startBluetoothGui(AbstractBluetoothStarter &starter, + QWidget *msgBoxParent, + QString *errorMessage); +} // namespace trk + +#endif // BLUETOOTHLISTENER_GUI_H diff --git a/src/shared/trk/launcher.cpp b/src/shared/trk/launcher.cpp index cff53c02a18..f066ab4864f 100644 --- a/src/shared/trk/launcher.cpp +++ b/src/shared/trk/launcher.cpp @@ -30,6 +30,7 @@ #include "launcher.h" #include "trkutils.h" #include "trkdevice.h" +#include "bluetoothlistener.h" #include #include @@ -50,8 +51,9 @@ struct LauncherPrivate { int position; }; - LauncherPrivate(); - TrkDevice m_device; + explicit LauncherPrivate(const TrkDevicePtr &d); + + TrkDevicePtr m_device; QString m_trkServerName; QByteArray m_trkReadBuffer; @@ -65,21 +67,28 @@ struct LauncherPrivate { int m_verbose; Launcher::Actions m_startupActions; bool m_connected; + bool m_closeDevice; }; -LauncherPrivate::LauncherPrivate() : +LauncherPrivate::LauncherPrivate(const TrkDevicePtr &d) : + m_device(d), m_verbose(0), - m_connected(false) + m_connected(false), + m_closeDevice(true) { + if (m_device.isNull()) + m_device = TrkDevicePtr(new TrkDevice); } -Launcher::Launcher(Actions startupActions, QObject *parent) : +Launcher::Launcher(Actions startupActions, + const TrkDevicePtr &dev, + QObject *parent) : QObject(parent), - d(new LauncherPrivate) + d(new LauncherPrivate(dev)) { d->m_startupActions = startupActions; - connect(&d->m_device, SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult))); - connect(this, SIGNAL(finished()), &d->m_device, SLOT(close())); + connect(d->m_device.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult))); + connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close())); } Launcher::~Launcher() @@ -98,6 +107,16 @@ void Launcher::setTrkServerName(const QString &name) d->m_trkServerName = name; } +QString Launcher::trkServerName() const +{ + return d->m_trkServerName; +} + +TrkDevicePtr Launcher::trkDevice() const +{ + return d->m_device; +} + void Launcher::setFileName(const QString &name) { d->m_fileName = name; @@ -116,16 +135,28 @@ void Launcher::setInstallFileName(const QString &name) void Launcher::setSerialFrame(bool b) { - d->m_device.setSerialFrame(b); + d->m_device->setSerialFrame(b); } bool Launcher::serialFrame() const { - return d->m_device.serialFrame(); + return d->m_device->serialFrame(); +} + + +bool Launcher::closeDevice() const +{ + return d->m_closeDevice; +} + +void Launcher::setCloseDevice(bool c) +{ + d->m_closeDevice = c; } bool Launcher::startServer(QString *errorMessage) { + errorMessage->clear(); if (d->m_verbose) { const QString msg = QString::fromLatin1("Port=%1 Executable=%2 Package=%3 Remote Package=%4 Install file=%5") .arg(d->m_trkServerName, d->m_fileName, d->m_copyState.sourceFileName, d->m_copyState.destinationFileName, d->m_installFileName); @@ -148,15 +179,21 @@ bool Launcher::startServer(QString *errorMessage) qWarning("No remote executable given for running."); return false; } - if (!d->m_device.open(d->m_trkServerName, errorMessage)) + if (!d->m_device->isOpen() && !d->m_device->open(d->m_trkServerName, errorMessage)) return false; - d->m_device.sendTrkInitialPing(); - d->m_device.sendTrkMessage(TrkDisconnect); // Disconnect, as trk might be still connected - d->m_device.sendTrkMessage(TrkSupported, TrkCallback(this, &Launcher::handleSupportMask)); - d->m_device.sendTrkMessage(TrkCpuType, TrkCallback(this, &Launcher::handleCpuType)); - d->m_device.sendTrkMessage(TrkVersions, TrkCallback(this, &Launcher::handleTrkVersion)); + if (d->m_closeDevice) { + connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close())); + } else { + disconnect(this, SIGNAL(finished()), d->m_device.data(), 0); + } + + d->m_device->sendTrkInitialPing(); + d->m_device->sendTrkMessage(TrkDisconnect); // Disconnect, as trk might be still connected + d->m_device->sendTrkMessage(TrkSupported, TrkCallback(this, &Launcher::handleSupportMask)); + d->m_device->sendTrkMessage(TrkCpuType, TrkCallback(this, &Launcher::handleCpuType)); + d->m_device->sendTrkMessage(TrkVersions, TrkCallback(this, &Launcher::handleTrkVersion)); if (d->m_startupActions != ActionPingOnly) - d->m_device.sendTrkMessage(TrkConnect, TrkCallback(this, &Launcher::handleConnect)); + d->m_device->sendTrkMessage(TrkConnect, TrkCallback(this, &Launcher::handleConnect)); return true; } @@ -178,7 +215,7 @@ void Launcher::handleConnect(const TrkResult &result) void Launcher::setVerbose(int v) { d->m_verbose = v; - d->m_device.setVerbose(v); + d->m_device->setVerbose(v); } void Launcher::logMessage(const QString &msg) @@ -193,7 +230,7 @@ void Launcher::terminate() QByteArray ba; appendShort(&ba, 0x0000, TargetByteOrder); appendInt(&ba, d->m_session.pid, TargetByteOrder); - d->m_device.sendTrkMessage(TrkDeleteItem, TrkCallback(this, &Launcher::handleRemoteProcessKilled), ba); + d->m_device->sendTrkMessage(TrkDeleteItem, TrkCallback(this, &Launcher::handleRemoteProcessKilled), ba); } else if (d->m_connected) { if (d->m_copyState.copyFileHandle) closeRemoteFile(true); @@ -235,17 +272,17 @@ void Launcher::handleResult(const TrkResult &result) // uint pid = extractInt(data + 4); // ProcessID: 4 bytes; // uint tid = extractInt(data + 8); // ThreadID: 4 bytes //logMessage(prefix << " ADDR: " << addr << " PID: " << pid << " TID: " << tid); - d->m_device.sendTrkAck(result.token); + d->m_device->sendTrkAck(result.token); break; } case TrkNotifyException: { // Notify Exception (obsolete) logMessage(prefix + "NOTE: EXCEPTION " + str); - d->m_device.sendTrkAck(result.token); + d->m_device->sendTrkAck(result.token); break; } case TrkNotifyInternalError: { // logMessage(prefix + "NOTE: INTERNAL ERROR: " + str); - d->m_device.sendTrkAck(result.token); + d->m_device->sendTrkAck(result.token); break; } @@ -278,8 +315,8 @@ void Launcher::handleResult(const TrkResult &result) break; QByteArray ba; ba.append(result.data.mid(2, 8)); - d->m_device.sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE"); - //d->m_device.sendTrkAck(result.token) + d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE"); + //d->m_device->sendTrkAck(result.token) break; } case TrkNotifyDeleted: { // NotifyDeleted @@ -289,7 +326,7 @@ void Launcher::handleResult(const TrkResult &result) logMessage(QString::fromLatin1("%1 %2 UNLOAD: %3"). arg(QString::fromAscii(prefix)).arg(itemType ? QLatin1String("LIB") : QLatin1String("PROCESS")). arg(name)); - d->m_device.sendTrkAck(result.token); + d->m_device->sendTrkAck(result.token); if (itemType == 0 // process && result.data.size() >= 10 && d->m_session.pid == extractInt(result.data.data() + 6)) { @@ -299,17 +336,17 @@ void Launcher::handleResult(const TrkResult &result) } case TrkNotifyProcessorStarted: { // NotifyProcessorStarted logMessage(prefix + "NOTE: PROCESSOR STARTED: " + str); - d->m_device.sendTrkAck(result.token); + d->m_device->sendTrkAck(result.token); break; } case TrkNotifyProcessorStandBy: { // NotifyProcessorStandby logMessage(prefix + "NOTE: PROCESSOR STANDBY: " + str); - d->m_device.sendTrkAck(result.token); + d->m_device->sendTrkAck(result.token); break; } case TrkNotifyProcessorReset: { // NotifyProcessorReset logMessage(prefix + "NOTE: PROCESSOR RESET: " + str); - d->m_device.sendTrkAck(result.token); + d->m_device->sendTrkAck(result.token); break; } default: { @@ -384,7 +421,7 @@ void Launcher::continueCopying(uint lastCopiedBlockSize) QByteArray ba; appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder); appendString(&ba, d->m_copyState.data->mid(d->m_copyState.position, 2048), TargetByteOrder, false); - d->m_device.sendTrkMessage(TrkWriteFile, TrkCallback(this, &Launcher::handleCopy), ba); + d->m_device->sendTrkMessage(TrkWriteFile, TrkCallback(this, &Launcher::handleCopy), ba); } else { closeRemoteFile(); } @@ -395,7 +432,7 @@ void Launcher::closeRemoteFile(bool failed) QByteArray ba; appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder); appendInt(&ba, QDateTime::currentDateTime().toTime_t(), TargetByteOrder); - d->m_device.sendTrkMessage(TrkCloseFile, + d->m_device->sendTrkMessage(TrkCloseFile, failed ? TrkCallback() : TrkCallback(this, &Launcher::handleFileCopied), ba); d->m_copyState.data.reset(); @@ -458,7 +495,7 @@ void Launcher::handleCreateProcess(const TrkResult &result) QByteArray ba; appendInt(&ba, d->m_session.pid); appendInt(&ba, d->m_session.tid); - d->m_device.sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE"); + d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE"); } void Launcher::handleWaitForFinished(const TrkResult &result) @@ -496,7 +533,7 @@ void Launcher::cleanUp() appendByte(&ba, 0x00); appendByte(&ba, 0x00); appendInt(&ba, d->m_session.pid); - d->m_device.sendTrkMessage(TrkDeleteItem, TrkCallback(), ba, "Delete process"); + d->m_device->sendTrkMessage(TrkDeleteItem, TrkCallback(), ba, "Delete process"); //---TRK------------------------------------------------------ // Command: 0x80 Acknowledge @@ -540,7 +577,7 @@ void Launcher::cleanUp() void Launcher::disconnectTrk() { - d->m_device.sendTrkMessage(TrkDisconnect, TrkCallback(this, &Launcher::handleWaitForFinished)); + d->m_device->sendTrkMessage(TrkDisconnect, TrkCallback(this, &Launcher::handleWaitForFinished)); } void Launcher::copyFileToRemote() @@ -549,7 +586,7 @@ void Launcher::copyFileToRemote() QByteArray ba; appendByte(&ba, 0x10); appendString(&ba, d->m_copyState.destinationFileName.toLocal8Bit(), TargetByteOrder, false); - d->m_device.sendTrkMessage(TrkOpenFile, TrkCallback(this, &Launcher::handleFileCreation), ba); + d->m_device->sendTrkMessage(TrkOpenFile, TrkCallback(this, &Launcher::handleFileCreation), ba); } void Launcher::installRemotePackageSilently() @@ -558,7 +595,7 @@ void Launcher::installRemotePackageSilently() QByteArray ba; appendByte(&ba, 'C'); appendString(&ba, d->m_installFileName.toLocal8Bit(), TargetByteOrder, false); - d->m_device.sendTrkMessage(TrkInstallFile, TrkCallback(this, &Launcher::handleInstallPackageFinished), ba); + d->m_device->sendTrkMessage(TrkInstallFile, TrkCallback(this, &Launcher::handleInstallPackageFinished), ba); } void Launcher::handleInstallPackageFinished(const TrkResult &result) @@ -586,7 +623,6 @@ void Launcher::startInferiorIfNeeded() appendByte(&ba, 0); // create new process appendByte(&ba, 0); // ? appendString(&ba, d->m_fileName.toLocal8Bit(), TargetByteOrder); - d->m_device.sendTrkMessage(TrkCreateItem, TrkCallback(this, &Launcher::handleCreateProcess), ba); // Create Item -} - + d->m_device->sendTrkMessage(TrkCreateItem, TrkCallback(this, &Launcher::handleCreateProcess), ba); // Create Item } +} // namespace trk diff --git a/src/shared/trk/launcher.h b/src/shared/trk/launcher.h index 93f5d52923e..2c4881de6d1 100644 --- a/src/shared/trk/launcher.h +++ b/src/shared/trk/launcher.h @@ -29,8 +29,11 @@ #ifndef LAUNCHER_H #define LAUNCHER_H +#include "trkdevice.h" + #include #include +#include namespace trk { @@ -38,9 +41,12 @@ struct TrkResult; struct TrkMessage; struct LauncherPrivate; +typedef QSharedPointer TrkDevicePtr; + class Launcher : public QObject { Q_OBJECT + Q_DISABLE_COPY(Launcher) public: typedef void (Launcher::*TrkCallBack)(const TrkResult &); @@ -56,10 +62,12 @@ public: }; explicit Launcher(trk::Launcher::Actions startupActions = trk::Launcher::ActionPingOnly, + const TrkDevicePtr &trkDevice = TrkDevicePtr(), QObject *parent = 0); ~Launcher(); void addStartupActions(trk::Launcher::Actions startupActions); void setTrkServerName(const QString &name); + QString trkServerName() const; void setFileName(const QString &name); void setCopyFileName(const QString &srcName, const QString &dstName); void setInstallFileName(const QString &name); @@ -67,6 +75,11 @@ public: void setVerbose(int v); void setSerialFrame(bool b); bool serialFrame() const; + // Close device or leave it open + bool closeDevice() const; + void setCloseDevice(bool c); + + TrkDevicePtr trkDevice() const; // becomes valid after successful execution of ActionPingOnly QString deviceDescription(unsigned verbose = 0u) const; diff --git a/src/shared/trk/trk.pri b/src/shared/trk/trk.pri index 1564e4684dd..8965948f194 100644 --- a/src/shared/trk/trk.pri +++ b/src/shared/trk/trk.pri @@ -1,13 +1,20 @@ INCLUDEPATH *= $$PWD # Input -HEADERS += \ - $$PWD/callback.h \ +HEADERS += $$PWD/callback.h \ $$PWD/trkutils.h \ $$PWD/trkdevice.h \ - $$PWD/launcher.h + $$PWD/launcher.h \ + $$PWD/bluetoothlistener.h -SOURCES += \ - $$PWD/trkutils.cpp \ +SOURCES += $$PWD/trkutils.cpp \ $$PWD/trkdevice.cpp \ - $$PWD/launcher.cpp + $$PWD/launcher.cpp \ + $$PWD/bluetoothlistener.cpp + +contains(QT, gui) { + HEADERS += $$PWD/bluetoothlistener_gui.h + SOURCES += $$PWD/bluetoothlistener_gui.cpp +} else { + message(Trk: Console ...) +} diff --git a/tests/manual/trklauncher/main.cpp b/tests/manual/trklauncher/main.cpp index 65031e7cc5a..e9847d33b8f 100644 --- a/tests/manual/trklauncher/main.cpp +++ b/tests/manual/trklauncher/main.cpp @@ -1,13 +1,19 @@ #include "launcher.h" +#include "bluetoothlistener.h" #include +#include #include #include static const char *usageC = -"\nUsage: %1 [-v] [-i remote_sis_file | -I local_sis_file remote_sis_file] []\n" +"\n" +"Usage: %1 [options] \n" +" %1 [options] -i remote_sis_file\n" +" %1 [options] -I local_sis_file remote_sis_file] []\n" "\nOptions:\n -v verbose\n" - " -f turn serial message frame off\n\n" + " -b Prompt for Bluetooth connect (Linux only)\n" + " -f turn serial message frame off (Bluetooth)\n" "\nPing:\n" "%1 COM5\n" "\nRemote launch:\n" @@ -27,74 +33,94 @@ static void usage() qWarning("%s", qPrintable(msg)); } -static bool parseArguments(const QStringList &arguments, trk::Launcher &launcher) +typedef QSharedPointer TrkLauncherPtr; + +// Parse arguments, return pointer or a null none. + +static inline TrkLauncherPtr createLauncher(trk::Launcher::Actions actions, + const QString &serverName, + bool serialFrame, + int verbosity) +{ + TrkLauncherPtr launcher(new trk::Launcher(actions)); + launcher->setTrkServerName(serverName); + launcher->setSerialFrame(serialFrame); + launcher->setVerbose(verbosity); + return launcher; +} + +static TrkLauncherPtr parseArguments(const QStringList &arguments, bool *bluetooth) { // Parse away options bool install = false; bool customInstall = false; + bool serialFrame = true; const int argCount = arguments.size(); int verbosity = 0; + *bluetooth = false; + trk::Launcher::Actions actions = trk::Launcher::ActionPingOnly; int a = 1; for ( ; a < argCount; a++) { const QString option = arguments.at(a); if (!option.startsWith(QLatin1Char('-'))) break; if (option.size() != 2) - return false; + return TrkLauncherPtr(); switch (option.at(1).toAscii()) { case 'v': verbosity++; break; case 'f': - launcher.setSerialFrame(false); - break;verbosity++; + serialFrame = false; + break; + case 'b': + *bluetooth = true; + break; case 'i': install = true; - launcher.addStartupActions(trk::Launcher::ActionInstall); + actions = trk::Launcher::ActionInstall; break; case 'I': customInstall = true; - launcher.addStartupActions(trk::Launcher::ActionCopyInstall); + actions = trk::Launcher::ActionCopyInstall; break; default: - return false; + return TrkLauncherPtr(); } } - - launcher.setVerbose(verbosity); // Evaluate arguments const int remainingArgsCount = argCount - a; - if (remainingArgsCount == 1 && !install && !customInstall) { - launcher.setTrkServerName(arguments.at(a)); // ping - return true; + if (remainingArgsCount == 1 && !install && !customInstall) { // Ping + return createLauncher(actions, arguments.at(a), serialFrame, verbosity); } if (remainingArgsCount == 2 && !install && !customInstall) { // remote exec - launcher.addStartupActions(trk::Launcher::ActionRun); - launcher.setTrkServerName(arguments.at(a)); - launcher.setFileName(arguments.at(a + 1)); - return true; + TrkLauncherPtr launcher = createLauncher(actions, arguments.at(a), serialFrame, verbosity); + launcher->addStartupActions(trk::Launcher::ActionRun); + launcher->setFileName(arguments.at(a + 1)); + return launcher; } if ((remainingArgsCount == 3 || remainingArgsCount == 2) && install && !customInstall) { - launcher.setTrkServerName(arguments.at(a)); // ping - launcher.setInstallFileName(arguments.at(a + 1)); + TrkLauncherPtr launcher = createLauncher(actions, arguments.at(a), serialFrame, verbosity); + launcher->setInstallFileName(arguments.at(a + 1)); if (remainingArgsCount == 3) { - launcher.addStartupActions(trk::Launcher::ActionRun); - launcher.setFileName(arguments.at(a + 2)); + launcher->addStartupActions(trk::Launcher::ActionRun); + launcher->setFileName(arguments.at(a + 2)); } - return true; + return launcher; } if ((remainingArgsCount == 4 || remainingArgsCount == 3) && !install && customInstall) { - launcher.setTrkServerName(arguments.at(a)); // ping - launcher.setCopyFileName(arguments.at(a + 1), arguments.at(a + 2)); - launcher.setInstallFileName(arguments.at(a + 2)); + TrkLauncherPtr launcher = createLauncher(actions, arguments.at(a), serialFrame, verbosity); + launcher->setTrkServerName(arguments.at(a)); // ping + launcher->setCopyFileName(arguments.at(a + 1), arguments.at(a + 2)); + launcher->setInstallFileName(arguments.at(a + 2)); if (remainingArgsCount == 4) { - launcher.addStartupActions(trk::Launcher::ActionRun); - launcher.setFileName(arguments.at(a + 3)); + launcher->addStartupActions(trk::Launcher::ActionRun); + launcher->setFileName(arguments.at(a + 3)); } - return true; + return launcher; } - return false; + return TrkLauncherPtr(); } int main(int argc, char *argv[]) @@ -103,14 +129,23 @@ int main(int argc, char *argv[]) QCoreApplication::setApplicationName(QLatin1String("trklauncher")); QCoreApplication::setOrganizationName(QLatin1String("Nokia")); - trk::Launcher launcher; - if (!parseArguments(app.arguments(), launcher)) { + bool bluetooth; + const TrkLauncherPtr launcher = parseArguments(app.arguments(), &bluetooth); + if (launcher.isNull()) { usage(); return 1; } - QObject::connect(&launcher, SIGNAL(finished()), &app, SLOT(quit())); + QObject::connect(launcher.data(), SIGNAL(finished()), &app, SLOT(quit())); + // BLuetooth: Open with prompt QString errorMessage; - if (launcher.startServer(&errorMessage)) + if (bluetooth && !trk::ConsoleBluetoothStarter::startBluetooth(launcher->trkDevice(), + launcher.data(), + launcher->trkServerName(), + 30, &errorMessage)) { + qWarning("%s\n", qPrintable(errorMessage)); + return -1; + } + if (launcher->startServer(&errorMessage)) return app.exec(); qWarning("%s\n", qPrintable(errorMessage)); return 4; diff --git a/tests/manual/trklauncher/trklauncher.pro b/tests/manual/trklauncher/trklauncher.pro index 73e7f7d7818..943afde4ada 100644 --- a/tests/manual/trklauncher/trklauncher.pro +++ b/tests/manual/trklauncher/trklauncher.pro @@ -1,5 +1,5 @@ TEMPLATE = app QT = core +CONFIG += console include(../../../src/shared/trk/trk.pri) -win32:CONFIG += console SOURCES += main.cpp From 1c528c48ccb11403f01c9e60145e0f99609ba815 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Oct 2009 18:19:53 +0200 Subject: [PATCH 59/91] Fix compilation on Windows --- src/shared/trk/bluetoothlistener.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/shared/trk/bluetoothlistener.cpp b/src/shared/trk/bluetoothlistener.cpp index b395131ad39..6b22dea6d4c 100644 --- a/src/shared/trk/bluetoothlistener.cpp +++ b/src/shared/trk/bluetoothlistener.cpp @@ -37,8 +37,26 @@ #ifdef Q_OS_UNIX # include # include +#else +# include #endif +// Process id helpers. +#ifdef Q_OS_WIN +inline DWORD processId(const QProcess &p) +{ + if (const Q_PID processInfoStruct = p.pid()) + return processInfoStruct->dwProcessId; + return 0; +} +#else +inline Q_PID processId(const QProcess &p) +{ + return p.pid(); +} +#endif + + enum { debug = 0 }; namespace trk { @@ -47,7 +65,11 @@ struct BluetoothListenerPrivate { BluetoothListenerPrivate(); QString device; QProcess process; +#ifdef Q_OS_WIN + DWORD pid; +#else Q_PID pid; +#endif bool printConsoleMessages; BluetoothListener::Mode mode; }; @@ -110,7 +132,7 @@ int BluetoothListener::terminateProcess() qDebug() << "terminateProcess" << d->process.pid() << d->process.state(); if (d->process.state() == QProcess::NotRunning) return -1; - emitMessage(tr("%1: Stopping listener %2...").arg(d->device).arg(d->process.pid())); + emitMessage(tr("%1: Stopping listener %2...").arg(d->device).arg(processId(d->process))); // When listening, the process should terminate by itself after closing the connection if (mode() == Listen && d->process.waitForFinished(TimeOutMS)) return 0; @@ -147,8 +169,8 @@ bool BluetoothListener::start(const QString &device, QString *errorMessage) *errorMessage = tr("Unable to run '%1': %2").arg(binary, d->process.errorString()); return false; } - d->pid = d->process.pid(); // Forgets it after crash/termination - emitMessage(tr("%1: Bluetooth listener running (%2).").arg(device).arg(d->process.pid())); + d->pid = processId(d->process); // Forgets it after crash/termination + emitMessage(tr("%1: Bluetooth listener running (%2).").arg(device).arg(processId(d->process))); return true; } From 05f29012d924568fa18d2d86581fd6ba734d5462 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Fri, 23 Oct 2009 18:40:46 +0200 Subject: [PATCH 60/91] S60: Deleting allocated TrkLauncher in dtor of S60DeviceRunControlBase. --- .../qt-s60/s60devicerunconfiguration.cpp | 8 ++++++++ .../qt4projectmanager/qt-s60/s60devicerunconfiguration.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index 9ab5d93b3b7..d547c3b6d83 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -435,6 +435,14 @@ S60DeviceRunControlBase::S60DeviceRunControlBase(const QSharedPointerdeleteLater(); + m_launcher = 0; + } +} + void S60DeviceRunControlBase::start() { emit started(); diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h index 1efaca48f4a..444e8855f65 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h @@ -129,7 +129,7 @@ class S60DeviceRunControlBase : public ProjectExplorer::RunControl Q_OBJECT public: explicit S60DeviceRunControlBase(const QSharedPointer &runConfiguration); - ~S60DeviceRunControlBase() {} + ~S60DeviceRunControlBase(); virtual void start(); virtual void stop(); virtual bool isRunning() const; From f3aefdf5892d3dfed5a3614ce4461163ec5ad94b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 22:55:30 +0200 Subject: [PATCH 61/91] don't print error messages in quotes --- src/plugins/help/helpplugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 8421dca38d2..381b56bb34f 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -618,7 +618,7 @@ void HelpPlugin::extensionsInitialized() + QLatin1String("../../share/doc/qtcreator/qtcreator.qch")); #endif if (!hc.registerDocumentation(qchFileName)) - qDebug() << hc.error(); + qDebug() << qPrintable(hc.error()); needsSetup = true; } From 393123be4539169ed3bb98bd555c5063d91e4199 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 22:55:09 +0200 Subject: [PATCH 62/91] jump is a RunRequest, too --- src/plugins/debugger/gdb/gdbengine.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 715e70d4962..45ec57e8d5d 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1651,7 +1651,8 @@ void GdbEngine::jumpToLineExec(const QString &fileName, int lineNumber) // not available everywhere? //sendCliCommand(_("tbreak ") + fileName + ':' + QString::number(lineNumber)); postCommand(_("-break-insert -t ") + fileName + _c(':') + QString::number(lineNumber)); - postCommand(_("jump ") + fileName + _c(':') + QString::number(lineNumber)); + setState(InferiorRunningRequested); + postCommand(_("jump ") + fileName + _c(':') + QString::number(lineNumber), RunRequest); // will produce something like // &"jump /home/apoenitz/dev/work/test1/test1.cpp:242" // ~"Continuing at 0x4058f3." @@ -1664,7 +1665,8 @@ void GdbEngine::jumpToLineExec(const QString &fileName, int lineNumber) #else gotoLocation(frame, true); setBreakpoint(fileName, lineNumber); - postCommand(_("jump ") + fileName + ':' + QString::number(lineNumber)); + setState(InferiorRunningRequested); + postCommand(_("jump ") + fileName + ':' + QString::number(lineNumber), RunRequest); #endif } From 96a5ff74d9d67a8d7a733c5ba5e2e122d15a94d9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Oct 2009 17:32:11 +0200 Subject: [PATCH 63/91] disable remainders of the plugin loading settings code --- src/plugins/debugger/gdb/gdbengine.cpp | 5 +++++ src/plugins/debugger/gdb/gdboptionspage.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 45ec57e8d5d..cb9e822184c 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1049,6 +1049,10 @@ void GdbEngine::handleStopResponse(const GdbMi &data) } setState(InferiorStopped); +#if 0 + // The related code (handleAqcuiredInferior()) is disabled as well. + // When re-enabling, try something to avoid spurious source list updates + // due to unrelated no-reason stops. const QByteArray &msg = data.findChild("consolestreamoutput").data(); if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) { m_modulesListOutdated = true; @@ -1064,6 +1068,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data) } // fall through } +#endif // seen on XP after removing a breakpoint while running // >945*stopped,reason="signal-received",signal-name="SIGTRAP", diff --git a/src/plugins/debugger/gdb/gdboptionspage.cpp b/src/plugins/debugger/gdb/gdboptionspage.cpp index 226bfb7283a..b030e44977f 100644 --- a/src/plugins/debugger/gdb/gdboptionspage.cpp +++ b/src/plugins/debugger/gdb/gdboptionspage.cpp @@ -51,6 +51,9 @@ QWidget *GdbOptionsPage::createPage(QWidget *parent) m_group.insert(theDebuggerAction(GdbEnvironment), m_ui.environmentEdit); +#if 1 + m_ui.groupBoxPluginDebugging->hide(); +#else // The related code (handleAqcuiredInferior()) is disabled as well. m_group.insert(theDebuggerAction(AllPluginBreakpoints), m_ui.radioButtonAllPluginBreakpoints); m_group.insert(theDebuggerAction(SelectedPluginBreakpoints), @@ -59,6 +62,7 @@ QWidget *GdbOptionsPage::createPage(QWidget *parent) m_ui.radioButtonNoPluginBreakpoints); m_group.insert(theDebuggerAction(SelectedPluginBreakpointsPattern), m_ui.lineEditSelectedPluginBreakpointsPattern); +#endif m_ui.lineEditSelectedPluginBreakpointsPattern-> setEnabled(theDebuggerAction(SelectedPluginBreakpoints)->value().toBool()); From 087733e5d5db67ec9b83ba9b16e820b6e53d1807 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Oct 2009 21:32:08 +0200 Subject: [PATCH 64/91] avoid copy of GdbResponse struct --- src/plugins/debugger/gdb/gdbengine.cpp | 29 +++++++++++++------------- src/plugins/debugger/gdb/gdbengine.h | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index cb9e822184c..79ae8fafdcd 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -568,7 +568,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) m_pendingLogStreamOutput.clear(); m_pendingConsoleStreamOutput.clear(); - handleResultRecord(response); + handleResultRecord(&response); break; } default: { @@ -733,13 +733,13 @@ void GdbEngine::flushCommand(const GdbCommand &cmd0) m_gdbAdapter->write(cmd.command.toLatin1() + "\r\n"); } -void GdbEngine::handleResultRecord(const GdbResponse &response) +void GdbEngine::handleResultRecord(GdbResponse *response) { //qDebug() << "TOKEN:" << response.token // << " ACCEPTABLE:" << m_oldestAcceptableToken; //qDebug() << "\nRESULT" << response.token << response.toString(); - int token = response.token; + int token = response->token; if (token == -1) return; @@ -750,8 +750,8 @@ void GdbEngine::handleResultRecord(const GdbResponse &response) // Ideally, this code should not be present at all. debugMessage(_("COOKIE FOR TOKEN %1 ALREADY EATEN. " "TWO RESPONSES FOR ONE COMMAND?").arg(token)); - if (response.resultClass == GdbResultError) { - QByteArray msg = response.data.findChild("msg").data(); + if (response->resultClass == GdbResultError) { + QByteArray msg = response->data.findChild("msg").data(); if (msg == "Cannot find new threads: generic error") { // Handle a case known to occur on Linux/gdb 6.8 when debugging moc // with helpers enabled. In this case we get a second response with @@ -788,26 +788,25 @@ void GdbEngine::handleResultRecord(const GdbResponse &response) .arg(cmd.postTime.msecsTo(QTime::currentTime()) / 1000.)); } - if (response.token < m_oldestAcceptableToken && (cmd.flags & Discardable)) { + if (response->token < m_oldestAcceptableToken && (cmd.flags & Discardable)) { //debugMessage(_("### SKIPPING OLD RESULT") + response.toString()); return; } - GdbResponse responseWithCookie = response; - responseWithCookie.cookie = cmd.cookie; + response->cookie = cmd.cookie; - if (response.resultClass != GdbResultError && - response.resultClass != ((cmd.flags & RunRequest) ? GdbResultRunning : - (cmd.flags & ExitRequest) ? GdbResultExit : - GdbResultDone)) { - QString rsp = _(GdbResponse::stringFromResultClass(response.resultClass)); + if (response->resultClass != GdbResultError && + response->resultClass != ((cmd.flags & RunRequest) ? GdbResultRunning : + (cmd.flags & ExitRequest) ? GdbResultExit : + GdbResultDone)) { + QString rsp = _(GdbResponse::stringFromResultClass(response->resultClass)); qWarning() << "UNEXPECTED RESPONSE " << rsp << " TO COMMAND" << cmd.command << " AT " __FILE__ ":" STRINGIFY(__LINE__); debugMessage(_("UNEXPECTED RESPONSE %1 TO COMMAND %2").arg(rsp).arg(cmd.command)); } else { if (cmd.callback) - (this->*cmd.callback)(responseWithCookie); + (this->*cmd.callback)(*response); else if (cmd.adapterCallback) - (m_gdbAdapter->*cmd.adapterCallback)(responseWithCookie); + (m_gdbAdapter->*cmd.adapterCallback)(*response); } if (cmd.flags & RebuildModel) { diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 6e6db609c48..d26db4da69b 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -246,7 +246,7 @@ private: ////////// Gdb Output, State & Capability Handling ////////// void handleResponse(const QByteArray &buff); void handleStopResponse(const GdbMi &data); - void handleResultRecord(const GdbResponse &response); + void handleResultRecord(GdbResponse *response); void handleStop1(const GdbResponse &response); void handleStop1(const GdbMi &data); void handleStop2(const GdbResponse &response); From 31818acb116c99f334a2c7666037a82f8f8bd48b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Oct 2009 18:45:01 +0200 Subject: [PATCH 65/91] eliminate desperate attempts to keep short-long filename mapping complete *in theory*, there is no way we could at any point know more than gdb knows and tells us about full path names. let's see what practice shows for the gdbs we support ... --- src/plugins/debugger/gdb/gdbengine.cpp | 84 +++++++------------------- src/plugins/debugger/gdb/gdbengine.h | 2 - 2 files changed, 22 insertions(+), 64 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 79ae8fafdcd..20a5683e6b6 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1219,18 +1219,7 @@ void GdbEngine::handleStop2(const GdbResponse &response) void GdbEngine::handleStop2(const GdbMi &data) { - // Sometimes we get some interesting extra information. Grab it. const GdbMi gdbmiFrame = data.findChild("frame"); - GdbMi shortName = gdbmiFrame.findChild("file"); - GdbMi fullName = gdbmiFrame.findChild("fullname"); - if (shortName.isValid() && fullName.isValid()) { - QString file = QFile::decodeName(shortName.data()); - QString full = QFile::decodeName(fullName.data()); - if (file != full) { - m_shortToFullName[file] = full; - m_fullToShortName[full] = file; - } - } // Quick shot: Jump to stack frame #0. StackFrame frame; @@ -1356,21 +1345,6 @@ QString GdbEngine::fullName(const QString &fileName) return full; } -QString GdbEngine::fullName(const QStringList &candidates) -{ - QString full; - foreach (const QString &fileName, candidates) { - full = fullName(fileName); - if (!full.isEmpty()) - return full; - } - foreach (const QString &fileName, candidates) { - if (!fileName.isEmpty()) - return fileName; - } - return full; -} - void GdbEngine::shutdown() { debugMessage(_("INITIATE GDBENGINE SHUTDOWN")); @@ -1727,7 +1701,7 @@ void GdbEngine::breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt data->bpMultiple = false; data->bpEnabled = true; data->bpCondition.clear(); - QStringList files; + QByteArray file, fullName; foreach (const GdbMi &child, bkpt.children()) { if (child.hasName("number")) { data->bpNumber = _(child.data()); @@ -1741,13 +1715,9 @@ void GdbEngine::breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt else data->bpAddress = _(child.data()); } else if (child.hasName("file")) { - files.append(QFile::decodeName(child.data())); + file = child.data(); } else if (child.hasName("fullname")) { - QString fullName = QFile::decodeName(child.data()); - #ifdef Q_OS_WIN - fullName = QDir::cleanPath(fullName); - #endif - files.prepend(fullName); + fullName = child.data(); } else if (child.hasName("line")) { data->bpLineNumber = _(child.data()); if (child.data().toInt()) @@ -1761,17 +1731,8 @@ void GdbEngine::breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt data->bpEnabled = (child.data() == "y"); } else if (child.hasName("pending")) { data->pending = true; - int pos = child.data().lastIndexOf(':'); - if (pos > 0) { - data->bpLineNumber = _(child.data().mid(pos + 1)); - data->markerLineNumber = child.data().mid(pos + 1).toInt(); - QString file = QString::fromLocal8Bit(child.data().left(pos)); - if (file.startsWith(_c('"')) && file.endsWith(_c('"'))) - file = file.mid(1, file.size() - 2); - files.prepend(file); - } else { - files.prepend(QString::fromLocal8Bit(child.data())); - } + // Any content here would be interesting only if we did accept + // spontaneously appearing breakpoints (user using gdb commands). } else if (child.hasName("at")) { // Happens with (e.g.?) gdb 6.4 symbianelf QByteArray ba = child.data(); @@ -1785,11 +1746,20 @@ void GdbEngine::breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt //else if (child.hasName("ignore")) // data->bpIgnoreCount = child.data(); - QString name = fullName(files); - if (data->bpFileName.isEmpty()) - data->bpFileName = name; - if (data->markerFileName.isEmpty()) - data->markerFileName = name; + QString name; + if (!fullName.isEmpty()) { + name = QFile::decodeName(fullName); + #ifdef Q_OS_WIN + name = QDir::cleanPath(name); + #endif + if (data->markerFileName.isEmpty()) + data->markerFileName = name; + } else { + name = QFile::decodeName(file); + // Use fullName() once we have a mapping which is more complete than gdb's own ... + // No point in assigning markerFileName for now. + } + data->bpFileName = name; } void GdbEngine::sendInsertBreakpoint(int index) @@ -2102,15 +2072,6 @@ void GdbEngine::attemptBreakpointSynchronization() } } } - - for (int index = 0; index != handler->size(); ++index) { - // happens sometimes on Mac. Brush over symptoms - BreakpointData *data = handler->at(index); - if (data->markerFileName.startsWith(__("../"))) { - data->markerFileName = fullName(data->markerFileName); - handler->updateMarkers(); - } - } } @@ -2288,12 +2249,11 @@ void GdbEngine::reloadStack(bool forceGotoLocation) StackFrame GdbEngine::parseStackFrame(const GdbMi &frameMi, int level) { //qDebug() << "HANDLING FRAME:" << frameMi.toString(); - QStringList files; - files.append(QFile::decodeName(frameMi.findChild("fullname").data())); - files.append(QFile::decodeName(frameMi.findChild("file").data())); StackFrame frame; frame.level = level; - frame.file = fullName(files); + // We might want to fall back to "file" once we have a mapping which + // is more complete than gdb's own ... + frame.file = QFile::decodeName(frameMi.findChild("fullname").data()); frame.function = _(frameMi.findChild("func").data()); frame.from = _(frameMi.findChild("from").data()); frame.line = frameMi.findChild("line").data().toInt(); diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index d26db4da69b..7935144ffe2 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -350,8 +350,6 @@ private: ////////// View & Data Stuff ////////// void handleQuerySources(const GdbResponse &response); QString fullName(const QString &fileName); - // get one usable name out of these, try full names first - QString fullName(const QStringList &candidates); // awful hack to keep track of used files QMap m_shortToFullName; From bf09e8c830847d536c03f68182e30afab32e6c7b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Oct 2009 21:50:33 +0200 Subject: [PATCH 66/91] fix spurious command reordering if there are already commands queued for running after temporary break, then *all* commands must queued up or their order will change. --- 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 20a5683e6b6..3f4be15a304 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -696,7 +696,7 @@ void GdbEngine::postCommandHelper(const GdbCommand &cmd) << "LEAVES PENDING AT:" << m_pendingRequests << cmd.command); } - if (cmd.flags & NeedsStop) { + if ((cmd.flags & NeedsStop) || !m_commandsToRunOnTemporaryBreak.isEmpty()) { if (state() == InferiorStopped || state() == InferiorStarting || state() == AdapterStarted) { // Can be safely sent now. From d81150850bbe462eadcf35cb7ef9194a500c4b80 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Oct 2009 21:54:27 +0200 Subject: [PATCH 67/91] fix spurious inferior interruption (attempts ...) when queuing up commands, don't interrupt if we are already waiting for interruption. that will be the case when other commands area already queued. --- src/plugins/debugger/gdb/gdbengine.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 3f4be15a304..643f1379dee 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -703,10 +703,12 @@ void GdbEngine::postCommandHelper(const GdbCommand &cmd) flushCommand(cmd); } else { // Queue the commands that we cannot send at once. - showStatusMessage(tr("Stopping temporarily."), 1000); debugMessage(_("QUEUING COMMAND ") + cmd.command); m_commandsToRunOnTemporaryBreak.append(cmd); - interruptInferior(); // FIXME: race condition between gdb and kill() + if (state() != InferiorStopping) { + showStatusMessage(tr("Stopping temporarily."), 1000); + interruptInferior(); // FIXME: race condition between gdb and kill() + } } } else if (!cmd.command.isEmpty()) { flushCommand(cmd); From c0a46ace611befdb5aa03d53597c115960f28c74 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 22:54:30 +0200 Subject: [PATCH 68/91] improve breakpoint setting first, try harder to have an up-to-date sources list. then, use the mapping whenever applicable and available. --- src/plugins/debugger/gdb/gdbengine.cpp | 88 ++++++++++++++------------ src/plugins/debugger/gdb/gdbengine.h | 6 ++ 2 files changed, 54 insertions(+), 40 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 643f1379dee..1ad7b8624c6 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -257,7 +257,8 @@ void GdbEngine::initializeVariables() m_shortToFullName.clear(); m_varToType.clear(); - m_modulesListOutdated = true; + m_modulesListOutdated = m_sourcesListOutdated = true; + m_sourcesListUpdating = false; m_oldestAcceptableToken = -1; m_outputCodec = QTextCodec::codecForLocale(); m_pendingRequests = 0; @@ -417,14 +418,14 @@ void GdbEngine::handleResponse(const QByteArray &buff) QByteArray id = result.findChild("id").data(); if (!id.isEmpty()) showStatusMessage(tr("Library %1 loaded.").arg(_(id))); - m_modulesListOutdated = true; + m_modulesListOutdated = m_sourcesListOutdated = true; } else if (asyncClass == "library-unloaded") { // Archer has 'id="/usr/lib/libdrm.so.2", // target-name="/usr/lib/libdrm.so.2", // host-name="/usr/lib/libdrm.so.2" QByteArray id = result.findChild("id").data(); showStatusMessage(tr("Library %1 unloaded.").arg(_(id))); - m_modulesListOutdated = true; + m_modulesListOutdated = m_sourcesListOutdated = true; } else if (asyncClass == "thread-group-created") { // Archer has "{id="28902"}" QByteArray id = result.findChild("id").data(); @@ -453,7 +454,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) #if defined(Q_OS_MAC) } else if (asyncClass == "shlibs-updated") { // MAC announces updated libs - m_modulesListOutdated = true; + m_modulesListOutdated = m_sourcesListOutdated = true; } else if (asyncClass == "shlibs-added") { // MAC announces added libs // {shlib-info={num="2", name="libmathCommon.A_debug.dylib", @@ -461,7 +462,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) // state="Y", path="/usr/lib/system/libmathCommon.A_debug.dylib", // description="/usr/lib/system/libmathCommon.A_debug.dylib", // loaded_addr="0x7f000", slide="0x7f000", prefix=""}} - m_modulesListOutdated = true; + m_modulesListOutdated = m_sourcesListOutdated = true; #endif } else { qDebug() << "IGNORED ASYNC OUTPUT" @@ -495,7 +496,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) // Show some messages to give the impression something happens. if (data.startsWith("Reading symbols from ")) { showStatusMessage(tr("Reading %1...").arg(_(data.mid(21))), 1000); - m_modulesListOutdated = true; + m_modulesListOutdated = m_sourcesListOutdated = true; } else if (data.startsWith("[New ") || data.startsWith("[Thread ")) { if (data.endsWith('\n')) data.chop(1); @@ -866,6 +867,7 @@ void GdbEngine::updateAll() void GdbEngine::handleQuerySources(const GdbResponse &response) { + m_sourcesListUpdating = false; if (response.resultClass == GdbResultDone) { QMap oldShortToFull = m_shortToFullName; m_shortToFullName.clear(); @@ -1056,7 +1058,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data) // due to unrelated no-reason stops. const QByteArray &msg = data.findChild("consolestreamoutput").data(); if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) { - m_modulesListOutdated = true; + m_modulesListOutdated = m_sourcesListOutdated = true; if (theDebuggerBoolSetting(SelectedPluginBreakpoints)) { QString dataStr = _(data.toString()); debugMessage(_("SHARED LIBRARY EVENT: ") + dataStr); @@ -1159,7 +1161,9 @@ void GdbEngine::handleStop1(const GdbResponse &response) void GdbEngine::handleStop1(const GdbMi &data) { if (m_modulesListOutdated) - reloadModules(); + reloadModules(); // This is for display only + if (m_sourcesListOutdated) + reloadSourceFiles(); // This needs to be done before fullName() may need it QByteArray reason = data.findChild("reason").data(); if (reason == "breakpoint-hit") { showStatusMessage(tr("Stopped at breakpoint.")); @@ -1168,8 +1172,6 @@ void GdbEngine::handleStop1(const GdbMi &data) m_currentFrame = _(frame.findChild("addr").data() + '%' + frame.findChild("func").data() + '%'); - if (theDebuggerAction(ListSourceFiles)->value().toBool()) - reloadSourceFiles(); postCommand(_("-break-list"), CB(handleBreakList)); QVariant var = QVariant::fromValue(data); postCommand(_("p 2"), CB(handleStop2), var); // dummy @@ -1330,6 +1332,8 @@ QString GdbEngine::fullName(const QString &fileName) { if (fileName.isEmpty()) return QString(); + QTC_ASSERT(!m_sourcesListOutdated, /* */) + QTC_ASSERT(!m_sourcesListUpdating, /* */) QString full = m_shortToFullName.value(fileName, QString()); //debugMessage(_("RESOLVING: ") + fileName + " " + full); if (!full.isEmpty()) @@ -1576,8 +1580,7 @@ void GdbEngine::nextExec() #if 1 postCommand(_("-exec-next"), RunRequest, CB(handleExecContinue)); #else - postCommand(_("tbreak %1:%2").arg(QFileInfo(lastFile).fileName()) - .arg(lastLine + 1)); + postCommand(_("tbreak \"%2\":%1").arg(lastLine + 1).arg(breakLocation(lastFile))); postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue)); #endif } @@ -1601,13 +1604,8 @@ void GdbEngine::runToLineExec(const QString &fileName, int lineNumber) setTokenBarrier(); setState(InferiorRunningRequested); showStatusMessage(tr("Run to line %1 requested...").arg(lineNumber), 5000); - if (m_gdbVersion < 60500) { // We just know that 6.4 on S60 is broken - postCommand(_("tbreak %1:%2").arg(fileName).arg(lineNumber)); - postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue)); - } else { - postCommand(_("-exec-until %1:%2").arg(fileName).arg(lineNumber), - RunRequest, CB(handleExecContinue)); - } + postCommand(_("-exec-until \"%2\":%1").arg(lineNumber).arg(breakLocation(fileName)), + RunRequest, CB(handleExecContinue)); } void GdbEngine::runToFunctionExec(const QString &functionName) @@ -1628,13 +1626,12 @@ void GdbEngine::jumpToLineExec(const QString &fileName, int lineNumber) frame.file = fileName; frame.line = lineNumber; #if 1 - // not available everywhere? - //sendCliCommand(_("tbreak ") + fileName + ':' + QString::number(lineNumber)); - postCommand(_("-break-insert -t ") + fileName + _c(':') + QString::number(lineNumber)); + QString loc = breakLocation(fileName); + postCommand(_("tbreak \"%2\":%1").arg(lineNumber).arg(loc)); setState(InferiorRunningRequested); - postCommand(_("jump ") + fileName + _c(':') + QString::number(lineNumber), RunRequest); + postCommand(_("jump \"%2\":%1").arg(lineNumber).arg(loc), RunRequest); // will produce something like - // &"jump /home/apoenitz/dev/work/test1/test1.cpp:242" + // &"jump \"/home/apoenitz/dev/work/test1/test1.cpp\":242" // ~"Continuing at 0x4058f3." // ~"run1 (argc=1, argv=0x7fffbf1f5538) at test1.cpp:242" // ~"242\t x *= 2;" @@ -1764,21 +1761,25 @@ void GdbEngine::breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt data->bpFileName = name; } +QString GdbEngine::breakLocation(const QString &file) const +{ + QTC_ASSERT(!m_sourcesListOutdated, /* */) + QTC_ASSERT(!m_sourcesListUpdating, /* */) + QString where = m_fullToShortName.value(file); + if (where.isEmpty()) + return QFileInfo(file).fileName(); + return where; +} + void GdbEngine::sendInsertBreakpoint(int index) { const BreakpointData *data = manager()->breakHandler()->at(index); QString where; if (data->funcName.isEmpty()) { - if (data->useFullPath) { - where = data->fileName; - } else { - QFileInfo fi(data->fileName); - where = fi.fileName(); - } + where = data->useFullPath ? data->fileName : breakLocation(data->fileName); // The argument is simply a C-quoted version of the argument to the // non-MI "break" command, including the "original" quoting it wants. - where = _("\"\\\"%1\\\":%2\"") - .arg(GdbMi::escapeCString(where)).arg(data->lineNumber); + where = _("\"\\\"%2\\\":%1\"").arg(data->lineNumber).arg(GdbMi::escapeCString(where)); } else { where = data->funcName; } @@ -1917,15 +1918,8 @@ void GdbEngine::handleBreakInsert(const GdbResponse &response) handler->updateMarkers(); } else { if (m_gdbVersion < 60800 && !m_isMacGdb) { - // Note that it is perfectly correct that the file name is put - // in quotes but not escaped. GDB simply is like that. - const BreakpointData *data = handler->at(index); - QFileInfo fi(data->fileName); - QString where = _c('"') + fi.fileName() + _("\":") - + data->lineNumber; - postCommand(_("break ") + where, CB(handleBreakInsert1), index); + // This gdb version doesn't "do" pending breakpoints. } else { - // The breakpoint would be pending even if the path simply cannot be found. QTC_ASSERT(false, /**/); } } @@ -2008,6 +2002,11 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response) handler->updateMarkers(); } +void GdbEngine::attemptBreakpointSynchronization2(const GdbResponse &) +{ + attemptBreakpointSynchronization(); +} + void GdbEngine::attemptBreakpointSynchronization() { switch (state()) { @@ -2022,6 +2021,13 @@ void GdbEngine::attemptBreakpointSynchronization() return; } + // For best results, we rely on an up-to-date fullname mapping. + if (m_sourcesListOutdated) { + reloadSourceFiles(); + postCommand(_("p 5"), CB(attemptBreakpointSynchronization2)); + return; + } + BreakHandler *handler = manager()->breakHandler(); foreach (BreakpointData *data, handler->takeDisabledBreakpoints()) { @@ -2191,6 +2197,8 @@ void GdbEngine::handleModulesList(const GdbResponse &response) void GdbEngine::reloadSourceFiles() { + m_sourcesListUpdating = true; + m_sourcesListOutdated = false; postCommand(_("-file-list-exec-source-files"), NeedsStop, CB(handleQuerySources)); } diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 7935144ffe2..82e07981c2e 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -267,7 +267,9 @@ private: ////////// Gdb Output, State & Capability Handling ////////// private: ////////// Inferior Management ////////// + // This should be always the last call in a function. Q_SLOT virtual void attemptBreakpointSynchronization(); + void attemptBreakpointSynchronization2(const GdbResponse &); virtual void stepExec(); virtual void stepOutExec(); @@ -311,6 +313,7 @@ private: ////////// View & Data Stuff ////////// void extractDataFromInfoBreak(const QString &output, BreakpointData *data); void breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt); void sendInsertBreakpoint(int index); + QString breakLocation(const QString &file) const; // // Modules specific stuff @@ -355,6 +358,9 @@ private: ////////// View & Data Stuff ////////// QMap m_shortToFullName; QMap m_fullToShortName; + bool m_sourcesListOutdated; + bool m_sourcesListUpdating; + // // Stack specific stuff // From a2a444d683ea730c72cce64cb474fa04d6957472 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Oct 2009 22:17:15 +0200 Subject: [PATCH 69/91] do the auto-continue-at-_start hack earlier --- src/plugins/debugger/gdb/gdbengine.cpp | 29 +++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 1ad7b8624c6..7a4231b63fd 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1052,6 +1052,21 @@ void GdbEngine::handleStopResponse(const GdbMi &data) } setState(InferiorStopped); +#ifdef Q_OS_LINUX + // For some reason, attaching to a stopped process causes *two* stops + // when trying to continue (kernel 2.6.24-23-ubuntu). + // Interestingly enough, on MacOSX no signal is delivered at all. + if (reason == "signal-received" + && data.findChild("signal-name").data() == "SIGSTOP") { + GdbMi frameData = data.findChild("frame"); + if (frameData.findChild("func").data() == "_start" + && frameData.findChild("from").data() == "/lib/ld-linux.so.2") { + continueInferiorInternal(); + return; + } + } +#endif + #if 0 // The related code (handleAqcuiredInferior()) is disabled as well. // When re-enabling, try something to avoid spurious source list updates @@ -1176,20 +1191,6 @@ void GdbEngine::handleStop1(const GdbMi &data) QVariant var = QVariant::fromValue(data); postCommand(_("p 2"), CB(handleStop2), var); // dummy } else { -#ifdef Q_OS_LINUX - // For some reason, attaching to a stopped process causes *two* stops - // when trying to continue (kernel 2.6.24-23-ubuntu). - // Interestingly enough, on MacOSX no signal is delivered at all. - if (reason == "signal-received" - && data.findChild("signal-name").data() == "SIGSTOP") { - GdbMi frameData = data.findChild("frame"); - if (frameData.findChild("func").data() == "_start" - && frameData.findChild("from").data() == "/lib/ld-linux.so.2") { - continueInferiorInternal(); - return; - } - } -#endif if (reason == "signal-received" && theDebuggerBoolSetting(UseMessageBoxForSignals)) { QByteArray name = data.findChild("signal-name").data(); From c07667a7439e7da7e4270da1b484d3d1ed18b12b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Oct 2009 22:52:16 +0200 Subject: [PATCH 70/91] remove unreachable "stopped for unknown reason" fallback seems to have been an artifact from an early version. it was unreachable (gdb going wild notwithstanding), and would do Strange Stuff (TM) if it ever were reached. --- src/plugins/debugger/gdb/gdbengine.cpp | 64 ++++++-------------------- 1 file changed, 13 insertions(+), 51 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 7a4231b63fd..bbf314e03ee 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -945,21 +945,6 @@ static bool isExitedReason(const QByteArray &reason) || reason == "exited"; // inferior exited } -static bool isStoppedReason(const QByteArray &reason) -{ - return reason == "function-finished" // -exec-finish - || reason == "signal-received" // handled as "isExitedReason" - || reason == "breakpoint-hit" // -exec-continue - || reason == "end-stepping-range" // -exec-next, -exec-step - || reason == "location-reached" // -exec-until - || reason == "access-watchpoint-trigger" - || reason == "read-watchpoint-trigger" - #ifdef Q_OS_MAC - || reason.isEmpty() - #endif - ; -} - #if 0 void GdbEngine::handleAqcuiredInferior() { @@ -1129,43 +1114,20 @@ void GdbEngine::handleStopResponse(const GdbMi &data) } } - if (isStoppedReason(reason) || reason.isEmpty()) { - if (initHelpers && m_debuggingHelperState != DebuggingHelperUninitialized) - initHelpers = false; - // Don't load helpers on stops triggered by signals unless it's - // an intentional trap. - if (initHelpers && reason == "signal-received" - && data.findChild("signal-name").data() != "SIGTRAP") - initHelpers = false; - - if (initHelpers) { - tryLoadDebuggingHelpers(); - QVariant var = QVariant::fromValue(data); - postCommand(_("p 4"), CB(handleStop1), var); // dummy - } else { - handleStop1(data); - } - return; + if (initHelpers && m_debuggingHelperState != DebuggingHelperUninitialized) + initHelpers = false; + // Don't load helpers on stops triggered by signals unless it's + // an intentional trap. + if (initHelpers && reason == "signal-received" + && data.findChild("signal-name").data() != "SIGTRAP") + initHelpers = false; + if (initHelpers) { + tryLoadDebuggingHelpers(); + QVariant var = QVariant::fromValue(data); + postCommand(_("p 4"), CB(handleStop1), var); // dummy + } else { + handleStop1(data); } - - debugMessage(_("STOPPED FOR UNKNOWN REASON: " + data.toString())); - // Ignore it. Will be handled with full response later in the - // JumpToLine or RunToFunction handlers -#if 1 - // FIXME: remove this special case as soon as there's a real - // reason given when the temporary breakpoint is hit. - // right now we get: - // 14*stopped,thread-id="1",frame={addr="0x0000000000403ce4", - // func="foo",args=[{name="str",value="@0x7fff0f450460"}], - // file="main.cpp",fullname="/tmp/g/main.cpp",line="37"} - // - // MAC yields sometimes: - // >3661*stopped,time={wallclock="0.00658",user="0.00142", - // system="0.00136",start="1218810678.805432",end="1218810678.812011"} - showStatusMessage(tr("Run to Function finished. Stopped.")); - StackFrame f = parseStackFrame(data.findChild("frame"), 0); - gotoLocation(f, true); -#endif } void GdbEngine::handleStop1(const GdbResponse &response) From f1d5b3c70bef67e3a49595faedfc29704135a298 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Oct 2009 22:59:30 +0200 Subject: [PATCH 71/91] move setting of m_currentFrame to a somewhat useful place specifically, we need it iff the user gets to see the stopped inferior --- src/plugins/debugger/gdb/gdbengine.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index bbf314e03ee..80744585863 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1090,9 +1090,6 @@ void GdbEngine::handleStopResponse(const GdbMi &data) if (reason == "end-stepping-range" || reason == "function-finished") { GdbMi frame = data.findChild("frame"); //debugMessage(frame.toString()); - m_currentFrame = _(frame.findChild("addr").data() + '%' + - frame.findChild("func").data() + '%'); - QString funcName = _(frame.findChild("func").data()); QString fileName = QString::fromLocal8Bit(frame.findChild("file").data()); if (isLeavableFunction(funcName, fileName)) { @@ -1144,11 +1141,7 @@ void GdbEngine::handleStop1(const GdbMi &data) QByteArray reason = data.findChild("reason").data(); if (reason == "breakpoint-hit") { showStatusMessage(tr("Stopped at breakpoint.")); - GdbMi frame = data.findChild("frame"); //debugMessage(_("HIT BREAKPOINT: " + frame.toString())); - m_currentFrame = _(frame.findChild("addr").data() + '%' + - frame.findChild("func").data() + '%'); - postCommand(_("-break-list"), CB(handleBreakList)); QVariant var = QVariant::fromValue(data); postCommand(_("p 2"), CB(handleStop2), var); // dummy @@ -1188,6 +1181,9 @@ void GdbEngine::handleStop2(const GdbMi &data) { const GdbMi gdbmiFrame = data.findChild("frame"); + m_currentFrame = _(gdbmiFrame.findChild("addr").data() + '%' + + gdbmiFrame.findChild("func").data() + '%'); + // Quick shot: Jump to stack frame #0. StackFrame frame; if (gdbmiFrame.isValid()) { From dc8318853a4059a4e841e976b137e1d6b963cb4f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 26 Oct 2009 09:12:00 +0100 Subject: [PATCH 72/91] S60: Fix the run configuration status label --- .../qt-s60/s60devicerunconfigurationwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp index 71369923abd..0b1554b1bae 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp @@ -107,8 +107,8 @@ S60DeviceRunConfigurationWidget::S60DeviceRunConfigurationWidget( // Device Info with button. Widgets are enabled in above call to updateSerialDevices() QHBoxLayout *infoHBoxLayout = new QHBoxLayout; m_deviceInfoLabel->setWordWrap(true); + m_deviceInfoLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); infoHBoxLayout->addWidget(m_deviceInfoLabel); - infoHBoxLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); infoHBoxLayout->addWidget(m_deviceInfoButton); m_deviceInfoButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MessageBoxInformation)); m_deviceInfoButton->setToolTip(tr("Queries the device for information")); From 3e953b03238ffa15de3c04dec22cb64e1253145b Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Mon, 26 Oct 2009 10:33:32 +0100 Subject: [PATCH 73/91] Check for null scope when hovering. Fixes a segfault when hovering over QtCleanUpFunction in qcoreapplication.h. Reviewed-by: Roberto Raggi --- src/plugins/cppeditor/cpphoverhandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp index 508eec2854c..ff671da25af 100644 --- a/src/plugins/cppeditor/cpphoverhandler.cpp +++ b/src/plugins/cppeditor/cpphoverhandler.cpp @@ -337,7 +337,8 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in firstType = resolve(firstType, typeOfExpression.lookupContext(), &resolvedSymbol, &resolvedName); - if (resolvedSymbol && resolvedSymbol->scope()->isClassScope()) { + if (resolvedSymbol && resolvedSymbol->scope() + && resolvedSymbol->scope()->isClassScope()) { Class *enclosingClass = resolvedSymbol->scope()->owner()->asClass(); if (Identifier *id = enclosingClass->identifier()) { if (id->isEqualTo(resolvedSymbol->identifier())) From f4047ac8bf3d9d6f8fab4110412532e724fe9422 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Mon, 26 Oct 2009 10:19:44 +0100 Subject: [PATCH 74/91] Fixed use of uninitialized/unallocated object. --- src/shared/cplusplus/Parser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 4fffd4818dd..835b2c11c89 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -4595,6 +4595,7 @@ bool Parser::parseObjCMethodDefinitionList(DeclarationListAST *&node) last->next = new (_pool) ObjCSynthesizedPropertyListAST; last = last->next; + last->synthesized_property = new (_pool) ObjCSynthesizedPropertyAST; match(T_IDENTIFIER, &(last->synthesized_property->property_identifier)); if (LA() == T_EQUAL) { From dc9e019a1deaecef56b0757daa9beb39c8001beb Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 26 Oct 2009 11:24:32 +0100 Subject: [PATCH 75/91] Test the enclosing scope of pointer-to-function symbols. --- .../auto/cplusplus/semantic/tst_semantic.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp index 3df6573ccda..bf113873fe4 100644 --- a/tests/auto/cplusplus/semantic/tst_semantic.cpp +++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp @@ -100,6 +100,7 @@ private slots: void typedef_3(); void const_1(); void const_2(); + void pointer_to_function_1(); }; void tst_Semantic::function_declaration_1() @@ -367,5 +368,24 @@ void tst_Semantic::const_2() QVERIFY(arg->type()->asPointerType()->elementType()->isIntegerType()); } +void tst_Semantic::pointer_to_function_1() +{ + QSharedPointer doc = document("void (*QtSomething)();"); + QCOMPARE(doc->errorCount, 0U); + QCOMPARE(doc->globals->symbolCount(), 1U); + + Declaration *decl = doc->globals->symbolAt(0)->asDeclaration(); + QVERIFY(decl); + + PointerType *ptrTy = decl->type()->asPointerType(); + QVERIFY(ptrTy); + + Function *funTy = ptrTy->elementType()->asFunctionType(); + QVERIFY(funTy); + + QVERIFY(funTy->scope()); + QCOMPARE(funTy->scope(), decl->scope()); +} + QTEST_APPLESS_MAIN(tst_Semantic) #include "tst_semantic.moc" From 2bd9c40dd9b2d9e755ae245832d9ed41aceb18cd Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 26 Oct 2009 11:53:28 +0100 Subject: [PATCH 76/91] Updated the QML front-end to revision 44f3548fde7cf6a87bd3cc8bb1cc0e63cfc5ca4c of qt/kinetic-declarativeui --- src/plugins/qmleditor/parser/qmljs.g | 134 ++++++++++++------ src/plugins/qmleditor/parser/qmljsast.cpp | 40 ++++-- src/plugins/qmleditor/parser/qmljsast_p.h | 40 ++++-- src/plugins/qmleditor/parser/qmljsastfwd_p.h | 40 ++++-- .../qmleditor/parser/qmljsastvisitor.cpp | 46 +++--- .../qmleditor/parser/qmljsastvisitor_p.h | 42 ++++-- .../qmleditor/parser/qmljsengine_p.cpp | 42 ++++-- src/plugins/qmleditor/parser/qmljsengine_p.h | 42 ++++-- src/plugins/qmleditor/parser/qmljsgrammar.cpp | 32 ++--- src/plugins/qmleditor/parser/qmljsgrammar_p.h | 32 ++--- src/plugins/qmleditor/parser/qmljslexer.cpp | 73 ++++++---- src/plugins/qmleditor/parser/qmljslexer_p.h | 42 ++++-- .../qmleditor/parser/qmljsmemorypool_p.h | 40 ++++-- .../qmleditor/parser/qmljsnodepool_p.h | 48 +++++-- src/plugins/qmleditor/parser/qmljsparser.cpp | 51 ++++--- src/plugins/qmleditor/parser/qmljsparser_p.h | 40 ++++-- 16 files changed, 497 insertions(+), 287 deletions(-) diff --git a/src/plugins/qmleditor/parser/qmljs.g b/src/plugins/qmleditor/parser/qmljs.g index 8531ed51079..eb9a8abcfdc 100644 --- a/src/plugins/qmleditor/parser/qmljs.g +++ b/src/plugins/qmleditor/parser/qmljs.g @@ -1,20 +1,18 @@ ---------------------------------------------------------------------------- -- --- This file is part of Qt Creator +-- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +-- Contact: Qt Software Information (qt-info@nokia.com) -- --- Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +-- This file is part of the QtDeclarative module of the Qt Toolkit. -- --- Contact: Nokia Corporation (qt-info@nokia.com) --- --- Commercial Usage --- --- Licensees holding valid Qt Commercial licenses may use this file in --- accordance with the Qt Commercial License Agreement provided with the --- Software or, alternatively, in accordance with the terms contained in --- a written agreement between you and Nokia. +-- $QT_BEGIN_LICENSE:LGPL$ +-- No Commercial Usage +-- This file contains pre-release code and may not be distributed. +-- You may use this file in accordance with the terms and conditions +-- contained in the either Technology Preview License Agreement or the +-- Beta Release License Agreement. -- -- GNU Lesser General Public License Usage --- -- Alternatively, this file may be used under the terms of the GNU Lesser -- General Public License version 2.1 as published by the Free Software -- Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,8 +20,25 @@ -- ensure the GNU Lesser General Public License version 2.1 requirements -- will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -- +-- In addition, as a special exception, Nokia gives you certain +-- additional rights. These rights are described in the Nokia Qt LGPL +-- Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +-- package. +-- +-- GNU General Public License Usage +-- Alternatively, this file may be used under the terms of the GNU +-- General Public License version 3.0 as published by the Free Software +-- Foundation and appearing in the file LICENSE.GPL included in the +-- packaging of this file. Please review the following information to +-- ensure the GNU General Public License version 3.0 requirements will be +-- met: http://www.gnu.org/copyleft/gpl.html. +-- -- If you are unsure which license is appropriate for your use, please --- contact the sales department at http://qt.nokia.com/contact. +-- contact the sales department at qt-sales@nokia.com. +-- $QT_END_LICENSE$ +-- +-- This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +-- WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- ---------------------------------------------------------------------------- @@ -85,23 +100,21 @@ %start TopLevel /. -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtScript module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -109,12 +122,27 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include +#include #include @@ -126,23 +154,21 @@ ./ /: -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtScript module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -150,10 +176,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ // // W A R N I N G @@ -2920,7 +2960,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; yylloc.startColumn += yylloc.length; yylloc.length = 0; - //const QString msg = QString::fromUtf8("Missing `;'"); + //const QString msg = qApp->translate("QmlParser", "Missing `;'"); //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); first_token = &token_buffer[0]; @@ -2945,7 +2985,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; token_buffer[1].loc = yylloc = location(lexer); if (t_action(errorState, yytoken)) { - const QString msg = QString::fromUtf8("Unexpected token `%1'").arg(QLatin1String(spell[token_buffer[0].token])); + const QString msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token_buffer[0].token])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); action = errorState; @@ -2973,7 +3013,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { int a = t_action(errorState, *tk); if (a > 0 && t_action(a, yytoken)) { - const QString msg = QString::fromUtf8("Expected token `%1'").arg(QLatin1String(spell[*tk])); + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); yytoken = *tk; @@ -2996,7 +3036,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; int a = t_action(errorState, tk); if (a > 0 && t_action(a, yytoken)) { - const QString msg = QString::fromUtf8("Expected token `%1'").arg(QLatin1String(spell[tk])); + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); yytoken = tk; @@ -3009,7 +3049,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; } } - const QString msg = QString::fromUtf8("Syntax error"); + const QString msg = qApp->translate("QmlParser", "Syntax error"); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); } diff --git a/src/plugins/qmleditor/parser/qmljsast.cpp b/src/plugins/qmleditor/parser/qmljsast.cpp index ec199e80ae7..4c45bc89d9e 100644 --- a/src/plugins/qmleditor/parser/qmljsast.cpp +++ b/src/plugins/qmleditor/parser/qmljsast.cpp @@ -1,20 +1,18 @@ /**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtScript module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include "qmljsast_p.h" #include "qmljsastvisitor_p.h" diff --git a/src/plugins/qmleditor/parser/qmljsast_p.h b/src/plugins/qmleditor/parser/qmljsast_p.h index 94a26096ee2..ef8a66bd949 100644 --- a/src/plugins/qmleditor/parser/qmljsast_p.h +++ b/src/plugins/qmleditor/parser/qmljsast_p.h @@ -1,20 +1,18 @@ /**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #ifndef QMLJSAST_P_H #define QMLJSAST_P_H diff --git a/src/plugins/qmleditor/parser/qmljsastfwd_p.h b/src/plugins/qmleditor/parser/qmljsastfwd_p.h index dd164e9e3c8..fcb97ad870a 100644 --- a/src/plugins/qmleditor/parser/qmljsastfwd_p.h +++ b/src/plugins/qmleditor/parser/qmljsastfwd_p.h @@ -1,20 +1,18 @@ /**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtScript module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #ifndef QMLJSAST_FWD_P_H #define QMLJSAST_FWD_P_H diff --git a/src/plugins/qmleditor/parser/qmljsastvisitor.cpp b/src/plugins/qmleditor/parser/qmljsastvisitor.cpp index 6a0d55a4f16..642bcee26b9 100644 --- a/src/plugins/qmleditor/parser/qmljsastvisitor.cpp +++ b/src/plugins/qmleditor/parser/qmljsastvisitor.cpp @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtScript module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,14 +20,28 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include "qmljsastvisitor_p.h" -QT_QML_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE namespace QmlJS { namespace AST { @@ -43,4 +55,4 @@ Visitor::~Visitor() } } // namespace QmlJS::AST -QT_QML_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/plugins/qmleditor/parser/qmljsastvisitor_p.h b/src/plugins/qmleditor/parser/qmljsastvisitor_p.h index 09714ee0a0a..eea492a0572 100644 --- a/src/plugins/qmleditor/parser/qmljsastvisitor_p.h +++ b/src/plugins/qmleditor/parser/qmljsastvisitor_p.h @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtScript module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #ifndef QMLJSASTVISITOR_P_H #define QMLJSASTVISITOR_P_H diff --git a/src/plugins/qmleditor/parser/qmljsengine_p.cpp b/src/plugins/qmleditor/parser/qmljsengine_p.cpp index 6e7a45a5065..32068c03205 100644 --- a/src/plugins/qmleditor/parser/qmljsengine_p.cpp +++ b/src/plugins/qmleditor/parser/qmljsengine_p.cpp @@ -1,20 +1,18 @@ /**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include "qmljsglobal_p.h" #include "qmljsengine_p.h" @@ -152,7 +164,7 @@ double integerFromString(const char *buf, int size, int radix) double integerFromString(const QString &str, int radix) { - QByteArray ba = str.trimmed().toUtf8(); + QByteArray ba = str.trimmed().toLatin1(); return integerFromString(ba.constData(), ba.size(), radix); } diff --git a/src/plugins/qmleditor/parser/qmljsengine_p.h b/src/plugins/qmleditor/parser/qmljsengine_p.h index 98e71c88790..8627a990243 100644 --- a/src/plugins/qmleditor/parser/qmljsengine_p.h +++ b/src/plugins/qmleditor/parser/qmljsengine_p.h @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #ifndef QMLJSENGINE_P_H #define QMLJSENGINE_P_H diff --git a/src/plugins/qmleditor/parser/qmljsgrammar.cpp b/src/plugins/qmleditor/parser/qmljsgrammar.cpp index 67f14032fa7..da3ce2a0770 100644 --- a/src/plugins/qmleditor/parser/qmljsgrammar.cpp +++ b/src/plugins/qmleditor/parser/qmljsgrammar.cpp @@ -2,8 +2,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: Qt Software Information (qt-info@nokia.com) ** ** This file is part of the QtCore module of the Qt Toolkit. ** @@ -11,8 +10,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -22,20 +21,21 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. ** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/qmleditor/parser/qmljsgrammar_p.h b/src/plugins/qmleditor/parser/qmljsgrammar_p.h index 7de77c03a09..b297f81cff5 100644 --- a/src/plugins/qmleditor/parser/qmljsgrammar_p.h +++ b/src/plugins/qmleditor/parser/qmljsgrammar_p.h @@ -2,8 +2,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: Qt Software Information (qt-info@nokia.com) ** ** This file is part of the QtCore module of the Qt Toolkit. ** @@ -11,8 +10,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -22,20 +21,21 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. ** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/qmleditor/parser/qmljslexer.cpp b/src/plugins/qmleditor/parser/qmljslexer.cpp index a52ea7c0896..2c03c214970 100644 --- a/src/plugins/qmleditor/parser/qmljslexer.cpp +++ b/src/plugins/qmleditor/parser/qmljslexer.cpp @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #ifdef HAVE_CONFIG_H #include "config.h" @@ -36,6 +48,8 @@ #include "qmljslexer_p.h" #include "qmljsgrammar_p.h" +#include + #include #include #include @@ -536,7 +550,7 @@ int Lexer::lex() else { setDone(Bad); err = IllegalCharacter; - errmsg = QLatin1String("Illegal character"); + errmsg = qApp->translate("QmlParser", "Illegal character"); } } break; @@ -550,7 +564,7 @@ int Lexer::lex() } else if (current == 0 || isLineTerminator()) { setDone(Bad); err = UnclosedStringLiteral; - errmsg = QLatin1String("Unclosed string at end of line"); + errmsg = qApp->translate("QmlParser", "Unclosed string at end of line"); } else if (current == '\\') { state = InEscapeSequence; } else { @@ -576,7 +590,7 @@ int Lexer::lex() } else { setDone(Bad); err = IllegalEscapeSequence; - errmsg = QLatin1String("Illegal escape squence"); + errmsg = qApp->translate("QmlParser", "Illegal escape squence"); } } else if (current == 'x') state = InHexEscape; @@ -622,7 +636,7 @@ int Lexer::lex() } else { setDone(Bad); err = IllegalUnicodeEscapeSequence; - errmsg = QLatin1String("Illegal unicode escape sequence"); + errmsg = qApp->translate("QmlParser", "Illegal unicode escape sequence"); } break; case InSingleLineComment: @@ -648,7 +662,7 @@ int Lexer::lex() if (current == 0) { setDone(Bad); err = UnclosedComment; - errmsg = QLatin1String("Unclosed comment at end of file"); + errmsg = qApp->translate("QmlParser", "Unclosed comment at end of file"); driver->addComment(startpos, tokenLength(), startlineno, startcolumn); } else if (isLineTerminator()) { shiftWindowsLineBreak(); @@ -735,7 +749,7 @@ int Lexer::lex() } else { setDone(Bad); err = IllegalExponentIndicator; - errmsg = QLatin1String("Illegal syntax for exponential number"); + errmsg = qApp->translate("QmlParser", "Illegal syntax for exponential number"); } break; case InExponent: @@ -761,7 +775,7 @@ int Lexer::lex() && isIdentLetter(current)) { state = Bad; err = IllegalIdentifier; - errmsg = QLatin1String("Identifier cannot start with numeric literal"); + errmsg = qApp->translate("QmlParser", "Identifier cannot start with numeric literal"); } // terminate string @@ -855,11 +869,16 @@ bool Lexer::isLineTerminator() const bool Lexer::isIdentLetter(ushort c) { - /* TODO: allow other legitimate unicode chars */ - return ((c >= 'a' && c <= 'z') + // ASCII-biased, since all reserved words are ASCII, aand hence the + // bulk of content to be parsed. + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '$' - || c == '_'); + || c == '_') + return true; + if (c < 128) + return false; + return QChar(c).isLetterOrNumber(); } bool Lexer::isDecimalDigit(ushort c) @@ -1087,7 +1106,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix) while (1) { if (isLineTerminator() || current == 0) { - errmsg = QLatin1String("Unterminated regular expression literal"); + errmsg = qApp->translate("QmlParser", "Unterminated regular expression literal"); return false; } else if (current != '/' || lastWasEscape == true) @@ -1111,7 +1130,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix) while (isIdentLetter(current)) { int flag = Ecma::RegExp::flagFromChar(current); if (flag == 0) { - errmsg = QString::fromLatin1("Invalid regular expression flag '%0'") + errmsg = qApp->translate("QmlParser", "Invalid regular expression flag '%0'") .arg(QChar(current)); return false; } diff --git a/src/plugins/qmleditor/parser/qmljslexer_p.h b/src/plugins/qmleditor/parser/qmljslexer_p.h index 1be466c3e62..50f7c4b279d 100644 --- a/src/plugins/qmleditor/parser/qmljslexer_p.h +++ b/src/plugins/qmleditor/parser/qmljslexer_p.h @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtScript module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #ifndef QMLJSLEXER_P_H #define QMLJSLEXER_P_H diff --git a/src/plugins/qmleditor/parser/qmljsmemorypool_p.h b/src/plugins/qmleditor/parser/qmljsmemorypool_p.h index 4b79f174fb0..70e77371127 100644 --- a/src/plugins/qmleditor/parser/qmljsmemorypool_p.h +++ b/src/plugins/qmleditor/parser/qmljsmemorypool_p.h @@ -1,20 +1,18 @@ /**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #ifndef QMLJSMEMORYPOOL_P_H #define QMLJSMEMORYPOOL_P_H diff --git a/src/plugins/qmleditor/parser/qmljsnodepool_p.h b/src/plugins/qmleditor/parser/qmljsnodepool_p.h index 30669b04d1b..dfe3bac4652 100644 --- a/src/plugins/qmleditor/parser/qmljsnodepool_p.h +++ b/src/plugins/qmleditor/parser/qmljsnodepool_p.h @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #ifndef QMLJSNODEPOOL_P_H #define QMLJSNODEPOOL_P_H @@ -104,11 +116,17 @@ public: inline QString fileName() const { return m_fileName; } inline Engine *engine() const { return m_engine; } +#ifndef J_SCRIPT_NO_EVENT_NOTIFY + inline qint64 id() const { return m_id; } +#endif private: QHash m_codeCache; QString m_fileName; Engine *m_engine; +#ifndef J_SCRIPT_NO_EVENT_NOTIFY + qint64 m_id; +#endif private: Q_DISABLE_COPY(NodePool) diff --git a/src/plugins/qmleditor/parser/qmljsparser.cpp b/src/plugins/qmleditor/parser/qmljsparser.cpp index f5fab00f4cc..402aaeb3959 100644 --- a/src/plugins/qmleditor/parser/qmljsparser.cpp +++ b/src/plugins/qmleditor/parser/qmljsparser.cpp @@ -2,21 +2,19 @@ /**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtScript module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -24,12 +22,27 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include +#include #include @@ -1711,7 +1724,7 @@ case 337: { yylloc.startColumn += yylloc.length; yylloc.length = 0; - //const QString msg = QString::fromUtf8("Missing `;'"); + //const QString msg = qApp->translate("QmlParser", "Missing `;'"); //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); first_token = &token_buffer[0]; @@ -1736,7 +1749,7 @@ case 337: { token_buffer[1].loc = yylloc = location(lexer); if (t_action(errorState, yytoken)) { - const QString msg = QString::fromUtf8("Unexpected token `%1'").arg(QLatin1String(spell[token_buffer[0].token])); + const QString msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token_buffer[0].token])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); action = errorState; @@ -1764,7 +1777,7 @@ case 337: { for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { int a = t_action(errorState, *tk); if (a > 0 && t_action(a, yytoken)) { - const QString msg = QString::fromUtf8("Expected token `%1'").arg(QLatin1String(spell[*tk])); + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); yytoken = *tk; @@ -1787,7 +1800,7 @@ case 337: { int a = t_action(errorState, tk); if (a > 0 && t_action(a, yytoken)) { - const QString msg = QString::fromUtf8("Expected token `%1'").arg(QLatin1String(spell[tk])); + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); yytoken = tk; @@ -1800,7 +1813,7 @@ case 337: { } } - const QString msg = QString::fromUtf8("Syntax error"); + const QString msg = qApp->translate("QmlParser", "Syntax error"); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); } diff --git a/src/plugins/qmleditor/parser/qmljsparser_p.h b/src/plugins/qmleditor/parser/qmljsparser_p.h index 7ee69a57d56..b35bec32b38 100644 --- a/src/plugins/qmleditor/parser/qmljsparser_p.h +++ b/src/plugins/qmleditor/parser/qmljsparser_p.h @@ -2,21 +2,19 @@ /**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtScript module of the Qt Toolkit. ** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -24,10 +22,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -**************************************************************************/ +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ // // W A R N I N G From 93759263d06388a9a183885e81e973e92cbc1964 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 26 Oct 2009 11:55:02 +0100 Subject: [PATCH 77/91] S60/Debugger: Add Bluetooth starter to Debugger - Remove old rfcomm process handler from TrkGdbAdapter, use Bluetooth starter instead - Synchronous connection, remove waitForTrkConnect() - Move gdb start into Trk version answer, pass on settings id hint - Prevent exit crash triggered by signal gdbProcessFinished() - Set DebuggerNotReady correctly on AdapterStartFailed when no gdb is started yet --- src/plugins/debugger/gdb/gdbengine.cpp | 27 ++- src/plugins/debugger/gdb/gdbengine.h | 4 +- src/plugins/debugger/gdb/trkgdbadapter.cpp | 185 ++++++--------------- src/plugins/debugger/gdb/trkgdbadapter.h | 19 +-- 4 files changed, 79 insertions(+), 156 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 80744585863..8980ccec838 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -225,7 +225,9 @@ QMainWindow *GdbEngine::mainWindow() const GdbEngine::~GdbEngine() { // prevent sending error messages afterwards + disconnect(&m_gdbProc); delete m_gdbAdapter; + m_gdbAdapter = 0; } void GdbEngine::connectAdapter() @@ -1325,7 +1327,11 @@ void GdbEngine::shutdown() // fall-through case AdapterStartFailed: // Adapter "did something", but it did not help // FIXME set some timeout? - postCommand(_("-gdb-exit"), GdbEngine::ExitRequest, CB(handleGdbExit)); + if (m_gdbProc.state() == QProcess::Running) { + postCommand(_("-gdb-exit"), GdbEngine::ExitRequest, CB(handleGdbExit)); + } else { + setState(DebuggerNotReady); + } break; case InferiorRunningRequested: case InferiorRunning: @@ -4099,7 +4105,7 @@ void GdbEngine::gotoLocation(const StackFrame &frame, bool setMarker) // Starting up & shutting down // -bool GdbEngine::startGdb(const QStringList &args, const QString &gdb) +bool GdbEngine::startGdb(const QStringList &args, const QString &gdb, const QString &settingsIdHint) { debugMessage(_("STARTING GDB ") + gdb); @@ -4115,7 +4121,8 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb) m_gdbProc.start(location, gdbArgs); if (!m_gdbProc.waitForStarted()) { - handleAdapterStartFailed(m_gdbProc.errorString()); + const QString msg = tr("Unable to start gdb '%1': %2").arg(gdb, m_gdbProc.errorString()); + handleAdapterStartFailed(msg, settingsIdHint); return false; } @@ -4166,7 +4173,6 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb) // /build/buildd/gdb-6.8/gdb/valops.c:2069: internal-error: postCommand(_("set overload-resolution off")); //postCommand(_("set demangle-style none")); - // From the docs: // Stop means reenter debugger if this signal happens (implies print). // Print means print a message if this signal happens. @@ -4238,6 +4244,8 @@ void GdbEngine::handleGdbError(QProcess::ProcessError error) void GdbEngine::handleGdbFinished(int code, QProcess::ExitStatus type) { debugMessage(_("GDB PROCESS FINISHED, status %1, code %2").arg(type).arg(code)); + if (!m_gdbAdapter) + return; if (state() == EngineShuttingDown) { m_gdbAdapter->shutdown(); } else if (state() != AdapterStartFailed) { @@ -4255,9 +4263,14 @@ void GdbEngine::handleAdapterStartFailed(const QString &msg, const QString &sett { setState(AdapterStartFailed); debugMessage(_("ADAPTER START FAILED")); - Core::ICore::instance()->showWarningWithOptions( - tr("Adapter start failed"), msg, QString(), - _(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY), settingsIdHint); + const QString title = tr("Adapter start failed"); + if (settingsIdHint.isEmpty()) { + Core::ICore::instance()->showWarningWithOptions(title, msg); + } else { + Core::ICore::instance()->showWarningWithOptions(title, msg, QString(), + _(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY), + settingsIdHint); + } shutdown(); } diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 82e07981c2e..786ac7696a6 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -126,7 +126,9 @@ private: ////////// Gdb Process Management ////////// AbstractGdbAdapter *createAdapter(const DebuggerStartParametersPtr &dp); void connectAdapter(); - bool startGdb(const QStringList &args = QStringList(), const QString &gdb = QString()); + bool startGdb(const QStringList &args = QStringList(), + const QString &gdb = QString(), + const QString &settingsIdHint = QString()); void startInferiorPhase2(); void handleInferiorShutdown(const GdbResponse &response); diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp index c3604a80319..e954396c30a 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp @@ -30,6 +30,8 @@ #include "trkgdbadapter.h" #include "trkoptions.h" #include "trkoptionspage.h" +#include "s60debuggerbluetoothstarter.h" +#include "bluetoothlistener_gui.h" #include "debuggerstringutils.h" #ifndef STANDALONE_RUNNER @@ -193,10 +195,10 @@ TrkGdbAdapter::TrkGdbAdapter(GdbEngine *engine, const TrkOptionsPtr &options) : m_options(options), m_overrideTrkDeviceType(-1), m_running(false), + m_trkDevice(new trk::TrkDevice), m_gdbAckMode(true), m_verbose(2), - m_bufferedMemoryRead(true), - m_waitCount(0) + m_bufferedMemoryRead(true) { m_gdbServer = 0; m_gdbConnection = 0; @@ -207,28 +209,15 @@ TrkGdbAdapter::TrkGdbAdapter(GdbEngine *engine, const TrkOptionsPtr &options) : #endif m_gdbServerName = _("127.0.0.1:%1").arg(2222 + portOffset); - connect(&m_rfcommProc, SIGNAL(readyReadStandardError()), - this, SLOT(handleRfcommReadyReadStandardError())); - connect(&m_rfcommProc, SIGNAL(readyReadStandardOutput()), - this, SLOT(handleRfcommReadyReadStandardOutput())); - connect(&m_rfcommProc, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(handleRfcommError(QProcess::ProcessError))); - connect(&m_rfcommProc, SIGNAL(finished(int, QProcess::ExitStatus)), - this, SLOT(handleRfcommFinished(int, QProcess::ExitStatus))); - connect(&m_rfcommProc, SIGNAL(started()), - this, SLOT(handleRfcommStarted())); - connect(&m_rfcommProc, SIGNAL(stateChanged(QProcess::ProcessState)), - this, SLOT(handleRfcommStateChanged(QProcess::ProcessState))); - - connect(&m_trkDevice, SIGNAL(messageReceived(trk::TrkResult)), + connect(m_trkDevice.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleTrkResult(trk::TrkResult))); - connect(&m_trkDevice, SIGNAL(error(QString)), + connect(m_trkDevice.data(), SIGNAL(error(QString)), this, SLOT(handleTrkError(QString))); - m_trkDevice.setVerbose(m_verbose); - m_trkDevice.setSerialFrame(effectiveTrkDeviceType() != TrkOptions::BlueTooth); + m_trkDevice->setVerbose(m_verbose); + m_trkDevice->setSerialFrame(effectiveTrkDeviceType() != TrkOptions::BlueTooth); - connect(&m_trkDevice, SIGNAL(logMessage(QString)), + connect(m_trkDevice.data(), SIGNAL(logMessage(QString)), this, SLOT(trkLogMessage(QString))); } @@ -387,44 +376,6 @@ void TrkGdbAdapter::slotEmitDelayedInferiorStartFailed() emit inferiorStartFailed(m_adapterFailMessage); } -void TrkGdbAdapter::waitForTrkConnect() -{ - QTC_ASSERT(state() == AdapterStarting, qDebug() << state()); - QString errorMessage; - const QString device = effectiveTrkDevice(); - if (!m_trkDevice.open(device, &errorMessage)) { - logMessage(_("Waiting on %1 (%2)").arg(device, errorMessage)); - if (errorMessage.contains(_("ermission denied"))) { - static int direction = 0; - direction = (direction + 1) % 4; - showStatusMessage(_("Please start TRK on your device! %1") - .arg(QChar("/-\\|"[direction]))); - } - // Do not loop forever - if (m_waitCount++ < (effectiveTrkDeviceType() == TrkOptions::BlueTooth ? 60 : 5)) { - QTimer::singleShot(1000, this, SLOT(waitForTrkConnect())); - } else { - QString msg = _("Failed to connect to %1 after " - "%2 attempts").arg(device).arg(m_waitCount); - logMessage(msg); - emit adapterStartFailed(msg, TrkOptionsPage::settingsId()); - } - return; - } - - m_trkDevice.sendTrkInitialPing(); - sendTrkMessage(0x02); // Disconnect, as trk might be still connected - sendTrkMessage(0x01); // Connect - sendTrkMessage(0x05, TrkCB(handleSupportMask)); - sendTrkMessage(0x06, TrkCB(handleCpuType)); - sendTrkMessage(0x04, TrkCB(handleTrkVersions)); // Versions - //sendTrkMessage(0x09); // Unrecognized command - //sendTrkMessage(0x4a, 0, - // "10 " + formatString("C:\\data\\usingdlls.sisx")); // Open File - //sendTrkMessage(0x4B, 0, "00 00 00 01 73 1C 3A C8"); // Close File - - emit adapterStarted(); -} void TrkGdbAdapter::logMessage(const QString &msg) { @@ -981,13 +932,13 @@ i */ void TrkGdbAdapter::sendTrkMessage(byte code, TrkCallback callback, const QByteArray &data, const QVariant &cookie) { - m_trkDevice.sendTrkMessage(code, callback, data, cookie); + m_trkDevice->sendTrkMessage(code, callback, data, cookie); } void TrkGdbAdapter::sendTrkAck(byte token) { //logMessage(QString("SENDING ACKNOWLEDGEMENT FOR TOKEN %1").arg(int(token))); - m_trkDevice.sendTrkAck(token); + m_trkDevice->sendTrkAck(token); } void TrkGdbAdapter::handleTrkError(const QString &msg) @@ -1495,7 +1446,7 @@ void TrkGdbAdapter::handleSupportMask(const TrkResult &result) logMessage("SUPPORTED: " + str); } -void TrkGdbAdapter::handleTrkVersions(const TrkResult &result) +void TrkGdbAdapter::handleTrkVersionsStartGdb(const TrkResult &result) { QString logMsg; QTextStream str(&logMsg); @@ -1507,6 +1458,13 @@ void TrkGdbAdapter::handleTrkVersions(const TrkResult &result) << '.' << int(result.data.at(4)); } logMessage(logMsg); + QStringList gdbArgs; + gdbArgs.append(QLatin1String("--nx")); // Do not read .gdbinit file + if (!m_engine->startGdb(gdbArgs, m_options->gdb, TrkOptionsPage::settingsId())) { + cleanup(); + return; + } + emit adapterStarted(); } void TrkGdbAdapter::handleDisconnect(const TrkResult & /*result*/) @@ -1553,30 +1511,32 @@ void TrkGdbAdapter::startAdapter() setState(AdapterStarting); debugMessage(_("TRYING TO START ADAPTER")); logMessage(QLatin1String("### Starting TrkGdbAdapter")); - m_trkDevice.setSerialFrame(effectiveTrkDeviceType() != TrkOptions::BlueTooth); + m_trkDevice->setSerialFrame(effectiveTrkDeviceType() != TrkOptions::BlueTooth); + // Prompt the user for a bluetooth connection + const QString device = effectiveTrkDevice(); + QString message; if (effectiveTrkDeviceType() == TrkOptions::BlueTooth) { - const QString device = effectiveTrkDevice(); - const QString blueToothListener = QLatin1String("rfcomm"); - QStringList blueToothListenerArguments; - blueToothListenerArguments.append(_("-r")); - blueToothListenerArguments.append(_("listen")); - blueToothListenerArguments.append(m_options->blueToothDevice); - blueToothListenerArguments.append(_("1")); - logMessage(_("### Starting BlueTooth listener %1 on %2: %3 %4") - .arg(blueToothListener).arg(device).arg(blueToothListener) - .arg(blueToothListenerArguments.join(" "))); - m_rfcommProc.start(blueToothListener, blueToothListenerArguments); - m_rfcommProc.waitForStarted(); - if (m_rfcommProc.state() != QProcess::Running) { - QString msg = _("Failed to start BlueTooth " - "listener %1 on %2: %3\n"); - msg = msg.arg(blueToothListener, device, m_rfcommProc.errorString()); - msg += QString::fromLocal8Bit(m_rfcommProc.readAllStandardError()); - emit adapterStartFailed(msg, TrkOptionsPage::settingsId()); + S60DebuggerBluetoothStarter starter(m_trkDevice); + starter.setDevice(device); + const trk::StartBluetoothGuiResult src = trk::startBluetoothGui(starter, 0, &message); + switch (src) { + case trk::BluetoothGuiConnected: + break; + case trk::BluetoothGuiCanceled: + emit adapterStartFailed(message, QString()); + return; + case trk::BluetoothGuiError: + emit adapterStartFailed(message, TrkOptionsPage::settingsId()); + return; + }; + } else { + if (!m_trkDevice->isOpen() && !m_trkDevice->open(device, &message)) { + message = tr("Failed to connect to %1: %2\nCheck whether TRK is running.").arg(device).arg(message); + logMessage(message); + emit adapterStartFailed(message, TrkOptionsPage::settingsId()); return; } } - m_waitCount = 0; QTC_ASSERT(m_gdbServer == 0, delete m_gdbServer); QTC_ASSERT(m_gdbConnection == 0, m_gdbConnection = 0); @@ -1596,14 +1556,12 @@ void TrkGdbAdapter::startAdapter() connect(m_gdbServer, SIGNAL(newConnection()), this, SLOT(handleGdbConnection())); - QStringList gdbArgs; - gdbArgs.append(QLatin1String("--nx")); // Do not read .gdbinit file - if (!m_engine->startGdb(gdbArgs, m_options->gdb)) { - cleanup(); - return; - } - - waitForTrkConnect(); + m_trkDevice->sendTrkInitialPing(); + sendTrkMessage(0x02); // Disconnect, as trk might be still connected + sendTrkMessage(0x01); // Connect + sendTrkMessage(0x05, TrkCB(handleSupportMask)); + sendTrkMessage(0x06, TrkCB(handleCpuType)); + sendTrkMessage(0x04, TrkCB(handleTrkVersionsStartGdb)); // Versions } void TrkGdbAdapter::startInferior() @@ -1640,11 +1598,11 @@ void TrkGdbAdapter::handleCreateProcess(const TrkResult &result) m_session.tid = extractInt(data + 5); m_session.codeseg = extractInt(data + 9); m_session.dataseg = extractInt(data + 13); + const QString startMsg = tr("Process started, PID: 0x%1, thread id: 0x%2, code segment: 0x%3, data segment: 0x%4.") + .arg(m_session.pid, 0, 16).arg(m_session.tid, 0, 16) + .arg(m_session.codeseg, 0, 16).arg(m_session.dataseg, 0, 16); - logMessage("PID: " + hexxNumber(m_session.pid)); - logMessage("TID: " + hexxNumber(m_session.tid)); - logMessage("COD: " + hexxNumber(m_session.codeseg)); - logMessage("DAT: " + hexxNumber(m_session.dataseg)); + logMessage(startMsg); const QString fileName = m_symbolFile; if (m_symbolFile.isEmpty()) { @@ -1675,45 +1633,6 @@ void TrkGdbAdapter::startInferiorPhase2() m_engine->continueInferiorInternal(); } -// -// Rfcomm process handling -// - -void TrkGdbAdapter::handleRfcommReadyReadStandardError() -{ - QByteArray ba = m_rfcommProc.readAllStandardError(); - logMessage(QString("RFCONN stderr: %1").arg(_(ba))); -} - -void TrkGdbAdapter::handleRfcommReadyReadStandardOutput() -{ - QByteArray ba = m_rfcommProc.readAllStandardOutput(); - logMessage(QString("RFCONN stdout: %1").arg(_(ba))); -} - - -void TrkGdbAdapter::handleRfcommError(QProcess::ProcessError error) -{ - logMessage(QString("RFCOMM: Process Error %1: %2") - .arg(error).arg(m_rfcommProc.errorString())); -} - -void TrkGdbAdapter::handleRfcommFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - logMessage(QString("RFCOMM: ProcessFinished %1 %2") - .arg(exitCode).arg(exitStatus)); -} - -void TrkGdbAdapter::handleRfcommStarted() -{ - logMessage(QString("RFCOMM: Process Started")); -} - -void TrkGdbAdapter::handleRfcommStateChanged(QProcess::ProcessState newState) -{ - logMessage(QString("RFCOMM: Process State %1").arg(newState)); -} - // // AbstractGdbAdapter interface implementation // @@ -1939,7 +1858,7 @@ void TrkGdbAdapter::handleDirectStep3(const TrkResult &result) void TrkGdbAdapter::cleanup() { - m_trkDevice.close(); + m_trkDevice->close(); delete m_gdbServer; m_gdbServer = 0; } diff --git a/src/plugins/debugger/gdb/trkgdbadapter.h b/src/plugins/debugger/gdb/trkgdbadapter.h index 2f73b7fa76d..a4e01f3258a 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.h +++ b/src/plugins/debugger/gdb/trkgdbadapter.h @@ -43,10 +43,12 @@ #include #include #include +#include #include #include + namespace Debugger { namespace Internal { @@ -152,7 +154,6 @@ private: QString m_gdbServerName; // 127.0.0.1:(2222+uid) - QProcess m_rfcommProc; bool m_running; public: @@ -176,7 +177,6 @@ private: void emitDelayedInferiorStartFailed(const QString &msg); Q_SLOT void slotEmitDelayedInferiorStartFailed(); - Q_SLOT void waitForTrkConnect(); void handleTargetRemote(const GdbResponse &response); // @@ -198,7 +198,7 @@ private: void handleSignalContinue(const TrkResult &result); void handleStop(const TrkResult &result); void handleSupportMask(const TrkResult &result); - void handleTrkVersions(const TrkResult &result); + void handleTrkVersionsStartGdb(const TrkResult &result); void handleDisconnect(const TrkResult &result); void handleDeleteProcess(const TrkResult &result); void handleDeleteProcess2(const TrkResult &result); @@ -248,7 +248,7 @@ private: QByteArray trkDeleteProcessMessage(); QByteArray trkInterruptMessage(); - trk::TrkDevice m_trkDevice; + QSharedPointer m_trkDevice; QString m_adapterFailMessage; // @@ -288,16 +288,6 @@ private: QHash m_gdbCookieForToken; - // - // Rfcomm - // - Q_SLOT void handleRfcommReadyReadStandardError(); - Q_SLOT void handleRfcommReadyReadStandardOutput(); - Q_SLOT void handleRfcommError(QProcess::ProcessError error); - Q_SLOT void handleRfcommFinished(int exitCode, QProcess::ExitStatus exitStatus); - Q_SLOT void handleRfcommStarted(); - Q_SLOT void handleRfcommStateChanged(QProcess::ProcessState newState); - QString effectiveTrkDevice() const; int effectiveTrkDeviceType() const; @@ -308,7 +298,6 @@ private: QString m_symbolFile; int m_verbose; bool m_bufferedMemoryRead; - int m_waitCount; }; } // namespace Internal From 59584a1803c200fc97bf0d1b873da79874d39d17 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 26 Oct 2009 12:06:02 +0100 Subject: [PATCH 78/91] Updated the copyright header. --- .../qtscripteditor/parser/javascript.g | 134 ++++++------------ .../qtscripteditor/parser/javascriptast.cpp | 39 ++--- .../qtscripteditor/parser/javascriptast_p.h | 45 ++---- .../parser/javascriptastfwd_p.h | 46 +++--- .../parser/javascriptastvisitor.cpp | 36 ++--- .../parser/javascriptastvisitor_p.h | 47 +++--- .../parser/javascriptengine_p.h | 16 +++ .../parser/javascriptgrammar.cpp | 40 ++---- .../parser/javascriptgrammar_p.h | 45 +++--- .../qtscripteditor/parser/javascriptlexer.cpp | 47 ++---- .../qtscripteditor/parser/javascriptlexer_p.h | 47 +++--- .../parser/javascriptmemorypool_p.h | 52 +++---- .../parser/javascriptnodepool_p.h | 47 +++--- .../parser/javascriptparser.cpp | 47 ++---- .../parser/javascriptparser_p.h | 36 ++--- .../qtscripteditor/parser/javascriptvalue.h | 29 ++++ 16 files changed, 305 insertions(+), 448 deletions(-) diff --git a/src/plugins/qtscripteditor/parser/javascript.g b/src/plugins/qtscripteditor/parser/javascript.g index e75ee1cf7ed..927175edc42 100644 --- a/src/plugins/qtscripteditor/parser/javascript.g +++ b/src/plugins/qtscripteditor/parser/javascript.g @@ -1,18 +1,20 @@ ----------------------------------------------------------------------------- +--------------------------------------------------------------------------- +-- +-- This file is part of Qt Creator +-- +-- Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -- --- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -- Contact: Nokia Corporation (qt-info@nokia.com) -- --- This file is part of the QtScript module of the Qt Toolkit. +-- Commercial Usage -- --- $QT_BEGIN_LICENSE:LGPL$ --- No Commercial Usage --- This file contains pre-release code and may not be distributed. --- You may use this file in accordance with the terms and conditions --- contained in the either Technology Preview License Agreement or the --- Beta Release License Agreement. +-- Licensees holding valid Qt Commercial licenses may use this file in +-- accordance with the Qt Commercial License Agreement provided with the +-- Software or, alternatively, in accordance with the terms contained in +-- a written agreement between you and Nokia. -- -- GNU Lesser General Public License Usage +-- -- Alternatively, this file may be used under the terms of the GNU Lesser -- General Public License version 2.1 as published by the Free Software -- Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,27 +22,10 @@ -- ensure the GNU Lesser General Public License version 2.1 requirements -- will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -- --- In addition, as a special exception, Nokia gives you certain --- additional rights. These rights are described in the Nokia Qt LGPL --- Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this --- package. --- --- GNU General Public License Usage --- Alternatively, this file may be used under the terms of the GNU --- General Public License version 3.0 as published by the Free Software --- Foundation and appearing in the file LICENSE.GPL included in the --- packaging of this file. Please review the following information to --- ensure the GNU General Public License version 3.0 requirements will be --- met: http://www.gnu.org/copyleft/gpl.html. --- -- If you are unsure which license is appropriate for your use, please -- contact the sales department at http://qt.nokia.com/contact. --- $QT_END_LICENSE$ -- --- This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE --- WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. --- ----------------------------------------------------------------------------- +--------------------------------------------------------------------------- %parser JavaScriptGrammar %decl javascriptparser_p.h @@ -82,21 +67,23 @@ %start Program /. -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -104,37 +91,25 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ +**************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// #include - - - #include - - #include "javascriptengine_p.h" - - - - #include "javascriptlexer_p.h" #include "javascriptast_p.h" #include "javascriptnodepool_p.h" @@ -149,21 +124,23 @@ ./ /: -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -171,24 +148,10 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ +**************************************************************************/ // // W A R N I N G @@ -210,9 +173,6 @@ #define JAVASCRIPTPARSER_P_H #include "javascriptgrammar_p.h" - - - #include "javascriptastfwd_p.h" #include diff --git a/src/plugins/qtscripteditor/parser/javascriptast.cpp b/src/plugins/qtscripteditor/parser/javascriptast.cpp index 19c9e0af43e..d109d09e4a6 100644 --- a/src/plugins/qtscripteditor/parser/javascriptast.cpp +++ b/src/plugins/qtscripteditor/parser/javascriptast.cpp @@ -1,18 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,29 +22,12 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ +**************************************************************************/ #include "javascriptast_p.h" - - - #include "javascriptastvisitor_p.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/qtscripteditor/parser/javascriptast_p.h b/src/plugins/qtscripteditor/parser/javascriptast_p.h index 0aaaeb332cb..eb12f899cff 100644 --- a/src/plugins/qtscripteditor/parser/javascriptast_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptast_p.h @@ -1,18 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,27 +22,10 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ - -#ifndef JAVASCRIPTAST_P_H -#define JAVASCRIPTAST_P_H +**************************************************************************/ // // W A R N I N G @@ -53,10 +38,10 @@ // We mean it. // +#ifndef JAVASCRIPTAST_P_H +#define JAVASCRIPTAST_P_H + #include - - - #include "javascriptastvisitor_p.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/qtscripteditor/parser/javascriptastfwd_p.h b/src/plugins/qtscripteditor/parser/javascriptastfwd_p.h index 27a24bf7436..2c3a5955b9d 100644 --- a/src/plugins/qtscripteditor/parser/javascriptastfwd_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptastfwd_p.h @@ -1,18 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,29 +22,10 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ - -#ifndef JAVASCRIPTAST_FWD_P_H -#define JAVASCRIPTAST_FWD_P_H - -#include +**************************************************************************/ // // W A R N I N G @@ -55,6 +38,11 @@ // We mean it. // +#ifndef JAVASCRIPTAST_FWD_P_H +#define JAVASCRIPTAST_FWD_P_H + +#include + QT_BEGIN_NAMESPACE namespace JavaScript { namespace AST { diff --git a/src/plugins/qtscripteditor/parser/javascriptastvisitor.cpp b/src/plugins/qtscripteditor/parser/javascriptastvisitor.cpp index 5fbfc53d47b..47e1ba4225a 100644 --- a/src/plugins/qtscripteditor/parser/javascriptastvisitor.cpp +++ b/src/plugins/qtscripteditor/parser/javascriptastvisitor.cpp @@ -1,18 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,24 +22,10 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ +**************************************************************************/ #include "javascriptastvisitor_p.h" diff --git a/src/plugins/qtscripteditor/parser/javascriptastvisitor_p.h b/src/plugins/qtscripteditor/parser/javascriptastvisitor_p.h index aa924bc24c4..df6f8bd6a7d 100644 --- a/src/plugins/qtscripteditor/parser/javascriptastvisitor_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptastvisitor_p.h @@ -1,18 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,24 +22,21 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ +**************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// #ifndef JAVASCRIPTASTVISITOR_P_H #define JAVASCRIPTASTVISITOR_P_H diff --git a/src/plugins/qtscripteditor/parser/javascriptengine_p.h b/src/plugins/qtscripteditor/parser/javascriptengine_p.h index 42418741a75..15232f288d3 100644 --- a/src/plugins/qtscripteditor/parser/javascriptengine_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptengine_p.h @@ -27,6 +27,22 @@ ** **************************************************************************/ +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// +// This file is automatically generated from javascript.g. +// Changes will be lost. +// + #ifndef JAVASCRIPTENGINE_P_H #define JAVASCRIPTENGINE_P_H diff --git a/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp b/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp index aaa8cd092b5..aca84c8b2e7 100644 --- a/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp +++ b/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp @@ -1,20 +1,21 @@ // This file was generated by qlalr - DO NOT EDIT! -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtCore module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,23 +23,10 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +**************************************************************************/ #include "javascriptgrammar_p.h" diff --git a/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h b/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h index 3126ed08cf1..ed797cfa601 100644 --- a/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h @@ -1,20 +1,20 @@ -// This file was generated by qlalr - DO NOT EDIT! -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtCore module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,30 +22,17 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +**************************************************************************/ // // W A R N I N G // ------------- // -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. diff --git a/src/plugins/qtscripteditor/parser/javascriptlexer.cpp b/src/plugins/qtscripteditor/parser/javascriptlexer.cpp index 51fa3ebfb11..6f0220d4fcd 100644 --- a/src/plugins/qtscripteditor/parser/javascriptlexer.cpp +++ b/src/plugins/qtscripteditor/parser/javascriptlexer.cpp @@ -1,18 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,37 +22,12 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +**************************************************************************/ #include "javascriptengine_p.h" - - - - - - - #include "javascriptlexer_p.h" #include "javascriptgrammar_p.h" diff --git a/src/plugins/qtscripteditor/parser/javascriptlexer_p.h b/src/plugins/qtscripteditor/parser/javascriptlexer_p.h index d6d5f7f819e..406620bb3ea 100644 --- a/src/plugins/qtscripteditor/parser/javascriptlexer_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptlexer_p.h @@ -1,18 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,27 +22,10 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ - -#ifndef JAVASCRIPTLEXER_P_H -#define JAVASCRIPTLEXER_P_H +**************************************************************************/ // // W A R N I N G @@ -53,6 +38,14 @@ // We mean it. // +// +// This file is automatically generated from javascript.g. +// Changes will be lost. +// + +#ifndef JAVASCRIPTLEXER_P_H +#define JAVASCRIPTLEXER_P_H + #include diff --git a/src/plugins/qtscripteditor/parser/javascriptmemorypool_p.h b/src/plugins/qtscripteditor/parser/javascriptmemorypool_p.h index 429b74def71..c58e2dc90e4 100644 --- a/src/plugins/qtscripteditor/parser/javascriptmemorypool_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptmemorypool_p.h @@ -1,18 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,24 +22,26 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ +**************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// +// This file is automatically generated from javascript.g. +// Changes will be lost. +// #ifndef JAVASCRIPTMEMORYPOOL_P_H #define JAVASCRIPTMEMORYPOOL_P_H diff --git a/src/plugins/qtscripteditor/parser/javascriptnodepool_p.h b/src/plugins/qtscripteditor/parser/javascriptnodepool_p.h index a0e7d649c69..1b7242e29c9 100644 --- a/src/plugins/qtscripteditor/parser/javascriptnodepool_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptnodepool_p.h @@ -1,18 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,27 +22,10 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ - -#ifndef JAVASCRIPTNODEPOOL_P_H -#define JAVASCRIPTNODEPOOL_P_H +**************************************************************************/ // // W A R N I N G @@ -53,6 +38,14 @@ // We mean it. // +// +// This file is automatically generated from javascript.g. +// Changes will be lost. +// + +#ifndef JAVASCRIPTNODEPOOL_P_H +#define JAVASCRIPTNODEPOOL_P_H + #include #include diff --git a/src/plugins/qtscripteditor/parser/javascriptparser.cpp b/src/plugins/qtscripteditor/parser/javascriptparser.cpp index b63a9fbe93a..295969a11d8 100644 --- a/src/plugins/qtscripteditor/parser/javascriptparser.cpp +++ b/src/plugins/qtscripteditor/parser/javascriptparser.cpp @@ -1,20 +1,20 @@ -// This file was generated by qlalr - DO NOT EDIT! - -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,37 +22,14 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ +**************************************************************************/ #include - - - #include - - #include "javascriptengine_p.h" - - - - #include "javascriptlexer_p.h" #include "javascriptast_p.h" #include "javascriptnodepool_p.h" diff --git a/src/plugins/qtscripteditor/parser/javascriptparser_p.h b/src/plugins/qtscripteditor/parser/javascriptparser_p.h index d6929710e10..29c54927d65 100644 --- a/src/plugins/qtscripteditor/parser/javascriptparser_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptparser_p.h @@ -1,20 +1,22 @@ // This file was generated by qlalr - DO NOT EDIT! -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,24 +24,10 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ +**************************************************************************/ // // W A R N I N G diff --git a/src/plugins/qtscripteditor/parser/javascriptvalue.h b/src/plugins/qtscripteditor/parser/javascriptvalue.h index c68b817b9fc..715cedf3c4a 100644 --- a/src/plugins/qtscripteditor/parser/javascriptvalue.h +++ b/src/plugins/qtscripteditor/parser/javascriptvalue.h @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #ifndef JAVASCRIPTVALUE_H #define JAVASCRIPTVALUE_H From fc512f716dad7dcb0c1a560ad516eae284fce1bb Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 26 Oct 2009 12:08:05 +0100 Subject: [PATCH 79/91] some forgotten license header changes. also, use Nokia instead of Trolltech. --- doc/addressbook-sdk.qdoc | 36 +++++++------------ share/qtcreator/gdbmacros/gdbmacros_p.h | 36 +++++++------------ .../test/auto/pluginspec/testspecs/spec1.xml | 6 ++-- .../auto/pluginspec/testspecs/spec_wrong1.xml | 6 ++-- .../auto/pluginspec/testspecs/spec_wrong2.xml | 6 ++-- .../auto/pluginspec/testspecs/spec_wrong3.xml | 6 ++-- .../auto/pluginspec/testspecs/spec_wrong4.xml | 6 ++-- .../auto/pluginspec/testspecs/spec_wrong5.xml | 6 ++-- 8 files changed, 42 insertions(+), 66 deletions(-) diff --git a/doc/addressbook-sdk.qdoc b/doc/addressbook-sdk.qdoc index 7d7734bea78..9737100f255 100644 --- a/doc/addressbook-sdk.qdoc +++ b/doc/addressbook-sdk.qdoc @@ -1,18 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the documentation of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,24 +22,10 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ +**************************************************************************/ /*! \page tutorials-addressbook-sdk.html diff --git a/share/qtcreator/gdbmacros/gdbmacros_p.h b/share/qtcreator/gdbmacros/gdbmacros_p.h index fc6b665e9ad..88867b02b2f 100644 --- a/share/qtcreator/gdbmacros/gdbmacros_p.h +++ b/share/qtcreator/gdbmacros/gdbmacros_p.h @@ -1,18 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Assistant of the Qt Toolkit. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -20,24 +22,10 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ ** -****************************************************************************/ +**************************************************************************/ #ifndef GDBMACROS_P_H #define GDBMACROS_P_H diff --git a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec1.xml b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec1.xml index 31cebf44146..994f330bbe6 100644 --- a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec1.xml +++ b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec1.xml @@ -1,6 +1,6 @@ - Trolltech - (C) 2007 Trolltech ASA + Nokia Corporation + (C) 2007 Nokia Corporation This is a default license bla blubbblubb @@ -10,7 +10,7 @@ end of terms This plugin is just a test. it demonstrates the great use of the plugin spec. - http://www.trolltech.com + http://qt.noki.com diff --git a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong1.xml b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong1.xml index e6fe956c98e..ffcb61241e9 100644 --- a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong1.xml +++ b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong1.xml @@ -1,6 +1,6 @@ - Trolltech - (C) 2007 Trolltech ASA + Nokia Corporation + (C) 2007 Nokia Corporation This is a default license bla blubbblubb @@ -10,7 +10,7 @@ end of terms This plugin is just a test. it demonstrates the great use of the plugin spec. - http://www.trolltech.com + http://qt.nokia.com diff --git a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong2.xml b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong2.xml index 200a1fd1ac1..917acf78ad7 100644 --- a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong2.xml +++ b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong2.xml @@ -1,6 +1,6 @@ - Trolltech - (C) 2007 Trolltech ASA + Nokia Corporation + (C) 2007 Nokia Corporation This is a default license bla blubbblubb @@ -10,7 +10,7 @@ end of terms This plugin is just a test. it demonstrates the great use of the plugin spec. - http://www.trolltech.com + http://qt.nokia.com diff --git a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong3.xml b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong3.xml index 13bbdb09a8d..d79ab4492bc 100644 --- a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong3.xml +++ b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong3.xml @@ -1,6 +1,6 @@ - Trolltech - (C) 2007 Trolltech ASA + Nokia Corporation + (C) 2007 Nokia Corporation This is a default license bla blubbblubb @@ -10,7 +10,7 @@ end of terms This plugin is just a test. it demonstrates the great use of the plugin spec. - http://www.trolltech.com + http://qt.nokia.com diff --git a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong4.xml b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong4.xml index b904f901387..849f165f9ca 100644 --- a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong4.xml +++ b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong4.xml @@ -1,6 +1,6 @@ - Trolltech - (C) 2007 Trolltech ASA + Nokia Corporation + (C) 2007 Nokia Corporation This is a default license bla blubbblubb @@ -10,7 +10,7 @@ end of terms This plugin is just a test. it demonstrates the great use of the plugin spec. - http://www.trolltech.com + http://qt.nokia.com diff --git a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong5.xml b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong5.xml index 1c110d1eeae..03936fd88c0 100644 --- a/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong5.xml +++ b/src/libs/extensionsystem/test/auto/pluginspec/testspecs/spec_wrong5.xml @@ -1,6 +1,6 @@ - Trolltech - (C) 2007 Trolltech ASA + Nokia Corporation + (C) 2007 Nokia Corporation This is a default license bla blubbblubb @@ -10,7 +10,7 @@ end of terms This plugin is just a test. it demonstrates the great use of the plugin spec. - http://www.trolltech.com + http://qt.nokia.com From 47035f381706d62de9689501e5e9ba400b01782c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 26 Oct 2009 12:18:14 +0100 Subject: [PATCH 80/91] S60: Split up starters into a different file. --- .../gdb/s60debuggerbluetoothstarter.cpp | 1 + .../gdb/s60debuggerbluetoothstarter.h | 2 +- .../qt-s60/s60runconfigbluetoothstarter.cpp | 1 + .../qt-s60/s60runconfigbluetoothstarter.h | 2 +- src/shared/trk/bluetoothlistener.cpp | 193 --------------- src/shared/trk/bluetoothlistener.h | 85 ------- src/shared/trk/bluetoothlistener_gui.cpp | 1 + src/shared/trk/communicationstarter.cpp | 228 ++++++++++++++++++ src/shared/trk/communicationstarter.h | 125 ++++++++++ src/shared/trk/trk.pri | 6 +- tests/manual/trklauncher/main.cpp | 2 +- 11 files changed, 363 insertions(+), 283 deletions(-) create mode 100644 src/shared/trk/communicationstarter.cpp create mode 100644 src/shared/trk/communicationstarter.h diff --git a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp index b1d34f4ff3a..8dcfa4b9042 100644 --- a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp +++ b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp @@ -28,6 +28,7 @@ **************************************************************************/ #include "s60debuggerbluetoothstarter.h" +#include "bluetoothlistener.h" #include "debuggermanager.h" namespace Debugger { diff --git a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h index 216ab80a4b9..226e00072ac 100644 --- a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h +++ b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h @@ -30,7 +30,7 @@ #ifndef S60DEBUGGERBLUETOOTHSTARTER_H #define S60DEBUGGERBLUETOOTHSTARTER_H -#include "bluetoothlistener.h" +#include "communicationstarter.h" namespace Debugger { namespace Internal { diff --git a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp index 305d917597d..1481dcacbc9 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp @@ -28,6 +28,7 @@ **************************************************************************/ #include "s60runconfigbluetoothstarter.h" +#include "bluetoothlistener.h" #include #include diff --git a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h index 340f74082f4..0da8817b323 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h @@ -30,7 +30,7 @@ #ifndef S60RUNCONFIGBLUETOOTHSTARTER_H #define S60RUNCONFIGBLUETOOTHSTARTER_H -#include "bluetoothlistener.h" +#include "communicationstarter.h" namespace Qt4ProjectManager { namespace Internal { diff --git a/src/shared/trk/bluetoothlistener.cpp b/src/shared/trk/bluetoothlistener.cpp index 6b22dea6d4c..1f5ccbe51b4 100644 --- a/src/shared/trk/bluetoothlistener.cpp +++ b/src/shared/trk/bluetoothlistener.cpp @@ -31,8 +31,6 @@ #include "trkdevice.h" #include -#include -#include #ifdef Q_OS_UNIX # include @@ -211,195 +209,4 @@ void BluetoothListener::slotProcessError(QProcess::ProcessError error) .arg(d->device).arg(error).arg(d->process.errorString())); } -// --------------- AbstractBluetoothStarter -struct AbstractBluetoothStarterPrivate { - explicit AbstractBluetoothStarterPrivate(const AbstractBluetoothStarter::TrkDevicePtr &d); - - const AbstractBluetoothStarter::TrkDevicePtr trkDevice; - BluetoothListener *listener; - QTimer *timer; - int intervalMS; - int attempts; - int n; - QString device; - QString errorString; - AbstractBluetoothStarter::State state; -}; - -AbstractBluetoothStarterPrivate::AbstractBluetoothStarterPrivate(const AbstractBluetoothStarter::TrkDevicePtr &d) : - - trkDevice(d), - listener(0), - timer(0), - intervalMS(1000), - attempts(-1), - n(0), - device(QLatin1String("/dev/rfcomm0")), - state(AbstractBluetoothStarter::TimedOut) -{ -} - -AbstractBluetoothStarter::AbstractBluetoothStarter(const TrkDevicePtr &trkDevice, QObject *parent) : - QObject(parent), - d(new AbstractBluetoothStarterPrivate(trkDevice)) -{ -} - -AbstractBluetoothStarter::~AbstractBluetoothStarter() -{ - stopTimer(); - delete d; -} - -void AbstractBluetoothStarter::stopTimer() -{ - if (d->timer && d->timer->isActive()) - d->timer->stop(); -} - -AbstractBluetoothStarter::StartResult AbstractBluetoothStarter::start() -{ - if (state() == Running) { - d->errorString = QLatin1String("Internal error, attempt to re-start AbstractBluetoothStarter.\n"); - return StartError; - } - // Before we instantiate timers, and such, try to open the device, - // which should succeed if another listener is already running in - // 'Watch' mode - if (d->trkDevice->open(d->device , &(d->errorString))) - return ConnectionSucceeded; - // Fire up the listener - d->n = 0; - d->listener = createListener(); - if (!d->listener->start(d->device, &(d->errorString))) - return StartError; - // Start timer - if (!d->timer) { - d->timer = new QTimer; - connect(d->timer, SIGNAL(timeout()), this, SLOT(slotTimer())); - } - d->timer->setInterval(d->intervalMS); - d->timer->setSingleShot(false); - d->timer->start(); - d->state = Running; - return Started; -} - -AbstractBluetoothStarter::State AbstractBluetoothStarter::state() const -{ - return d->state; -} - -int AbstractBluetoothStarter::intervalMS() const -{ - return d->intervalMS; -} - -void AbstractBluetoothStarter::setIntervalMS(int i) -{ - d->intervalMS = i; - if (d->timer) - d->timer->setInterval(i); -} - -int AbstractBluetoothStarter::attempts() const -{ - return d->attempts; -} - -void AbstractBluetoothStarter::setAttempts(int a) -{ - d->attempts = a; -} - -QString AbstractBluetoothStarter::device() const -{ - return d->device; -} - -void AbstractBluetoothStarter::setDevice(const QString &dv) -{ - d->device = dv; -} - -QString AbstractBluetoothStarter::errorString() const -{ - return d->errorString; -} - -void AbstractBluetoothStarter::slotTimer() -{ - ++d->n; - // Check for timeout - if (d->attempts >= 0 && d->n >= d->attempts) { - stopTimer(); - d->errorString = tr("%1: timed out after %n attempts using an interval of %2ms.", 0, d->n) - .arg(d->device).arg(d->intervalMS); - d->state = TimedOut; - emit timeout(); - } else { - // Attempt n to connect? - if (d->trkDevice->open(d->device , &(d->errorString))) { - stopTimer(); - const QString msg = tr("%1: Connection attempt %2 succeeded.").arg(d->device).arg(d->n); - d->listener->emitMessage(msg); - d->state = Connected; - emit connected(); - } else { - const QString msg = tr("%1: Connection attempt %2 failed: %3 (retrying)...") - .arg(d->device).arg(d->n).arg(d->errorString); - d->listener->emitMessage(msg); - } - } -} - -// -------- ConsoleBluetoothStarter -ConsoleBluetoothStarter::ConsoleBluetoothStarter(const TrkDevicePtr &trkDevice, - QObject *listenerParent, - QObject *parent) : - AbstractBluetoothStarter(trkDevice, parent), - m_listenerParent(listenerParent) -{ -} - -BluetoothListener *ConsoleBluetoothStarter::createListener() -{ - BluetoothListener *rc = new BluetoothListener(m_listenerParent); - rc->setMode(BluetoothListener::Listen); - rc->setPrintConsoleMessages(true); - return rc; -} - -bool ConsoleBluetoothStarter::startBluetooth(const TrkDevicePtr &trkDevice, - QObject *listenerParent, - const QString &device, - int attempts, - QString *errorMessage) -{ - // Set up a console starter to print to stdout. - ConsoleBluetoothStarter starter(trkDevice, listenerParent); - starter.setDevice(device); - starter.setAttempts(attempts); - switch (starter.start()) { - case Started: - break; - case ConnectionSucceeded: - return true; - case StartError: - *errorMessage = starter.errorString(); - return false; - } - // Run the starter with an event loop. @ToDo: Implement - // some asynchronous keypress read to cancel. - QEventLoop eventLoop; - connect(&starter, SIGNAL(connected()), &eventLoop, SLOT(quit())); - connect(&starter, SIGNAL(timeout()), &eventLoop, SLOT(quit())); - eventLoop.exec(QEventLoop::ExcludeUserInputEvents); - if (starter.state() != AbstractBluetoothStarter::Connected) { - *errorMessage = starter.errorString(); - return false; - } - return true; -} - } // namespace trk diff --git a/src/shared/trk/bluetoothlistener.h b/src/shared/trk/bluetoothlistener.h index 581a32cde1a..a20ba307534 100644 --- a/src/shared/trk/bluetoothlistener.h +++ b/src/shared/trk/bluetoothlistener.h @@ -32,12 +32,9 @@ #include #include -#include namespace trk { -class TrkDevice; struct BluetoothListenerPrivate; -struct AbstractBluetoothStarterPrivate; /* BluetoothListener: Starts a helper process watching connections on a * Bluetooth device, Linux only: @@ -87,88 +84,6 @@ private: BluetoothListenerPrivate *d; }; -/* AbstractBluetoothStarter: Repeatedly tries to open a trk device - * until a connection succeeds, allowing to do something else in the - * foreground (local event loop or asynchronous operation). - * Note that in case a Listener is already running in watch mode, it might - * also happen that connection succeeds immediately. - * Implementations must provide a factory function that creates and sets up the - * listener (mode, message connection, etc). */ - -class AbstractBluetoothStarter : public QObject { - Q_OBJECT - Q_DISABLE_COPY(AbstractBluetoothStarter) -public: - typedef QSharedPointer TrkDevicePtr; - - enum State { Running, Connected, TimedOut }; - - virtual ~AbstractBluetoothStarter(); - - int intervalMS() const; - void setIntervalMS(int i); - - int attempts() const; - void setAttempts(int a); - - QString device() const; - void setDevice(const QString &); - - State state() const; - QString errorString() const; - - enum StartResult { - Started, // Starter is now running. - ConnectionSucceeded, /* Initial connection attempt succeeded, - * no need to keep running. */ - StartError // Error occurred during start. - }; - - StartResult start(); - -signals: - void connected(); - void timeout(); - -private slots: - void slotTimer(); - -protected: - explicit AbstractBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); - // Overwrite to create and parametrize the listener. - virtual BluetoothListener *createListener() = 0; - -private: - inline void stopTimer(); - - AbstractBluetoothStarterPrivate *d; -}; - -/* ConsoleBluetoothStarter: Convenience class for console processes. Creates a - * listener in "Listen" mode with the messages redirected to standard output. */ - -class ConsoleBluetoothStarter : public AbstractBluetoothStarter { - Q_OBJECT - Q_DISABLE_COPY(ConsoleBluetoothStarter) -public: - - static bool startBluetooth(const TrkDevicePtr& trkDevice, - QObject *listenerParent, - const QString &device, - int attempts, - QString *errorMessage); - -protected: - virtual BluetoothListener *createListener(); - -private: - explicit ConsoleBluetoothStarter(const TrkDevicePtr& trkDevice, - QObject *listenerParent, - QObject *parent = 0); - - QObject *m_listenerParent; -}; - } // namespace trk #endif // BLUETOOTHLISTENER_H diff --git a/src/shared/trk/bluetoothlistener_gui.cpp b/src/shared/trk/bluetoothlistener_gui.cpp index 9723a36d9d6..ee21c82a7c5 100644 --- a/src/shared/trk/bluetoothlistener_gui.cpp +++ b/src/shared/trk/bluetoothlistener_gui.cpp @@ -29,6 +29,7 @@ #include "bluetoothlistener_gui.h" #include "bluetoothlistener.h" +#include "communicationstarter.h" #include #include diff --git a/src/shared/trk/communicationstarter.cpp b/src/shared/trk/communicationstarter.cpp new file mode 100644 index 00000000000..58a954cd26b --- /dev/null +++ b/src/shared/trk/communicationstarter.cpp @@ -0,0 +1,228 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "communicationstarter.h" +#include "bluetoothlistener.h" +#include "trkdevice.h" + +#include +#include + +namespace trk { +// --------------- AbstractBluetoothStarter +struct AbstractBluetoothStarterPrivate { + explicit AbstractBluetoothStarterPrivate(const AbstractBluetoothStarter::TrkDevicePtr &d); + + const AbstractBluetoothStarter::TrkDevicePtr trkDevice; + BluetoothListener *listener; + QTimer *timer; + int intervalMS; + int attempts; + int n; + QString device; + QString errorString; + AbstractBluetoothStarter::State state; +}; + +AbstractBluetoothStarterPrivate::AbstractBluetoothStarterPrivate(const AbstractBluetoothStarter::TrkDevicePtr &d) : + + trkDevice(d), + listener(0), + timer(0), + intervalMS(1000), + attempts(-1), + n(0), + device(QLatin1String("/dev/rfcomm0")), + state(AbstractBluetoothStarter::TimedOut) +{ +} + +AbstractBluetoothStarter::AbstractBluetoothStarter(const TrkDevicePtr &trkDevice, QObject *parent) : + QObject(parent), + d(new AbstractBluetoothStarterPrivate(trkDevice)) +{ +} + +AbstractBluetoothStarter::~AbstractBluetoothStarter() +{ + stopTimer(); + delete d; +} + +void AbstractBluetoothStarter::stopTimer() +{ + if (d->timer && d->timer->isActive()) + d->timer->stop(); +} + +AbstractBluetoothStarter::StartResult AbstractBluetoothStarter::start() +{ + if (state() == Running) { + d->errorString = QLatin1String("Internal error, attempt to re-start AbstractBluetoothStarter.\n"); + return StartError; + } + // Before we instantiate timers, and such, try to open the device, + // which should succeed if another listener is already running in + // 'Watch' mode + if (d->trkDevice->open(d->device , &(d->errorString))) + return ConnectionSucceeded; + // Fire up the listener + d->n = 0; + d->listener = createListener(); + if (!d->listener->start(d->device, &(d->errorString))) + return StartError; + // Start timer + if (!d->timer) { + d->timer = new QTimer; + connect(d->timer, SIGNAL(timeout()), this, SLOT(slotTimer())); + } + d->timer->setInterval(d->intervalMS); + d->timer->setSingleShot(false); + d->timer->start(); + d->state = Running; + return Started; +} + +AbstractBluetoothStarter::State AbstractBluetoothStarter::state() const +{ + return d->state; +} + +int AbstractBluetoothStarter::intervalMS() const +{ + return d->intervalMS; +} + +void AbstractBluetoothStarter::setIntervalMS(int i) +{ + d->intervalMS = i; + if (d->timer) + d->timer->setInterval(i); +} + +int AbstractBluetoothStarter::attempts() const +{ + return d->attempts; +} + +void AbstractBluetoothStarter::setAttempts(int a) +{ + d->attempts = a; +} + +QString AbstractBluetoothStarter::device() const +{ + return d->device; +} + +void AbstractBluetoothStarter::setDevice(const QString &dv) +{ + d->device = dv; +} + +QString AbstractBluetoothStarter::errorString() const +{ + return d->errorString; +} + +void AbstractBluetoothStarter::slotTimer() +{ + ++d->n; + // Check for timeout + if (d->attempts >= 0 && d->n >= d->attempts) { + stopTimer(); + d->errorString = tr("%1: timed out after %n attempts using an interval of %2ms.", 0, d->n) + .arg(d->device).arg(d->intervalMS); + d->state = TimedOut; + emit timeout(); + } else { + // Attempt n to connect? + if (d->trkDevice->open(d->device , &(d->errorString))) { + stopTimer(); + const QString msg = tr("%1: Connection attempt %2 succeeded.").arg(d->device).arg(d->n); + d->listener->emitMessage(msg); + d->state = Connected; + emit connected(); + } else { + const QString msg = tr("%1: Connection attempt %2 failed: %3 (retrying)...") + .arg(d->device).arg(d->n).arg(d->errorString); + d->listener->emitMessage(msg); + } + } +} + +// -------- ConsoleBluetoothStarter +ConsoleBluetoothStarter::ConsoleBluetoothStarter(const TrkDevicePtr &trkDevice, + QObject *listenerParent, + QObject *parent) : +AbstractBluetoothStarter(trkDevice, parent), +m_listenerParent(listenerParent) +{ +} + +BluetoothListener *ConsoleBluetoothStarter::createListener() +{ + BluetoothListener *rc = new BluetoothListener(m_listenerParent); + rc->setMode(BluetoothListener::Listen); + rc->setPrintConsoleMessages(true); + return rc; +} + +bool ConsoleBluetoothStarter::startBluetooth(const TrkDevicePtr &trkDevice, + QObject *listenerParent, + const QString &device, + int attempts, + QString *errorMessage) +{ + // Set up a console starter to print to stdout. + ConsoleBluetoothStarter starter(trkDevice, listenerParent); + starter.setDevice(device); + starter.setAttempts(attempts); + switch (starter.start()) { + case Started: + break; + case ConnectionSucceeded: + return true; + case StartError: + *errorMessage = starter.errorString(); + return false; + } + // Run the starter with an event loop. @ToDo: Implement + // some asynchronous keypress read to cancel. + QEventLoop eventLoop; + connect(&starter, SIGNAL(connected()), &eventLoop, SLOT(quit())); + connect(&starter, SIGNAL(timeout()), &eventLoop, SLOT(quit())); + eventLoop.exec(QEventLoop::ExcludeUserInputEvents); + if (starter.state() != AbstractBluetoothStarter::Connected) { + *errorMessage = starter.errorString(); + return false; + } + return true; +} +} // namespace trk diff --git a/src/shared/trk/communicationstarter.h b/src/shared/trk/communicationstarter.h new file mode 100644 index 00000000000..e90578dc171 --- /dev/null +++ b/src/shared/trk/communicationstarter.h @@ -0,0 +1,125 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef COMMUNICATIONSTARTER_H +#define COMMUNICATIONSTARTER_H + +#include +#include + +namespace trk { +class TrkDevice; +class BluetoothListener; +struct AbstractBluetoothStarterPrivate; + +/* AbstractBluetoothStarter: Repeatedly tries to open a trk device + * until a connection succeeds, allowing to do something else in the + * foreground (local event loop or asynchronous operation). + * Note that in case a Listener is already running in watch mode, it might + * also happen that connection succeeds immediately. + * Implementations must provide a factory function that creates and sets up the + * listener (mode, message connection, etc). */ + +class AbstractBluetoothStarter : public QObject { + Q_OBJECT + Q_DISABLE_COPY(AbstractBluetoothStarter) +public: + typedef QSharedPointer TrkDevicePtr; + + enum State { Running, Connected, TimedOut }; + + virtual ~AbstractBluetoothStarter(); + + int intervalMS() const; + void setIntervalMS(int i); + + int attempts() const; + void setAttempts(int a); + + QString device() const; + void setDevice(const QString &); + + State state() const; + QString errorString() const; + + enum StartResult { + Started, // Starter is now running. + ConnectionSucceeded, /* Initial connection attempt succeeded, + * no need to keep running. */ + StartError // Error occurred during start. + }; + + StartResult start(); + +signals: + void connected(); + void timeout(); + +private slots: + void slotTimer(); + +protected: + explicit AbstractBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); + // Overwrite to create and parametrize the listener. + virtual BluetoothListener *createListener() = 0; + +private: + inline void stopTimer(); + + AbstractBluetoothStarterPrivate *d; +}; + +/* ConsoleBluetoothStarter: Convenience class for console processes. Creates a + * listener in "Listen" mode with the messages redirected to standard output. */ + +class ConsoleBluetoothStarter : public AbstractBluetoothStarter { + Q_OBJECT + Q_DISABLE_COPY(ConsoleBluetoothStarter) +public: + + static bool startBluetooth(const TrkDevicePtr& trkDevice, + QObject *listenerParent, + const QString &device, + int attempts, + QString *errorMessage); + +protected: + virtual BluetoothListener *createListener(); + +private: + explicit ConsoleBluetoothStarter(const TrkDevicePtr& trkDevice, + QObject *listenerParent, + QObject *parent = 0); + + QObject *m_listenerParent; +}; + +} // namespace trk + +#endif // COMMUNICATIONSTARTER_H diff --git a/src/shared/trk/trk.pri b/src/shared/trk/trk.pri index 8965948f194..5b0e067b158 100644 --- a/src/shared/trk/trk.pri +++ b/src/shared/trk/trk.pri @@ -5,12 +5,14 @@ HEADERS += $$PWD/callback.h \ $$PWD/trkutils.h \ $$PWD/trkdevice.h \ $$PWD/launcher.h \ - $$PWD/bluetoothlistener.h + $$PWD/bluetoothlistener.h \ + $$PWD/communicationstarter.h SOURCES += $$PWD/trkutils.cpp \ $$PWD/trkdevice.cpp \ $$PWD/launcher.cpp \ - $$PWD/bluetoothlistener.cpp + $$PWD/bluetoothlistener.cpp \ + $$PWD/communicationstarter.cpp contains(QT, gui) { HEADERS += $$PWD/bluetoothlistener_gui.h diff --git a/tests/manual/trklauncher/main.cpp b/tests/manual/trklauncher/main.cpp index e9847d33b8f..35336632173 100644 --- a/tests/manual/trklauncher/main.cpp +++ b/tests/manual/trklauncher/main.cpp @@ -1,5 +1,5 @@ #include "launcher.h" -#include "bluetoothlistener.h" +#include "communicationstarter.h" #include #include From fb8d699aac2cfe4b84a6f86abbd24e68333d1b12 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 26 Oct 2009 12:41:13 +0100 Subject: [PATCH 81/91] Introduced CPlusPlus::GenTemplateInstance. --- src/libs/cplusplus/GenTemplateInstance.cpp | 145 ++++++++++++++++++++ src/libs/cplusplus/GenTemplateInstance.h | 58 ++++++++ src/libs/cplusplus/ResolveExpression.cpp | 150 +-------------------- src/libs/cplusplus/cplusplus-lib.pri | 2 + 4 files changed, 208 insertions(+), 147 deletions(-) create mode 100644 src/libs/cplusplus/GenTemplateInstance.cpp create mode 100644 src/libs/cplusplus/GenTemplateInstance.h diff --git a/src/libs/cplusplus/GenTemplateInstance.cpp b/src/libs/cplusplus/GenTemplateInstance.cpp new file mode 100644 index 00000000000..07555932505 --- /dev/null +++ b/src/libs/cplusplus/GenTemplateInstance.cpp @@ -0,0 +1,145 @@ + +#include "GenTemplateInstance.h" +#include +#include +#include +#include +#include +#include + +using namespace CPlusPlus; + +GenTemplateInstance::GenTemplateInstance(Control *control, const Substitution &substitution) + : _control(control), + _substitution(substitution) +{ } + +FullySpecifiedType GenTemplateInstance::operator()(const FullySpecifiedType &ty) +{ return subst(ty); } + +FullySpecifiedType GenTemplateInstance::subst(Name *name) +{ + if (TemplateNameId *t = name->asTemplateNameId()) { + QVarLengthArray args(t->templateArgumentCount()); + + for (unsigned i = 0; i < t->templateArgumentCount(); ++i) + args[i] = subst(t->templateArgumentAt(i)); + + TemplateNameId *n = _control->templateNameId(t->identifier(), + args.data(), args.size()); + + return FullySpecifiedType(_control->namedType(n)); + } else if (name->isQualifiedNameId()) { + // ### implement me + } + + for (int i = 0; i < _substitution.size(); ++i) { + const QPair s = _substitution.at(i); + if (name->isEqualTo(s.first)) + return s.second; + } + + return FullySpecifiedType(_control->namedType(name)); +} + +FullySpecifiedType GenTemplateInstance::subst(const FullySpecifiedType &ty) +{ + FullySpecifiedType previousType = switchType(ty); + TypeVisitor::accept(ty.type()); + return switchType(previousType); +} + +FullySpecifiedType GenTemplateInstance::switchType(const FullySpecifiedType &type) +{ + FullySpecifiedType previousType = _type; + _type = type; + return previousType; +} + +// types +void GenTemplateInstance::visit(PointerToMemberType * /*ty*/) +{ + Q_ASSERT(false); +} + +void GenTemplateInstance::visit(PointerType *ty) +{ + FullySpecifiedType elementType = subst(ty->elementType()); + _type.setType(_control->pointerType(elementType)); +} + +void GenTemplateInstance::visit(ReferenceType *ty) +{ + FullySpecifiedType elementType = subst(ty->elementType()); + _type.setType(_control->referenceType(elementType)); +} + +void GenTemplateInstance::visit(ArrayType *ty) +{ + FullySpecifiedType elementType = subst(ty->elementType()); + _type.setType(_control->arrayType(elementType, ty->size())); +} + +void GenTemplateInstance::visit(NamedType *ty) +{ + Name *name = ty->name(); + _type.setType(subst(name).type()); +} + +void GenTemplateInstance::visit(Function *ty) +{ + Name *name = ty->name(); + FullySpecifiedType returnType = subst(ty->returnType()); + + Function *fun = _control->newFunction(0, name); + fun->setScope(ty->scope()); + fun->setConst(ty->isConst()); + fun->setVolatile(ty->isVolatile()); + fun->setReturnType(returnType); + for (unsigned i = 0; i < ty->argumentCount(); ++i) { + Symbol *arg = ty->argumentAt(i); + FullySpecifiedType argTy = subst(arg->type()); + Argument *newArg = _control->newArgument(0, arg->name()); + newArg->setType(argTy); + fun->arguments()->enterSymbol(newArg); + } + _type.setType(fun); +} + +void GenTemplateInstance::visit(VoidType *) +{ /* nothing to do*/ } + +void GenTemplateInstance::visit(IntegerType *) +{ /* nothing to do*/ } + +void GenTemplateInstance::visit(FloatType *) +{ /* nothing to do*/ } + +void GenTemplateInstance::visit(Namespace *) +{ Q_ASSERT(false); } + +void GenTemplateInstance::visit(Class *) +{ Q_ASSERT(false); } + +void GenTemplateInstance::visit(Enum *) +{ Q_ASSERT(false); } + +// names +void GenTemplateInstance::visit(NameId *) +{ Q_ASSERT(false); } + +void GenTemplateInstance::visit(TemplateNameId *) +{ Q_ASSERT(false); } + +void GenTemplateInstance::visit(DestructorNameId *) +{ Q_ASSERT(false); } + +void GenTemplateInstance::visit(OperatorNameId *) +{ Q_ASSERT(false); } + +void GenTemplateInstance::visit(ConversionNameId *) +{ Q_ASSERT(false); } + +void GenTemplateInstance::visit(QualifiedNameId *) +{ Q_ASSERT(false); } + diff --git a/src/libs/cplusplus/GenTemplateInstance.h b/src/libs/cplusplus/GenTemplateInstance.h new file mode 100644 index 00000000000..a4845f8bc3d --- /dev/null +++ b/src/libs/cplusplus/GenTemplateInstance.h @@ -0,0 +1,58 @@ +#ifndef GENTEMPLATEINSTANCE_H +#define GENTEMPLATEINSTANCE_H + +#include +#include +#include + +#include +#include + +namespace CPlusPlus { + +class CPLUSPLUS_EXPORT GenTemplateInstance: protected TypeVisitor, protected NameVisitor +{ +public: + typedef QList< QPair > Substitution; + +public: + GenTemplateInstance(Control *control, const Substitution &substitution); + + FullySpecifiedType operator()(const FullySpecifiedType &ty); + +protected: + FullySpecifiedType subst(Name *name); + FullySpecifiedType subst(const FullySpecifiedType &ty); + + FullySpecifiedType switchType(const FullySpecifiedType &type); + + virtual void visit(PointerToMemberType * /*ty*/); + virtual void visit(PointerType *ty); + virtual void visit(ReferenceType *ty); + virtual void visit(ArrayType *ty); + virtual void visit(NamedType *ty); + virtual void visit(Function *ty); + virtual void visit(VoidType *); + virtual void visit(IntegerType *); + virtual void visit(FloatType *); + virtual void visit(Namespace *); + virtual void visit(Class *); + virtual void visit(Enum *); + + // names + virtual void visit(NameId *); + virtual void visit(TemplateNameId *); + virtual void visit(DestructorNameId *); + virtual void visit(OperatorNameId *); + virtual void visit(ConversionNameId *); + virtual void visit(QualifiedNameId *); + +private: + Control *_control; + FullySpecifiedType _type; + const Substitution _substitution; +}; + +} // end of namespace CPlusPlus + +#endif // GENTEMPLATEINSTANCE_H diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index aff38db4b3f..f89c2c9afd5 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -30,6 +30,7 @@ #include "ResolveExpression.h" #include "LookupContext.h" #include "Overview.h" +#include "GenTemplateInstance.h" #include #include @@ -49,151 +50,6 @@ using namespace CPlusPlus; namespace { -typedef QList< QPair > Substitution; - -class GenerateInstance: protected TypeVisitor, protected NameVisitor -{ - Control *_control; - FullySpecifiedType _type; - const Substitution _substitution; - -public: - GenerateInstance(Control *control, const Substitution &substitution) - : _control(control), - _substitution(substitution) - { } - - FullySpecifiedType operator()(const FullySpecifiedType &ty) - { return subst(ty); } - -protected: - FullySpecifiedType subst(Name *name) - { - if (TemplateNameId *t = name->asTemplateNameId()) { - QVarLengthArray args(t->templateArgumentCount()); - - for (unsigned i = 0; i < t->templateArgumentCount(); ++i) - args[i] = subst(t->templateArgumentAt(i)); - - TemplateNameId *n = _control->templateNameId(t->identifier(), - args.data(), args.size()); - - return FullySpecifiedType(_control->namedType(n)); - } else if (name->isQualifiedNameId()) { - // ### implement me - } - - for (int i = 0; i < _substitution.size(); ++i) { - const QPair s = _substitution.at(i); - if (name->isEqualTo(s.first)) - return s.second; - } - - return FullySpecifiedType(_control->namedType(name)); - } - - FullySpecifiedType subst(const FullySpecifiedType &ty) - { - FullySpecifiedType previousType = switchType(ty); - TypeVisitor::accept(ty.type()); - return switchType(previousType); - } - - FullySpecifiedType switchType(const FullySpecifiedType &type) - { - FullySpecifiedType previousType = _type; - _type = type; - return previousType; - } - - // types - virtual void visit(PointerToMemberType * /*ty*/) - { - Q_ASSERT(false); - } - - virtual void visit(PointerType *ty) - { - FullySpecifiedType elementType = subst(ty->elementType()); - _type.setType(_control->pointerType(elementType)); - } - - virtual void visit(ReferenceType *ty) - { - FullySpecifiedType elementType = subst(ty->elementType()); - _type.setType(_control->referenceType(elementType)); - } - - virtual void visit(ArrayType *ty) - { - FullySpecifiedType elementType = subst(ty->elementType()); - _type.setType(_control->arrayType(elementType, ty->size())); - } - - virtual void visit(NamedType *ty) - { - Name *name = ty->name(); - _type.setType(subst(name).type()); - } - - virtual void visit(Function *ty) - { - Name *name = ty->name(); - FullySpecifiedType returnType = subst(ty->returnType()); - - Function *fun = _control->newFunction(0, name); - fun->setScope(ty->scope()); - fun->setConst(ty->isConst()); - fun->setVolatile(ty->isVolatile()); - fun->setReturnType(returnType); - for (unsigned i = 0; i < ty->argumentCount(); ++i) { - Symbol *arg = ty->argumentAt(i); - FullySpecifiedType argTy = subst(arg->type()); - Argument *newArg = _control->newArgument(0, arg->name()); - newArg->setType(argTy); - fun->arguments()->enterSymbol(newArg); - } - _type.setType(fun); - } - - virtual void visit(VoidType *) - { /* nothing to do*/ } - - virtual void visit(IntegerType *) - { /* nothing to do*/ } - - virtual void visit(FloatType *) - { /* nothing to do*/ } - - virtual void visit(Namespace *) - { Q_ASSERT(false); } - - virtual void visit(Class *) - { Q_ASSERT(false); } - - virtual void visit(Enum *) - { Q_ASSERT(false); } - - // names - virtual void visit(NameId *) - { Q_ASSERT(false); } - - virtual void visit(TemplateNameId *) - { Q_ASSERT(false); } - - virtual void visit(DestructorNameId *) - { Q_ASSERT(false); } - - virtual void visit(OperatorNameId *) - { Q_ASSERT(false); } - - virtual void visit(ConversionNameId *) - { Q_ASSERT(false); } - - virtual void visit(QualifiedNameId *) - { Q_ASSERT(false); } -}; - template static QList<_Tp> removeDuplicates(const QList<_Tp> &results) { @@ -849,7 +705,7 @@ ResolveExpression::resolveMember(Name *memberName, Class *klass, unqualifiedNameId = q->unqualifiedNameId(); if (TemplateNameId *templId = unqualifiedNameId->asTemplateNameId()) { - Substitution subst; + GenTemplateInstance::Substitution subst; for (unsigned i = 0; i < templId->templateArgumentCount(); ++i) { FullySpecifiedType templArgTy = templId->templateArgumentAt(i); @@ -859,7 +715,7 @@ ResolveExpression::resolveMember(Name *memberName, Class *klass, templArgTy)); } - GenerateInstance inst(control(), subst); + GenTemplateInstance inst(control(), subst); ty = inst(ty); } diff --git a/src/libs/cplusplus/cplusplus-lib.pri b/src/libs/cplusplus/cplusplus-lib.pri index 34caa520a80..812dbe0c9a4 100644 --- a/src/libs/cplusplus/cplusplus-lib.pri +++ b/src/libs/cplusplus/cplusplus-lib.pri @@ -32,6 +32,7 @@ HEADERS += \ $$PWD/LookupContext.h \ $$PWD/CppBindings.h \ $$PWD/ASTParent.h \ + $$PWD/GenTemplateInstance.h \ $$PWD/CheckUndefinedSymbols.h \ $$PWD/PreprocessorClient.h \ $$PWD/PreprocessorEnvironment.h \ @@ -54,6 +55,7 @@ SOURCES += \ $$PWD/LookupContext.cpp \ $$PWD/CppBindings.cpp \ $$PWD/ASTParent.cpp \ + $$PWD/GenTemplateInstance.cpp \ $$PWD/CheckUndefinedSymbols.cpp \ $$PWD/PreprocessorClient.cpp \ $$PWD/PreprocessorEnvironment.cpp \ From 3c0ca8c18881bc26fd8946bc2651fa89b10a1329 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 26 Oct 2009 12:51:25 +0100 Subject: [PATCH 82/91] fakevim: prepare fix of QTextDocument::revision() based undo/redo. --- src/plugins/fakevim/fakevimhandler.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index d9f6a7c103e..8d990494883 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -78,6 +78,10 @@ #include +// FIXME: Restrict this as soon the availableUndoSteps has been merged to Qt +//#if QT_VERSION < 0x040600 +#define availableUndoSteps revision +//#endif //#define DEBUG_KEY 1 #if DEBUG_KEY @@ -88,7 +92,7 @@ //#define DEBUG_UNDO 1 #if DEBUG_UNDO -# define UNDO_DEBUG(s) qDebug() << << m_tc.document()->revision() << s +# define UNDO_DEBUG(s) qDebug() << << m_tc.document()->availableUndoSteps() << s #else # define UNDO_DEBUG(s) #endif @@ -661,7 +665,7 @@ void FakeVimHandler::Private::restoreWidget() EventResult FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &text) { - m_undoCursorPosition[m_tc.document()->revision()] = m_tc.position(); + m_undoCursorPosition[m_tc.document()->availableUndoSteps()] = m_tc.position(); //qDebug() << "KEY: " << key << text << "POS: " << m_tc.position(); if (m_mode == InsertMode) return handleInsertMode(key, unmodified, text); @@ -2728,30 +2732,32 @@ QWidget *FakeVimHandler::Private::editor() const void FakeVimHandler::Private::undo() { - int current = m_tc.document()->revision(); + int current = m_tc.document()->availableUndoSteps(); //endEditBlock(); EDITOR(undo()); //beginEditBlock(); - int rev = m_tc.document()->revision(); + int rev = m_tc.document()->availableUndoSteps(); if (current == rev) showBlackMessage(FakeVimHandler::tr("Already at oldest change")); else showBlackMessage(QString()); + if (m_undoCursorPosition.contains(rev)) m_tc.setPosition(m_undoCursorPosition[rev]); } void FakeVimHandler::Private::redo() { - int current = m_tc.document()->revision(); + int current = m_tc.document()->availableUndoSteps(); //endEditBlock(); EDITOR(redo()); //beginEditBlock(); - int rev = m_tc.document()->revision(); + int rev = m_tc.document()->availableUndoSteps(); if (rev == current) showBlackMessage(FakeVimHandler::tr("Already at newest change")); else showBlackMessage(QString()); + if (m_undoCursorPosition.contains(rev)) m_tc.setPosition(m_undoCursorPosition[rev]); } From a2b518412307a03addcd63ccd6b9bce4eacdd4a7 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 26 Oct 2009 13:45:01 +0100 Subject: [PATCH 83/91] Activate the completion only when the canonical symbol has a valid name. --- src/plugins/cppeditor/cppeditor.cpp | 13 ++++++++----- src/plugins/cpptools/cppfindreferences.cpp | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index d96a3f50087..e323ff0651a 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -762,10 +762,6 @@ void CPPEditor::findUsages() void CPPEditor::renameUsages() { - Core::EditorManager::instance()->showEditorInfoBar(QLatin1String("CppEditor.Rename"), - tr("This change cannot be undone."), - tr("Yes, I know what I am doing."), - this, SLOT(hideRenameNotification())); renameUsagesNow(); } @@ -777,7 +773,14 @@ void CPPEditor::hideRenameNotification() void CPPEditor::renameUsagesNow() { if (Symbol *canonicalSymbol = markSymbols()) { - m_modelManager->renameUsages(canonicalSymbol); + if (canonicalSymbol->identifier() != 0) { + Core::EditorManager::instance()->showEditorInfoBar(QLatin1String("CppEditor.Rename"), + tr("This change cannot be undone."), + tr("Yes, I know what I am doing."), + this, SLOT(hideRenameNotification())); + + m_modelManager->renameUsages(canonicalSymbol); + } } } diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index eb90a186786..06ae9790602 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -656,6 +656,9 @@ void CppFindReferences::renameUsages(Symbol *symbol) void CppFindReferences::findAll_helper(Symbol *symbol) { + if (! (symbol && symbol->identifier())) + return; + _resultWindow->popup(true); const Snapshot snapshot = _modelManager->snapshot(); From 485dec6d2b3347b87b307f21597a0f4dbd5c930f Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 26 Oct 2009 14:40:36 +0100 Subject: [PATCH 84/91] Link with cplusplus library. --- tests/auto/cplusplus/ast/ast.pro | 2 +- tests/auto/cplusplus/lookup/lookup.pro | 6 ++---- tests/auto/cplusplus/preprocessor/preprocessor.pro | 6 ++---- tests/auto/cplusplus/semantic/semantic.pro | 2 +- tests/auto/cplusplus/shared/shared.pri | 1 + tests/auto/cplusplus/shared/shared.pro | 6 +++--- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/auto/cplusplus/ast/ast.pro b/tests/auto/cplusplus/ast/ast.pro index 2f5a0a33eae..05435839c6c 100644 --- a/tests/auto/cplusplus/ast/ast.pro +++ b/tests/auto/cplusplus/ast/ast.pro @@ -1,6 +1,6 @@ TEMPLATE = app CONFIG += qt warn_on console depend_includepath -QT = core testlib +QT += testlib include(../shared/shared.pri) SOURCES += tst_ast.cpp TARGET=tst_$$TARGET diff --git a/tests/auto/cplusplus/lookup/lookup.pro b/tests/auto/cplusplus/lookup/lookup.pro index b80aa2f2b7b..9011a33f612 100644 --- a/tests/auto/cplusplus/lookup/lookup.pro +++ b/tests/auto/cplusplus/lookup/lookup.pro @@ -1,8 +1,6 @@ TEMPLATE = app CONFIG += qt warn_on console depend_includepath -QT = core testlib - -include(../../../../src/libs/cplusplus/cplusplus-lib.pri) - +QT += testlib +include(../shared/shared.pri) SOURCES += tst_lookup.cpp TARGET=tst_$$TARGET diff --git a/tests/auto/cplusplus/preprocessor/preprocessor.pro b/tests/auto/cplusplus/preprocessor/preprocessor.pro index 463de3ccfb3..bc7c98ea4ea 100644 --- a/tests/auto/cplusplus/preprocessor/preprocessor.pro +++ b/tests/auto/cplusplus/preprocessor/preprocessor.pro @@ -1,8 +1,6 @@ TEMPLATE = app CONFIG += qt warn_on console depend_includepath -QT = core testlib +QT += testlib TARGET = tst_$$TARGET - -include(../../../../src/libs/cplusplus/cplusplus-lib.pri) - +include(../shared/shared.pri) SOURCES += tst_preprocessor.cpp diff --git a/tests/auto/cplusplus/semantic/semantic.pro b/tests/auto/cplusplus/semantic/semantic.pro index 09f80ab27ab..2198ab78c73 100644 --- a/tests/auto/cplusplus/semantic/semantic.pro +++ b/tests/auto/cplusplus/semantic/semantic.pro @@ -1,6 +1,6 @@ TEMPLATE = app CONFIG += qt warn_on console depend_includepath -QT = core testlib +QT += testlib include(../shared/shared.pri) SOURCES += tst_semantic.cpp diff --git a/tests/auto/cplusplus/shared/shared.pri b/tests/auto/cplusplus/shared/shared.pri index d0c398dae80..80dab035ba8 100644 --- a/tests/auto/cplusplus/shared/shared.pri +++ b/tests/auto/cplusplus/shared/shared.pri @@ -1,4 +1,5 @@ INCLUDEPATH += $$PWD/../../../../src/shared/cplusplus +INCLUDEPATH += $$PWD/../../../../src/libs/cplusplus DEPENDPATH += $$INCLUDEPATH . LIBS += -L$$PWD -lCPlusPlusTestSupport diff --git a/tests/auto/cplusplus/shared/shared.pro b/tests/auto/cplusplus/shared/shared.pro index f8eb83829da..72f904a9799 100644 --- a/tests/auto/cplusplus/shared/shared.pro +++ b/tests/auto/cplusplus/shared/shared.pro @@ -1,8 +1,8 @@ TEMPLATE = lib TARGET = CPlusPlusTestSupport -CONFIG += static -QT = core +CONFIG += static depend_includepath +QT = core gui DESTDIR = $$PWD +include($$PWD/../../../../src/libs/cplusplus/cplusplus-lib.pri) -include($$PWD/../../../../src/shared/cplusplus/cplusplus.pri) From 72da848073bfa895e25a2481239f03d58c486329 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 26 Oct 2009 14:45:58 +0100 Subject: [PATCH 85/91] We expect failures in tst_Semantic::pointer_to_function_1 --- tests/auto/cplusplus/semantic/tst_semantic.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp index bf113873fe4..cf2f6e23180 100644 --- a/tests/auto/cplusplus/semantic/tst_semantic.cpp +++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp @@ -217,7 +217,6 @@ void tst_Semantic::nested_class_1() Identifier *objectId = classObjectNameId->identifier(); QCOMPARE(QByteArray(objectId->chars(), objectId->size()), QByteArray("Object")); QCOMPARE(classObject->baseClassCount(), 0U); - QEXPECT_FAIL("", "Requires support for forward classes", Continue); QCOMPARE(classObject->members()->symbolCount(), 2U); Class *classObjectData = doc->globals->symbolAt(1)->asClass(); @@ -383,7 +382,10 @@ void tst_Semantic::pointer_to_function_1() Function *funTy = ptrTy->elementType()->asFunctionType(); QVERIFY(funTy); + QEXPECT_FAIL("", "Requires initialize enclosing scope of pointer-to-function symbols", Continue); QVERIFY(funTy->scope()); + + QEXPECT_FAIL("", "Requires initialize enclosing scope of pointer-to-function symbols", Continue); QCOMPARE(funTy->scope(), decl->scope()); } From 1f61dbc3802b73f5ec31a629ff22c92fa01164b1 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 26 Oct 2009 15:00:56 +0100 Subject: [PATCH 86/91] Test GenTemplateInstance. --- .../auto/cplusplus/semantic/tst_semantic.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp index cf2f6e23180..4e1586e68b5 100644 --- a/tests/auto/cplusplus/semantic/tst_semantic.cpp +++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include using namespace CPlusPlus; @@ -101,6 +103,8 @@ private slots: void const_1(); void const_2(); void pointer_to_function_1(); + + void template_instance_1(); }; void tst_Semantic::function_declaration_1() @@ -389,5 +393,29 @@ void tst_Semantic::pointer_to_function_1() QCOMPARE(funTy->scope(), decl->scope()); } +void tst_Semantic::template_instance_1() +{ + QSharedPointer doc = document("void append(const _Tp &value);"); + QCOMPARE(doc->errorCount, 0U); + QCOMPARE(doc->globals->symbolCount(), 1U); + + Declaration *decl = doc->globals->symbolAt(0)->asDeclaration(); + QVERIFY(decl); + + GenTemplateInstance::Substitution subst; + Name *nameTp = control.nameId(control.findOrInsertIdentifier("_Tp")); + FullySpecifiedType intTy(control.integerType(IntegerType::Int)); + subst.append(qMakePair(nameTp, intTy)); + + GenTemplateInstance inst(&control, subst); + FullySpecifiedType genTy = inst(decl->type()); + + Overview oo; + oo.setShowReturnTypes(true); + + const QString genDecl = oo.prettyType(genTy); + QCOMPARE(genDecl, QString::fromLatin1("void(const int &)")); +} + QTEST_APPLESS_MAIN(tst_Semantic) #include "tst_semantic.moc" From 0ed33aa8a557820638f5c6a5ed4611ff2464aa1e Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 26 Oct 2009 15:07:00 +0100 Subject: [PATCH 87/91] Test ExpressionUnderCursor --- .../auto/cplusplus/semantic/tst_semantic.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp index 4e1586e68b5..827a227f053 100644 --- a/tests/auto/cplusplus/semantic/tst_semantic.cpp +++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp @@ -1,6 +1,8 @@ #include #include +#include +#include #include #include @@ -14,6 +16,7 @@ #include #include #include +#include using namespace CPlusPlus; @@ -105,6 +108,8 @@ private slots: void pointer_to_function_1(); void template_instance_1(); + + void expression_under_cursor_1(); }; void tst_Semantic::function_declaration_1() @@ -417,5 +422,21 @@ void tst_Semantic::template_instance_1() QCOMPARE(genDecl, QString::fromLatin1("void(const int &)")); } +void tst_Semantic::expression_under_cursor_1() +{ + const QString plainText = "void *ptr = foo(10, bar"; + + QTextDocument textDocument; + textDocument.setPlainText(plainText); + + QTextCursor tc(&textDocument); + tc.movePosition(QTextCursor::End); + + ExpressionUnderCursor expressionUnderCursor; + const QString expression = expressionUnderCursor(tc); + + QCOMPARE(expression, QString("bar")); +} + QTEST_APPLESS_MAIN(tst_Semantic) #include "tst_semantic.moc" From fe9b4458c63fdabfb48afda4d7fe4db343a2abe6 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 26 Oct 2009 15:21:21 +0100 Subject: [PATCH 88/91] Fixed the #include directive. --- src/shared/cplusplus/ASTfwd.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/shared/cplusplus/ASTfwd.h b/src/shared/cplusplus/ASTfwd.h index f97bae2a84c..e0a5c59d9a6 100644 --- a/src/shared/cplusplus/ASTfwd.h +++ b/src/shared/cplusplus/ASTfwd.h @@ -49,8 +49,7 @@ #ifndef CPLUSPLUS_ASTFWD_H #define CPLUSPLUS_ASTFWD_H -#include - +#include "CPlusPlusForwardDeclarations.h" namespace CPlusPlus { From cd3435a9835dda6c0d5cc2295c5642c47045caca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Mon, 26 Oct 2009 15:31:43 +0100 Subject: [PATCH 89/91] Don't needlessly call updateProjectInfo() Should not be necessary when nothing changed in the project info. This also fixes a problem where include file scanning happened twice after saving a pro file. Reviewed-by: Roberto Raggi --- src/plugins/cpptools/cppmodelmanager.cpp | 3 +-- src/plugins/qt4projectmanager/qt4project.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 1d886920566..75f8f743b38 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -331,9 +331,8 @@ void CppPreprocessor::resetEnvironment() bool CppPreprocessor::includeFile(const QString &absoluteFilePath, QString *result) { - if (absoluteFilePath.isEmpty() || m_included.contains(absoluteFilePath)) { + if (absoluteFilePath.isEmpty() || m_included.contains(absoluteFilePath)) return true; - } if (m_workingCopy.contains(absoluteFilePath)) { m_included.insert(absoluteFilePath); diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index c58793bed76..96c080087a8 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -698,7 +698,7 @@ void Qt4Project::updateCodeModel() pinfo.includePaths == allIncludePaths && pinfo.frameworkPaths == allFrameworkPaths && pinfo.sourceFiles == files) { - modelmanager->updateProjectInfo(pinfo); + // Nothing to update... } else { if (pinfo.defines != predefinedMacros || pinfo.includePaths != allIncludePaths || From c6e9c041a76587c68aa6d866288e2e6093db5139 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Mon, 26 Oct 2009 15:35:37 +0100 Subject: [PATCH 90/91] Do not require QTDIR to be set. Reviewed-By: Oswald Buddenhagen --- doc/doc.pri | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/doc.pri b/doc/doc.pri index b15059163f9..5c93f3d3a55 100644 --- a/doc/doc.pri +++ b/doc/doc.pri @@ -1,15 +1,14 @@ -unix:QDOC_BIN = $$(QTDIR)/bin/qdoc3 -win32:QDOC_BIN = $$(QTDIR)/bin/qdoc3.exe +QDOC_BIN = $$[QT_INSTALL_BINS]/qdoc3 win32:QDOC_BIN = $$replace(QDOC_BIN, "/", "\\") unix { QDOC = SRCDIR=$$PWD OUTDIR=$$OUT_PWD/doc/html $$QDOC_BIN - HELPGENERATOR = $$(QTDIR)/bin/qhelpgenerator + HELPGENERATOR = $$[QT_INSTALL_BINS]/qhelpgenerator } else { QDOC = set SRCDIR=$$PWD&& set OUTDIR=$$OUT_PWD/doc/html&& $$QDOC_BIN # Always run qhelpgenerator inside its own cmd; this is a workaround for # an unusual bug which causes qhelpgenerator.exe to do nothing - HELPGENERATOR = cmd /C $$(QTDIR)\bin\qhelpgenerator.exe + HELPGENERATOR = cmd /C $$replace($$list($$[QT_INSTALL_BINS]/qhelpgenerator.exe), "/", "\\") } QHP_FILE = $$OUT_PWD/doc/html/qtcreator.qhp From 4091efb47f57e5c15b05089792389d9a512ad6e5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 26 Oct 2009 15:37:09 +0100 Subject: [PATCH 91/91] S60: Provide a MessageBox for starting serial communication as well. Generalize the concept of the Bluetooth starter, extract base class BaseCommunicationStarter that can be used to start a serial communication without further resources (listener) as well. Introduce convenience functions for both types. Note: This will only work for COM-ports that are not used otherwise by the operating system. --- .../gdb/s60debuggerbluetoothstarter.cpp | 20 +++++ .../gdb/s60debuggerbluetoothstarter.h | 18 ++++- src/plugins/debugger/gdb/trkgdbadapter.cpp | 40 ++++------ src/plugins/debugger/gdb/trkoptions.h | 1 + .../qt-s60/s60devicerunconfiguration.cpp | 33 ++++---- .../s60devicerunconfigurationwidget.cpp | 32 ++++---- .../qt-s60/s60runconfigbluetoothstarter.cpp | 21 +++++ .../qt-s60/s60runconfigbluetoothstarter.h | 18 ++++- src/shared/trk/bluetoothlistener_gui.cpp | 70 +++++++++++------ src/shared/trk/bluetoothlistener_gui.h | 39 +++++++--- src/shared/trk/communicationstarter.cpp | 76 ++++++++++++------- src/shared/trk/communicationstarter.h | 67 ++++++++++------ src/shared/trk/trk.pri | 1 + 13 files changed, 291 insertions(+), 145 deletions(-) diff --git a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp index 8dcfa4b9042..ad2869aac58 100644 --- a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp +++ b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp @@ -30,6 +30,7 @@ #include "s60debuggerbluetoothstarter.h" #include "bluetoothlistener.h" #include "debuggermanager.h" +#include "trkoptions.h" namespace Debugger { namespace Internal { @@ -48,5 +49,24 @@ trk::BluetoothListener *S60DebuggerBluetoothStarter::createListener() return rc; } +trk::PromptStartCommunicationResult +S60DebuggerBluetoothStarter::startCommunication(const TrkDevicePtr &trkDevice, + const QString &device, + int communicationType, + QWidget *msgBoxParent, + QString *errorMessage) +{ + // Bluetooth? + if (communicationType == TrkOptions::BlueTooth) { + S60DebuggerBluetoothStarter bluetoothStarter(trkDevice); + bluetoothStarter.setDevice(device); + return trk::promptStartBluetooth(bluetoothStarter, msgBoxParent, errorMessage); + } + // Serial + BaseCommunicationStarter serialStarter(trkDevice); + serialStarter.setDevice(device); + return trk::promptStartSerial(serialStarter, msgBoxParent, errorMessage); +} + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h index 226e00072ac..234afa2c2c9 100644 --- a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h +++ b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h @@ -31,6 +31,7 @@ #define S60DEBUGGERBLUETOOTHSTARTER_H #include "communicationstarter.h" +#include "bluetoothlistener_gui.h" namespace Debugger { namespace Internal { @@ -38,15 +39,24 @@ namespace Internal { /* S60DebuggerBluetoothStarter: Creates a listener in 'Listen' mode * parented on the Debugger manager which outputs to the debugger window. * Note: This is a "last resort" starter, normally, the run configuration - * should have already started a listener. */ + * should have already started a listener. + * Provides a static convenience to prompt for both connection types. */ class S60DebuggerBluetoothStarter : public trk::AbstractBluetoothStarter -{ +{ public: - explicit S60DebuggerBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); + static trk::PromptStartCommunicationResult + startCommunication(const TrkDevicePtr &trkDevice, + const QString &device, + int communicationType, + QWidget *msgBoxParent, + QString *errorMessage); -protected: +protected: virtual trk::BluetoothListener *createListener(); + +private: + explicit S60DebuggerBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); }; } // namespace Internal diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp index e954396c30a..bf23a09eab5 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp @@ -1512,30 +1512,22 @@ void TrkGdbAdapter::startAdapter() debugMessage(_("TRYING TO START ADAPTER")); logMessage(QLatin1String("### Starting TrkGdbAdapter")); m_trkDevice->setSerialFrame(effectiveTrkDeviceType() != TrkOptions::BlueTooth); - // Prompt the user for a bluetooth connection - const QString device = effectiveTrkDevice(); - QString message; - if (effectiveTrkDeviceType() == TrkOptions::BlueTooth) { - S60DebuggerBluetoothStarter starter(m_trkDevice); - starter.setDevice(device); - const trk::StartBluetoothGuiResult src = trk::startBluetoothGui(starter, 0, &message); - switch (src) { - case trk::BluetoothGuiConnected: - break; - case trk::BluetoothGuiCanceled: - emit adapterStartFailed(message, QString()); - return; - case trk::BluetoothGuiError: - emit adapterStartFailed(message, TrkOptionsPage::settingsId()); - return; - }; - } else { - if (!m_trkDevice->isOpen() && !m_trkDevice->open(device, &message)) { - message = tr("Failed to connect to %1: %2\nCheck whether TRK is running.").arg(device).arg(message); - logMessage(message); - emit adapterStartFailed(message, TrkOptionsPage::settingsId()); - return; - } + // Prompt the user to start communication + QString message; + const trk::PromptStartCommunicationResult src = + S60DebuggerBluetoothStarter::startCommunication(m_trkDevice, + effectiveTrkDevice(), + effectiveTrkDeviceType(), + 0, &message); + switch (src) { + case trk::PromptStartCommunicationConnected: + break; + case trk::PromptStartCommunicationCanceled: + emit adapterStartFailed(message, QString()); + return; + case trk::PromptStartCommunicationError: + emit adapterStartFailed(message, TrkOptionsPage::settingsId()); + return; } QTC_ASSERT(m_gdbServer == 0, delete m_gdbServer); diff --git a/src/plugins/debugger/gdb/trkoptions.h b/src/plugins/debugger/gdb/trkoptions.h index f4a288fe074..470b66ab52f 100644 --- a/src/plugins/debugger/gdb/trkoptions.h +++ b/src/plugins/debugger/gdb/trkoptions.h @@ -46,6 +46,7 @@ namespace Internal { struct TrkOptions { + // Matches the communication enumeration from the S60 devices listener. enum Mode { Serial, BlueTooth }; TrkOptions(); diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index d547c3b6d83..0804a9fe258 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -582,21 +582,24 @@ void S60DeviceRunControlBase::signsisProcessFinished() initLauncher(runFileName, m_launcher); emit addToOutputWindow(this, tr("Package: %1\nDeploying application to '%2'...").arg(lsFile(copySrc), m_serialPortFriendlyName)); QString errorMessage; - // Prompt the user to start up the Blue tooth connection - if (m_communicationType == BlueToothCommunication) { - S60RunConfigBluetoothStarter starter(m_launcher->trkDevice()); - switch (trk::startBluetoothGui(starter, 0, &errorMessage)) { - case trk::BluetoothGuiConnected: - break; - case trk::BluetoothGuiCanceled: - case trk::BluetoothGuiError: - delete m_launcher; - m_launcher = 0; - error(this, errorMessage); - emit finished(); - return; - }; - } + // Prompt the user to start up the Blue tooth connection + const trk::PromptStartCommunicationResult src = + S60RunConfigBluetoothStarter::startCommunication(m_launcher->trkDevice(), + m_serialPortName, + m_communicationType, 0, + &errorMessage); + switch (src) { + case trk::PromptStartCommunicationConnected: + break; + case trk::PromptStartCommunicationCanceled: + case trk::PromptStartCommunicationError: + delete m_launcher; + m_launcher = 0; + error(this, errorMessage); + emit finished(); + return; + }; + if (!m_launcher->startServer(&errorMessage)) { delete m_launcher; m_launcher = 0; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp index 0b1554b1bae..46ebf4f0443 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfigurationwidget.cpp @@ -302,22 +302,22 @@ bool S60DeviceRunConfigurationWidget::getDeviceInfo(QString *message) const CommunicationDevice commDev = currentDevice(); launcher->setSerialFrame(commDev.type == SerialPortCommunication); launcher->setTrkServerName(commDev.portName); - // Prompt the user to start - if (commDev.type == BlueToothCommunication) { - S60RunConfigBluetoothStarter starter(launcher->trkDevice()); - starter.setDevice(launcher->trkServerName()); - const trk::StartBluetoothGuiResult src = trk::startBluetoothGui(starter, this, message); - switch (src) { - case trk::BluetoothGuiConnected: - break; - case trk::BluetoothGuiCanceled: - launcher->deleteLater(); - return true; - case trk::BluetoothGuiError: - launcher->deleteLater(); - return false; - }; - } + // Prompt user + const trk::PromptStartCommunicationResult src = + S60RunConfigBluetoothStarter::startCommunication(launcher->trkDevice(), + commDev.portName, + commDev.type, this, + message); + switch (src) { + case trk::PromptStartCommunicationConnected: + break; + case trk::PromptStartCommunicationCanceled: + launcher->deleteLater(); + return true; + case trk::PromptStartCommunicationError: + launcher->deleteLater(); + return false; + }; if (!launcher->startServer(message)) { launcher->deleteLater(); return false; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp index 1481dcacbc9..b12aa0f1d29 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp @@ -29,6 +29,7 @@ #include "s60runconfigbluetoothstarter.h" #include "bluetoothlistener.h" +#include "serialdevicelister.h" #include #include @@ -49,5 +50,25 @@ trk::BluetoothListener *S60RunConfigBluetoothStarter::createListener() connect(rc, SIGNAL(message(QString)), core->messageManager(), SLOT(printToOutputPane(QString))); return rc; } + +trk::PromptStartCommunicationResult +S60RunConfigBluetoothStarter::startCommunication(const TrkDevicePtr &trkDevice, + const QString &device, + int communicationType, + QWidget *msgBoxParent, + QString *errorMessage) +{ + // Bluetooth? + if (communicationType == BlueToothCommunication) { + S60RunConfigBluetoothStarter bluetoothStarter(trkDevice); + bluetoothStarter.setDevice(device); + return trk::promptStartBluetooth(bluetoothStarter, msgBoxParent, errorMessage); + } + // Serial + BaseCommunicationStarter serialStarter(trkDevice); + serialStarter.setDevice(device); + return trk::promptStartSerial(serialStarter, msgBoxParent, errorMessage); +} + } // namespace Internal } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h index 0da8817b323..70ea0123f5d 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h @@ -31,20 +31,34 @@ #define S60RUNCONFIGBLUETOOTHSTARTER_H #include "communicationstarter.h" +#include "bluetoothlistener_gui.h" namespace Qt4ProjectManager { namespace Internal { /* S60RunConfigBluetoothStarter: Creates a listener in 'Listen' mode - * parented on the Qt Creator core which outputs to the message manager. */ + * parented on the Qt Creator core which outputs to the message manager. + * Provides a static convenience to prompt for both connection types. */ class S60RunConfigBluetoothStarter : public trk::AbstractBluetoothStarter { public: - explicit S60RunConfigBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); + typedef trk::AbstractBluetoothStarter::TrkDevicePtr TrkDevicePtr; + + // Convenience function to start communication depending on type, + // passing on the right messages. + static trk::PromptStartCommunicationResult + startCommunication(const TrkDevicePtr &trkDevice, + const QString &device, + int communicationType, + QWidget *msgBoxParent, + QString *errorMessage); protected: virtual trk::BluetoothListener *createListener(); + +private: + explicit S60RunConfigBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); }; } // namespace Internal diff --git a/src/shared/trk/bluetoothlistener_gui.cpp b/src/shared/trk/bluetoothlistener_gui.cpp index ee21c82a7c5..edcb40a9a52 100644 --- a/src/shared/trk/bluetoothlistener_gui.cpp +++ b/src/shared/trk/bluetoothlistener_gui.cpp @@ -38,38 +38,62 @@ namespace trk { -StartBluetoothGuiResult - startBluetoothGui(AbstractBluetoothStarter &starter, - QWidget *msgBoxParent, - QString *errorMessage) +PromptStartCommunicationResult + promptStartCommunication(BaseCommunicationStarter &starter, + const QString &msgBoxTitle, + const QString &msgBoxText, + QWidget *msgBoxParent, + QString *errorMessage) { errorMessage->clear(); + // Initial connection attempt. switch (starter.start()) { - case AbstractBluetoothStarter::Started: + case BaseCommunicationStarter::Started: break; - case AbstractBluetoothStarter::ConnectionSucceeded: - return BluetoothGuiConnected; - case AbstractBluetoothStarter::StartError: + case BaseCommunicationStarter::ConnectionSucceeded: + return PromptStartCommunicationConnected; + case BaseCommunicationStarter::StartError: *errorMessage = starter.errorString(); - return BluetoothGuiError; + return PromptStartCommunicationError; } - // Run the starter with the event loop of a message box, close it - // with the finished signals. - const QString title = QCoreApplication::translate("trk::startBluetoothGui", "Waiting for Bluetooth Connection"); - const QString message = QCoreApplication::translate("trk::startBluetoothGui", "Connecting to %1...").arg(starter.device()); - QMessageBox messageBox(QMessageBox::Information, title, message, QMessageBox::Cancel, msgBoxParent); + // Run the starter with the event loop of a message box, have the box + // closed by the signals of the starter. + QMessageBox messageBox(QMessageBox::Information, msgBoxTitle, msgBoxText, QMessageBox::Cancel, msgBoxParent); QObject::connect(&starter, SIGNAL(connected()), &messageBox, SLOT(close())); QObject::connect(&starter, SIGNAL(timeout()), &messageBox, SLOT(close())); - messageBox.exec(); - // Only starter.state() is reliable here. - if (starter.state() == AbstractBluetoothStarter::Running) { - *errorMessage = QCoreApplication::translate("trk::startBluetoothGui", "Connection on %1 canceled.").arg(starter.device()); - return BluetoothGuiCanceled; - } - if (starter.state() != AbstractBluetoothStarter::Connected) { + messageBox.exec(); + // Only starter.state() is reliable here to obtain the state. + switch (starter.state()) { + case AbstractBluetoothStarter::Running: + *errorMessage = QCoreApplication::translate("trk::promptStartCommunication", "Connection on %1 canceled.").arg(starter.device()); + return PromptStartCommunicationCanceled; + case AbstractBluetoothStarter::TimedOut: *errorMessage = starter.errorString(); - return BluetoothGuiError; + return PromptStartCommunicationError; + case AbstractBluetoothStarter::Connected: + break; } - return BluetoothGuiConnected; + return PromptStartCommunicationConnected; } + +PromptStartCommunicationResult + promptStartSerial(BaseCommunicationStarter &starter, + QWidget *msgBoxParent, + QString *errorMessage) +{ + const QString title = QCoreApplication::translate("trk::promptStartCommunication", "Waiting for TRK"); + const QString message = QCoreApplication::translate("trk::promptStartCommunication", "Waiting for TRK to start on %1...").arg(starter.device()); + return promptStartCommunication(starter, title, message, msgBoxParent, errorMessage); +} + +PromptStartCommunicationResult + promptStartBluetooth(BaseCommunicationStarter &starter, + QWidget *msgBoxParent, + QString *errorMessage) +{ + const QString title = QCoreApplication::translate("trk::promptStartCommunication", "Waiting for Bluetooth Connection"); + const QString message = QCoreApplication::translate("trk::promptStartCommunication", "Connecting to %1...").arg(starter.device()); + return promptStartCommunication(starter, title, message, msgBoxParent, errorMessage); +} + } // namespace trk diff --git a/src/shared/trk/bluetoothlistener_gui.h b/src/shared/trk/bluetoothlistener_gui.h index 2a7c57e291a..83cce425ea3 100644 --- a/src/shared/trk/bluetoothlistener_gui.h +++ b/src/shared/trk/bluetoothlistener_gui.h @@ -37,22 +37,39 @@ class QWidget; QT_END_NAMESPACE namespace trk { - class AbstractBluetoothStarter; +class BaseCommunicationStarter; - /* startBluetoothGui(): Prompt the user to start a Bluetooth - * connection with a message box he can cancel. Pass in - * the starter with device and parameters set up. */ +/* promptStartCommunication(): Convenience functions that + * prompt the user to start a communication (launching or + * connecting TRK) using a modal message box in which they can cancel. + * Pass in the starter with device and parameters set up. */ - enum StartBluetoothGuiResult { - BluetoothGuiConnected, - BluetoothGuiCanceled, - BluetoothGuiError - }; +enum PromptStartCommunicationResult { + PromptStartCommunicationConnected, + PromptStartCommunicationCanceled, + PromptStartCommunicationError +}; - StartBluetoothGuiResult - startBluetoothGui(AbstractBluetoothStarter &starter, +PromptStartCommunicationResult + promptStartCommunication(BaseCommunicationStarter &starter, + const QString &msgBoxTitle, + const QString &msgBoxText, + QWidget *msgBoxParent, + QString *errorMessage); + +// Convenience to start a serial connection (messages prompting +// to launch Trk). +PromptStartCommunicationResult + promptStartSerial(BaseCommunicationStarter &starter, QWidget *msgBoxParent, QString *errorMessage); + +// Convenience to start blue tooth connection (messages +// prompting to connect). +PromptStartCommunicationResult + promptStartBluetooth(BaseCommunicationStarter &starter, + QWidget *msgBoxParent, + QString *errorMessage); } // namespace trk #endif // BLUETOOTHLISTENER_GUI_H diff --git a/src/shared/trk/communicationstarter.cpp b/src/shared/trk/communicationstarter.cpp index 58a954cd26b..b425db25062 100644 --- a/src/shared/trk/communicationstarter.cpp +++ b/src/shared/trk/communicationstarter.cpp @@ -35,11 +35,12 @@ #include namespace trk { -// --------------- AbstractBluetoothStarter -struct AbstractBluetoothStarterPrivate { - explicit AbstractBluetoothStarterPrivate(const AbstractBluetoothStarter::TrkDevicePtr &d); - const AbstractBluetoothStarter::TrkDevicePtr trkDevice; +// --------------- AbstractBluetoothStarter +struct BaseCommunicationStarterPrivate { + explicit BaseCommunicationStarterPrivate(const BaseCommunicationStarter::TrkDevicePtr &d); + + const BaseCommunicationStarter::TrkDevicePtr trkDevice; BluetoothListener *listener; QTimer *timer; int intervalMS; @@ -47,11 +48,10 @@ struct AbstractBluetoothStarterPrivate { int n; QString device; QString errorString; - AbstractBluetoothStarter::State state; + BaseCommunicationStarter::State state; }; -AbstractBluetoothStarterPrivate::AbstractBluetoothStarterPrivate(const AbstractBluetoothStarter::TrkDevicePtr &d) : - +BaseCommunicationStarterPrivate::BaseCommunicationStarterPrivate(const BaseCommunicationStarter::TrkDevicePtr &d) : trkDevice(d), listener(0), timer(0), @@ -59,32 +59,38 @@ AbstractBluetoothStarterPrivate::AbstractBluetoothStarterPrivate(const AbstractB attempts(-1), n(0), device(QLatin1String("/dev/rfcomm0")), - state(AbstractBluetoothStarter::TimedOut) + state(BaseCommunicationStarter::TimedOut) { } -AbstractBluetoothStarter::AbstractBluetoothStarter(const TrkDevicePtr &trkDevice, QObject *parent) : +BaseCommunicationStarter::BaseCommunicationStarter(const TrkDevicePtr &trkDevice, QObject *parent) : QObject(parent), - d(new AbstractBluetoothStarterPrivate(trkDevice)) + d(new BaseCommunicationStarterPrivate(trkDevice)) { } -AbstractBluetoothStarter::~AbstractBluetoothStarter() +BaseCommunicationStarter::~BaseCommunicationStarter() { stopTimer(); delete d; } -void AbstractBluetoothStarter::stopTimer() +void BaseCommunicationStarter::stopTimer() { if (d->timer && d->timer->isActive()) d->timer->stop(); } -AbstractBluetoothStarter::StartResult AbstractBluetoothStarter::start() +bool BaseCommunicationStarter::initializeStartupResources(QString *errorMessage) +{ + errorMessage->clear(); + return true; +} + +BaseCommunicationStarter::StartResult BaseCommunicationStarter::start() { if (state() == Running) { - d->errorString = QLatin1String("Internal error, attempt to re-start AbstractBluetoothStarter.\n"); + d->errorString = QLatin1String("Internal error, attempt to re-start BaseCommunicationStarter.\n"); return StartError; } // Before we instantiate timers, and such, try to open the device, @@ -92,10 +98,9 @@ AbstractBluetoothStarter::StartResult AbstractBluetoothStarter::start() // 'Watch' mode if (d->trkDevice->open(d->device , &(d->errorString))) return ConnectionSucceeded; - // Fire up the listener + // Pull up resources for next attempt d->n = 0; - d->listener = createListener(); - if (!d->listener->start(d->device, &(d->errorString))) + if (!initializeStartupResources(&(d->errorString))) return StartError; // Start timer if (!d->timer) { @@ -109,49 +114,49 @@ AbstractBluetoothStarter::StartResult AbstractBluetoothStarter::start() return Started; } -AbstractBluetoothStarter::State AbstractBluetoothStarter::state() const +BaseCommunicationStarter::State BaseCommunicationStarter::state() const { return d->state; } -int AbstractBluetoothStarter::intervalMS() const +int BaseCommunicationStarter::intervalMS() const { return d->intervalMS; } -void AbstractBluetoothStarter::setIntervalMS(int i) +void BaseCommunicationStarter::setIntervalMS(int i) { d->intervalMS = i; if (d->timer) d->timer->setInterval(i); } -int AbstractBluetoothStarter::attempts() const +int BaseCommunicationStarter::attempts() const { return d->attempts; } -void AbstractBluetoothStarter::setAttempts(int a) +void BaseCommunicationStarter::setAttempts(int a) { d->attempts = a; } -QString AbstractBluetoothStarter::device() const +QString BaseCommunicationStarter::device() const { return d->device; } -void AbstractBluetoothStarter::setDevice(const QString &dv) +void BaseCommunicationStarter::setDevice(const QString &dv) { d->device = dv; } -QString AbstractBluetoothStarter::errorString() const +QString BaseCommunicationStarter::errorString() const { return d->errorString; } -void AbstractBluetoothStarter::slotTimer() +void BaseCommunicationStarter::slotTimer() { ++d->n; // Check for timeout @@ -166,17 +171,32 @@ void AbstractBluetoothStarter::slotTimer() if (d->trkDevice->open(d->device , &(d->errorString))) { stopTimer(); const QString msg = tr("%1: Connection attempt %2 succeeded.").arg(d->device).arg(d->n); - d->listener->emitMessage(msg); + emit message(msg); d->state = Connected; emit connected(); } else { const QString msg = tr("%1: Connection attempt %2 failed: %3 (retrying)...") .arg(d->device).arg(d->n).arg(d->errorString); - d->listener->emitMessage(msg); + emit message(msg); } } } +// --------------- AbstractBluetoothStarter + +AbstractBluetoothStarter::AbstractBluetoothStarter(const TrkDevicePtr &trkDevice, QObject *parent) : + BaseCommunicationStarter(trkDevice, parent) +{ +} + +bool AbstractBluetoothStarter::initializeStartupResources(QString *errorMessage) +{ + // Create the listener and forward messages to it. + BluetoothListener *listener = createListener(); + connect(this, SIGNAL(message(QString)), listener, SLOT(emitMessage(QString))); + return listener->start(device(), errorMessage); +} + // -------- ConsoleBluetoothStarter ConsoleBluetoothStarter::ConsoleBluetoothStarter(const TrkDevicePtr &trkDevice, QObject *listenerParent, diff --git a/src/shared/trk/communicationstarter.h b/src/shared/trk/communicationstarter.h index e90578dc171..7b89e2472ed 100644 --- a/src/shared/trk/communicationstarter.h +++ b/src/shared/trk/communicationstarter.h @@ -36,25 +36,28 @@ namespace trk { class TrkDevice; class BluetoothListener; -struct AbstractBluetoothStarterPrivate; +struct BaseCommunicationStarterPrivate; -/* AbstractBluetoothStarter: Repeatedly tries to open a trk device - * until a connection succeeds, allowing to do something else in the - * foreground (local event loop or asynchronous operation). - * Note that in case a Listener is already running in watch mode, it might - * also happen that connection succeeds immediately. - * Implementations must provide a factory function that creates and sets up the - * listener (mode, message connection, etc). */ +/* BaseCommunicationStarter: A QObject that repeatedly tries to open a + * trk device until a connection succeeds or a timeout occurs (emitting + * signals), allowing to do something else in the foreground (local event loop + * [say QMessageBox] or some asynchronous operation). If the initial + * connection attempt in start() fails, the + * virtual initializeStartupResources() is called to initialize resources + * required to pull up the communication (namely Bluetooth listeners). + * The base class can be used as is to prompt the user to launch TRK for a serial + * communication as this requires no further resource setup. */ -class AbstractBluetoothStarter : public QObject { +class BaseCommunicationStarter : public QObject { Q_OBJECT - Q_DISABLE_COPY(AbstractBluetoothStarter) + Q_DISABLE_COPY(BaseCommunicationStarter) public: - typedef QSharedPointer TrkDevicePtr; + typedef QSharedPointer TrkDevicePtr; enum State { Running, Connected, TimedOut }; - virtual ~AbstractBluetoothStarter(); + explicit BaseCommunicationStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); + virtual ~BaseCommunicationStarter(); int intervalMS() const; void setIntervalMS(int i); @@ -80,19 +83,40 @@ public: signals: void connected(); void timeout(); + void message(const QString &); private slots: void slotTimer(); protected: - explicit AbstractBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); - // Overwrite to create and parametrize the listener. - virtual BluetoothListener *createListener() = 0; + virtual bool initializeStartupResources(QString *errorMessage); private: inline void stopTimer(); - AbstractBluetoothStarterPrivate *d; + BaseCommunicationStarterPrivate *d; +}; + +/* AbstractBluetoothStarter: Repeatedly tries to open a trk Bluetooth + * device. Note that in case a Listener is already running mode, the + * connection will succeed immediately. + * initializeStartupResources() is implemented to fire up the listener. + * Introduces a new virtual createListener() that derived classes must + * implement as a factory function that creates and sets up the + * listener (mode, message connection, etc). */ + +class AbstractBluetoothStarter : public BaseCommunicationStarter { + Q_OBJECT + Q_DISABLE_COPY(AbstractBluetoothStarter) +public: + +protected: + explicit AbstractBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0); + + // Implemented to fire up the listener. + virtual bool initializeStartupResources(QString *errorMessage); + // New virtual: Overwrite to create and parametrize the listener. + virtual BluetoothListener *createListener() = 0; }; /* ConsoleBluetoothStarter: Convenience class for console processes. Creates a @@ -102,12 +126,11 @@ class ConsoleBluetoothStarter : public AbstractBluetoothStarter { Q_OBJECT Q_DISABLE_COPY(ConsoleBluetoothStarter) public: - - static bool startBluetooth(const TrkDevicePtr& trkDevice, - QObject *listenerParent, - const QString &device, - int attempts, - QString *errorMessage); + static bool startBluetooth(const TrkDevicePtr& trkDevice, + QObject *listenerParent, + const QString &device, + int attempts, + QString *errorMessage); protected: virtual BluetoothListener *createListener(); diff --git a/src/shared/trk/trk.pri b/src/shared/trk/trk.pri index 5b0e067b158..2ce17c0a6c6 100644 --- a/src/shared/trk/trk.pri +++ b/src/shared/trk/trk.pri @@ -14,6 +14,7 @@ SOURCES += $$PWD/trkutils.cpp \ $$PWD/bluetoothlistener.cpp \ $$PWD/communicationstarter.cpp +# Tests/trklauncher is a console application contains(QT, gui) { HEADERS += $$PWD/bluetoothlistener_gui.h SOURCES += $$PWD/bluetoothlistener_gui.cpp
" << QCoreApplication::translate("Qt4ProjectManager::Internal::S60Devices::Device", "Id:") + << "" << id << "
" << QCoreApplication::translate("Qt4ProjectManager::Internal::S60Devices::Device", "Name:") + << "" << name << "
" << QCoreApplication::translate("Qt4ProjectManager::Internal::S60Devices::Device", "EPOC:") + << "" << epocRoot << "
" << QCoreApplication::translate("Qt4ProjectManager::Internal::S60Devices::Device", "Tools:") + << "" << toolsRoot << "
" << QCoreApplication::translate("Qt4ProjectManager::Internal::S60Devices::Device", "Qt:") + << "" << qt << "