From a86da031c7a9473b3883c5ea117d15f7e6d979f9 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 4 May 2021 11:21:13 +0200 Subject: [PATCH 01/18] TextEditor: Fix is visible check of function hint Since the FunctionHintProposalWidget is just a proxy witget that uses a FakeToolTip it is not shown directly so we cannot check the visibility with isVisible. Fixes: QTCREATORBUG-25664 Change-Id: I6888e373afcfc79565ce8e3dad1bb05501d58200 Reviewed-by: Christian Stenger Reviewed-by: Christian Kandeler --- src/plugins/texteditor/codeassist/codeassistant.cpp | 2 +- .../texteditor/codeassist/functionhintproposalwidget.cpp | 7 ++++++- .../texteditor/codeassist/functionhintproposalwidget.h | 2 ++ src/plugins/texteditor/codeassist/iassistproposalwidget.h | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugins/texteditor/codeassist/codeassistant.cpp b/src/plugins/texteditor/codeassist/codeassistant.cpp index 1c499956187..7439980df31 100644 --- a/src/plugins/texteditor/codeassist/codeassistant.cpp +++ b/src/plugins/texteditor/codeassist/codeassistant.cpp @@ -407,7 +407,7 @@ void CodeAssistantPrivate::finalizeProposal() bool CodeAssistantPrivate::isDisplayingProposal() const { - return m_proposalWidget != nullptr && m_proposalWidget->isVisible(); + return m_proposalWidget != nullptr && m_proposalWidget->proposalIsVisible(); } bool CodeAssistantPrivate::isWaitingForProposal() const diff --git a/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp b/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp index 149fba33fa3..e96071cec5a 100644 --- a/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp +++ b/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp @@ -219,10 +219,15 @@ void FunctionHintProposalWidget::closeProposal() abort(); } +bool FunctionHintProposalWidget::proposalIsVisible() const +{ + return d->m_popupFrame->isVisible(); +} + void FunctionHintProposalWidget::abort() { qApp->removeEventFilter(this); - if (d->m_popupFrame->isVisible()) + if (proposalIsVisible()) d->m_popupFrame->close(); deleteLater(); } diff --git a/src/plugins/texteditor/codeassist/functionhintproposalwidget.h b/src/plugins/texteditor/codeassist/functionhintproposalwidget.h index 99def1676a1..a37905bbad5 100644 --- a/src/plugins/texteditor/codeassist/functionhintproposalwidget.h +++ b/src/plugins/texteditor/codeassist/functionhintproposalwidget.h @@ -52,6 +52,8 @@ public: void updateProposal(const QString &prefix) override; void closeProposal() override; + bool proposalIsVisible() const override; + protected: bool eventFilter(QObject *o, QEvent *e) override; diff --git a/src/plugins/texteditor/codeassist/iassistproposalwidget.h b/src/plugins/texteditor/codeassist/iassistproposalwidget.h index 0b7fdc0dddf..d178fc4b5ed 100644 --- a/src/plugins/texteditor/codeassist/iassistproposalwidget.h +++ b/src/plugins/texteditor/codeassist/iassistproposalwidget.h @@ -57,6 +57,8 @@ public: virtual void updateProposal(const QString &prefix) = 0; virtual void closeProposal() = 0; + virtual bool proposalIsVisible() const { return isVisible(); } + int basePosition() const; void setBasePosition(int basePosition); From 845afb25fc7bc296f4bd0aeb12207cdfbbc99107 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 4 May 2021 11:15:05 +0200 Subject: [PATCH 02/18] QmlJS: Fix checking for case and default blocks case and default blocks inside a switch statement are just special statement lists which need proper handling to avoid wrong warnings regarding using standalone blocks. Task-number: QTCREATORBUG-24214 Change-Id: Ia682b13ed4df21c5831308193d5abaf5163bde59 Reviewed-by: Fabian Kosmale --- src/libs/qmljs/qmljscheck.cpp | 10 ++++++++++ src/libs/qmljs/qmljscheck.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp index 4d084692e44..54226da5d54 100644 --- a/src/libs/qmljs/qmljscheck.cpp +++ b/src/libs/qmljs/qmljscheck.cpp @@ -1366,6 +1366,7 @@ bool Check::visit(Block *ast) && !cast(p) && !cast(p) && !cast(p) + && !isCaseOrDefault(p) && !cast(p)) { addMessage(WarnBlock, ast->lbraceToken); } @@ -1656,6 +1657,15 @@ bool Check::isQtQuick2Ui() const return _doc->language() == Dialect::QmlQtQuick2Ui; } +bool Check::isCaseOrDefault(Node *n) +{ + if (!cast(n)) + return false; + if (Node *p = parent(1)) + return p->kind == Node::Kind_CaseClause || p->kind == Node::Kind_DefaultClause; + return false; +} + bool Check::visit(NewExpression *ast) { checkNewExpression(ast->expression); diff --git a/src/libs/qmljs/qmljscheck.h b/src/libs/qmljs/qmljscheck.h index e5e110c5f9b..6b11c83f50b 100644 --- a/src/libs/qmljs/qmljscheck.h +++ b/src/libs/qmljs/qmljscheck.h @@ -122,6 +122,8 @@ private: bool isQtQuick2() const; bool isQtQuick2Ui() const; + bool isCaseOrDefault(AST::Node *n); + AST::Node *parent(int distance = 0); Document::Ptr _doc; From 2447d1d69ca941947c0df5cf32c6798f4cce1306 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 4 May 2021 12:04:01 +0200 Subject: [PATCH 03/18] QmlJS: Restrict warnings of blocks Warn only if the block contains a var statement as this is discouraged. Fixes: QTCREATORBUG-24214 Change-Id: Ib96c6723e82b6ddce0b7b63f23d3408f45ae7d58 Reviewed-by: Fabian Kosmale --- src/libs/qmljs/qmljscheck.cpp | 21 ++++++++++++++++++++- src/libs/qmljs/qmljscheck.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp index 54226da5d54..42287c4740f 100644 --- a/src/libs/qmljs/qmljscheck.cpp +++ b/src/libs/qmljs/qmljscheck.cpp @@ -1367,7 +1367,8 @@ bool Check::visit(Block *ast) && !cast(p) && !cast(p) && !isCaseOrDefault(p) - && !cast(p)) { + && !cast(p) + && hasVarStatement(ast)) { addMessage(WarnBlock, ast->lbraceToken); } if (!ast->statements @@ -1666,6 +1667,24 @@ bool Check::isCaseOrDefault(Node *n) return false; } +bool Check::hasVarStatement(AST::Block *b) const +{ + QTC_ASSERT(b, return false); + StatementList *s = b->statements; + while (s) { + if (auto var = cast(s->statement)) { + VariableDeclarationList *declList = var->declarations; + while (declList) { + if (declList->declaration && declList->declaration->scope == VariableScope::Var) + return true; + declList = declList->next; + } + } + s = s->next; + } + return false; +} + bool Check::visit(NewExpression *ast) { checkNewExpression(ast->expression); diff --git a/src/libs/qmljs/qmljscheck.h b/src/libs/qmljs/qmljscheck.h index 6b11c83f50b..ec208622485 100644 --- a/src/libs/qmljs/qmljscheck.h +++ b/src/libs/qmljs/qmljscheck.h @@ -123,6 +123,7 @@ private: bool isQtQuick2Ui() const; bool isCaseOrDefault(AST::Node *n); + bool hasVarStatement(AST::Block *b) const; AST::Node *parent(int distance = 0); From d5cadcfa599c4b523c28204552fe0a9d52742404 Mon Sep 17 00:00:00 2001 From: Tapani Mattila Date: Mon, 3 May 2021 14:47:13 +0300 Subject: [PATCH 04/18] ProjectExplorer: Enable to easily check if a project has dirty files Task-number: QDS-4241 Change-Id: I2fec5f411cdff9fabfa31bbd73971c0308df0783 Reviewed-by: Michael Winkelmann Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/project.cpp | 18 ++++++++++++++++++ src/plugins/projectexplorer/project.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index 908438b8620..bbf35c342a7 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -1061,6 +1062,23 @@ QStringList Project::availableQmlPreviewTranslations(QString *errorMessage) }); } +QList Project::modifiedDocuments() const +{ + QList modifiedProjectDocuments; + + for (Core::IDocument *doc : Core::DocumentModel::openedDocuments()) { + if (doc->isModified() && isKnownFile(doc->filePath())) + modifiedProjectDocuments.append(doc); + } + + return modifiedProjectDocuments; +} + +bool Project::isModified() const +{ + return !modifiedDocuments().isEmpty(); +} + #if defined(WITH_TESTS) } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index e91fec8e7cf..317d8bdc194 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -182,6 +182,9 @@ public: QStringList availableQmlPreviewTranslations(QString *errorMessage); + QList modifiedDocuments() const; + bool isModified() const; + signals: void projectFileIsDirty(const Utils::FilePath &path); From 5b5a998a5ca8d55cfee577e44ae3670a87f334b9 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 5 May 2021 13:09:09 +0200 Subject: [PATCH 05/18] QmlDesigner: Fix invalid id detection Do not expect an id having 2 or more characters. Fixes: QTCREATORBUG-25474 Change-Id: I0b3878614ad41681036a98befd03661530a0625c Reviewed-by: Tim Jenssen --- src/plugins/qmldesigner/designercore/model/modelnode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/designercore/model/modelnode.cpp b/src/plugins/qmldesigner/designercore/model/modelnode.cpp index f196f5ca406..0e40c8edabe 100644 --- a/src/plugins/qmldesigner/designercore/model/modelnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/modelnode.cpp @@ -203,7 +203,7 @@ static bool isIdToAvoid(const QString& id) static bool idContainsWrongLetter(const QString& id) { - static QRegularExpression idExpr(QStringLiteral("^[a-z_][a-zA-Z0-9_]+$")); + static QRegularExpression idExpr(QStringLiteral("^[a-z_][a-zA-Z0-9_]*$")); return !id.contains(idExpr); } From f4c3c49920e3ea1bbe010ede6b5f45e10d108a66 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 5 May 2021 16:48:14 +0200 Subject: [PATCH 06/18] Bump version to 4.15.1 Change-Id: Ibc2b495f00d33ec9c0c1400c9378cd80d95e11f3 Reviewed-by: Eike Ziller --- cmake/QtCreatorIDEBranding.cmake | 4 ++-- qbs/modules/qtc/qtc.qbs | 4 ++-- qtcreator_ide_branding.pri | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/QtCreatorIDEBranding.cmake b/cmake/QtCreatorIDEBranding.cmake index e16c1bd4a29..c442988571e 100644 --- a/cmake/QtCreatorIDEBranding.cmake +++ b/cmake/QtCreatorIDEBranding.cmake @@ -1,6 +1,6 @@ -set(IDE_VERSION "4.15.0") # The IDE version. +set(IDE_VERSION "4.15.1") # The IDE version. set(IDE_VERSION_COMPAT "4.15.0") # The IDE Compatibility version. -set(IDE_VERSION_DISPLAY "4.15.0") # The IDE display version. +set(IDE_VERSION_DISPLAY "4.15.1") # The IDE display version. set(IDE_COPYRIGHT_YEAR "2021") # The IDE current copyright year. set(IDE_SETTINGSVARIANT "QtProject") # The IDE settings variation. diff --git a/qbs/modules/qtc/qtc.qbs b/qbs/modules/qtc/qtc.qbs index d1dd8904b07..864bfb910e0 100644 --- a/qbs/modules/qtc/qtc.qbs +++ b/qbs/modules/qtc/qtc.qbs @@ -3,10 +3,10 @@ import qbs.Environment import qbs.FileInfo Module { - property string qtcreator_display_version: '4.15.0' + property string qtcreator_display_version: '4.15.1' property string ide_version_major: '4' property string ide_version_minor: '15' - property string ide_version_release: '0' + property string ide_version_release: '1' property string qtcreator_version: ide_version_major + '.' + ide_version_minor + '.' + ide_version_release diff --git a/qtcreator_ide_branding.pri b/qtcreator_ide_branding.pri index 4e70b129b86..2bd6d479baa 100644 --- a/qtcreator_ide_branding.pri +++ b/qtcreator_ide_branding.pri @@ -1,6 +1,6 @@ -QTCREATOR_VERSION = 4.15.0 +QTCREATOR_VERSION = 4.15.1 QTCREATOR_COMPAT_VERSION = 4.15.0 -QTCREATOR_DISPLAY_VERSION = 4.15.0 +QTCREATOR_DISPLAY_VERSION = 4.15.1 QTCREATOR_COPYRIGHT_YEAR = 2021 IDE_DISPLAY_NAME = Qt Creator From 47672714a35e0c6541087660c0306e6ef41039e6 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Sun, 4 Apr 2021 23:12:04 +0200 Subject: [PATCH 07/18] Sqlite: Simplify the binding with fold expressions Makes the life of the compiler easier too. Change-Id: I079ed042e0fd4c359415d123b89ad39341a35468 Reviewed-by: Thomas Hartmann Reviewed-by: Tapani Mattila --- src/libs/sqlite/sqlitebasestatement.h | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/libs/sqlite/sqlitebasestatement.h b/src/libs/sqlite/sqlitebasestatement.h index 08fb7ed0ed0..92c3b28a4cd 100644 --- a/src/libs/sqlite/sqlitebasestatement.h +++ b/src/libs/sqlite/sqlitebasestatement.h @@ -178,14 +178,15 @@ public: template void bindValues(const ValueType&... values) { - bindValuesByIndex(1, values...); + int index = 0; + (BaseStatement::bind(++index, values), ...); } template void write(const ValueType&... values) { Resetter resetter{*this}; - bindValuesByIndex(1, values...); + bindValues(values...); BaseStatement::next(); resetter.reset(); } @@ -380,19 +381,6 @@ private: return callCallable(callable, std::make_integer_sequence{}); } - template - void bindValuesByIndex(int index, const ValueType &value) - { - BaseStatement::bind(index, value); - } - - template - void bindValuesByIndex(int index, const ValueType &value, const ValueTypes &...values) - { - BaseStatement::bind(index, value); - bindValuesByIndex(index + 1, values...); - } - void setMaximumResultCount(std::size_t count) { m_maximumResultCount = std::max(m_maximumResultCount, count); From 385158ddcc94e8592af8bfec36e386a58089dcb9 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Sun, 4 Apr 2021 23:12:34 +0200 Subject: [PATCH 08/18] Sqlite: Remove unused function Change-Id: I3ce625c1c097c9f6e66c378c3b708397c09c6980 Reviewed-by: Tapani Mattila Reviewed-by: Thomas Hartmann --- src/libs/sqlite/sqlitebasestatement.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libs/sqlite/sqlitebasestatement.h b/src/libs/sqlite/sqlitebasestatement.h index 92c3b28a4cd..c96fb3faded 100644 --- a/src/libs/sqlite/sqlitebasestatement.h +++ b/src/libs/sqlite/sqlitebasestatement.h @@ -339,11 +339,6 @@ private: int column; }; - constexpr int resultCount(int localResultCount) const - { - return ResultCount < 0 ? localResultCount : ResultCount; - } - template void emplaceBackValues(ContainerType &container, std::integer_sequence) { From 8edbdd78adb8b9a0466ccb7063471ecfe417a961 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Fri, 9 Apr 2021 09:49:14 +0200 Subject: [PATCH 09/18] Sqlite: Default column type to None None has no type affinity. So it will not try to convert types to other types like Numeric will do. Change-Id: I5362a6d071459594619485b8b8a37b3f5ed12db6 Reviewed-by: Thomas Hartmann --- .../sqlite/createtablesqlstatementbuilder.cpp | 4 +++- src/libs/sqlite/sqlitecolumn.h | 2 +- src/libs/sqlite/sqliteglobal.h | 2 +- src/libs/sqlite/sqlitetable.h | 2 +- src/libs/sqlite/sqlstatementbuilder.cpp | 18 ++++++++++++------ tests/unit/unittest/sqlitetable-test.cpp | 10 +++++----- .../unit/unittest/sqlstatementbuilder-test.cpp | 10 +++++----- 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/libs/sqlite/createtablesqlstatementbuilder.cpp b/src/libs/sqlite/createtablesqlstatementbuilder.cpp index 07008a9a1da..de77eec5769 100644 --- a/src/libs/sqlite/createtablesqlstatementbuilder.cpp +++ b/src/libs/sqlite/createtablesqlstatementbuilder.cpp @@ -248,7 +248,9 @@ void CreateTableSqlStatementBuilder::bindColumnDefinitionsAndTableConstraints() columnDefinitionStrings.reserve(m_columns.size()); for (const Column &column : m_columns) { - Utils::SmallString columnDefinitionString = {column.name, " ", column.typeString()}; + Utils::SmallString columnDefinitionString = {column.name, + SqlStatementBuilder::columnTypeToString( + column.type)}; ContraintsVisiter visiter{columnDefinitionString}; diff --git a/src/libs/sqlite/sqlitecolumn.h b/src/libs/sqlite/sqlitecolumn.h index 1775a683075..35a5e0f25c9 100644 --- a/src/libs/sqlite/sqlitecolumn.h +++ b/src/libs/sqlite/sqlitecolumn.h @@ -39,7 +39,7 @@ public: Column(Utils::SmallStringView tableName, Utils::SmallStringView name, - ColumnType type, + ColumnType type = ColumnType::None, Constraints &&constraints = {}) : constraints(std::move(constraints)) , name(name) diff --git a/src/libs/sqlite/sqliteglobal.h b/src/libs/sqlite/sqliteglobal.h index 0bdb3c2aef9..cefdebd8d01 100644 --- a/src/libs/sqlite/sqliteglobal.h +++ b/src/libs/sqlite/sqliteglobal.h @@ -39,7 +39,7 @@ namespace Sqlite { -enum class ColumnType : char { Numeric, Integer, Real, Text, Blob, None }; +enum class ColumnType : char { None, Numeric, Integer, Real, Text, Blob }; enum class ConstraintType : char { NoConstraint, PrimaryKey, Unique, ForeignKey }; diff --git a/src/libs/sqlite/sqlitetable.h b/src/libs/sqlite/sqlitetable.h index 9883415a9f6..35453945f21 100644 --- a/src/libs/sqlite/sqlitetable.h +++ b/src/libs/sqlite/sqlitetable.h @@ -72,7 +72,7 @@ public: } Column &addColumn(Utils::SmallStringView name, - ColumnType type = ColumnType::Numeric, + ColumnType type = ColumnType::None, Constraints &&constraints = {}) { m_sqliteColumns.emplace_back(m_tableName, name, type, std::move(constraints)); diff --git a/src/libs/sqlite/sqlstatementbuilder.cpp b/src/libs/sqlite/sqlstatementbuilder.cpp index ecef170a346..7a6cc1a81a3 100644 --- a/src/libs/sqlite/sqlstatementbuilder.cpp +++ b/src/libs/sqlite/sqlstatementbuilder.cpp @@ -179,12 +179,18 @@ bool SqlStatementBuilder::isBuild() const Utils::SmallString SqlStatementBuilder::columnTypeToString(ColumnType columnType) { switch (columnType) { - case ColumnType::Numeric: return "NUMERIC"; - case ColumnType::Integer: return "INTEGER"; - case ColumnType::Real: return "REAL"; - case ColumnType::Text: return "TEXT"; - case ColumnType::Blob: return "BLOB"; - case ColumnType::None: return {}; + case ColumnType::Numeric: + return " NUMERIC"; + case ColumnType::Integer: + return " INTEGER"; + case ColumnType::Real: + return " REAL"; + case ColumnType::Text: + return " TEXT"; + case ColumnType::Blob: + return " BLOB"; + case ColumnType::None: + return {}; } Q_UNREACHABLE(); diff --git a/tests/unit/unittest/sqlitetable-test.cpp b/tests/unit/unittest/sqlitetable-test.cpp index b916ad5bc89..2faebd844cd 100644 --- a/tests/unit/unittest/sqlitetable-test.cpp +++ b/tests/unit/unittest/sqlitetable-test.cpp @@ -93,7 +93,9 @@ TEST_F(SqliteTable, InitializeTable) table.addColumn("name"); table.addColumn("value"); - EXPECT_CALL(databaseMock, execute(Eq("CREATE TEMPORARY TABLE IF NOT EXISTS testTable(name NUMERIC, value NUMERIC) WITHOUT ROWID"))); + EXPECT_CALL(databaseMock, + execute(Eq( + "CREATE TEMPORARY TABLE IF NOT EXISTS testTable(name, value) WITHOUT ROWID"))); table.initialize(databaseMock); } @@ -107,7 +109,7 @@ TEST_F(SqliteTable, InitializeTableWithIndex) table.addIndex({column}); table.addIndex({column2}); - EXPECT_CALL(databaseMock, execute(Eq("CREATE TABLE testTable(name NUMERIC, value NUMERIC)"))); + EXPECT_CALL(databaseMock, execute(Eq("CREATE TABLE testTable(name, value)"))); EXPECT_CALL(databaseMock, execute(Eq("CREATE INDEX IF NOT EXISTS index_testTable_name ON testTable(name)"))); EXPECT_CALL(databaseMock, execute(Eq("CREATE INDEX IF NOT EXISTS index_testTable_value ON testTable(value)"))); @@ -299,9 +301,7 @@ TEST_F(SqliteTable, AddPrimaryTableContraint) const auto &nameColumn = table.addColumn("name"); table.addPrimaryKeyContraint({idColumn, nameColumn}); - EXPECT_CALL(databaseMock, - execute( - Eq("CREATE TABLE testTable(id NUMERIC, name NUMERIC, PRIMARY KEY(id, name))"))); + EXPECT_CALL(databaseMock, execute(Eq("CREATE TABLE testTable(id, name, PRIMARY KEY(id, name))"))); table.initialize(databaseMock); } diff --git a/tests/unit/unittest/sqlstatementbuilder-test.cpp b/tests/unit/unittest/sqlstatementbuilder-test.cpp index 654439fbcd0..1e24faeded1 100644 --- a/tests/unit/unittest/sqlstatementbuilder-test.cpp +++ b/tests/unit/unittest/sqlstatementbuilder-test.cpp @@ -137,11 +137,11 @@ TEST(SqlStatementBuilder, ClearBinding) TEST(SqlStatementBuilder, ColumnType) { - ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Numeric), "NUMERIC"); - ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Integer), "INTEGER"); - ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Real), "REAL"); - ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Text), "TEXT"); - ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Blob), "BLOB"); + ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Numeric), " NUMERIC"); + ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Integer), " INTEGER"); + ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Real), " REAL"); + ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Text), " TEXT"); + ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Blob), " BLOB"); ASSERT_TRUE(SqlStatementBuilder::columnTypeToString(ColumnType::None).isEmpty()); } From 81a36ac0efd23154e449ccd132492a6893c0dacd Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Fri, 9 Apr 2021 17:44:03 +0200 Subject: [PATCH 10/18] Sqlite: Optimize the initialization https: //www.sqlite.org/compile.html#omit_autoinit Change-Id: Iaa91203be21f01a19235a9401cb4fa412eca8276 Reviewed-by: Thomas Hartmann --- src/libs/sqlite/CMakeLists.txt | 3 +- src/libs/sqlite/sqlite-lib.pri | 4 +- src/libs/sqlite/sqlitelibraryinitializer.cpp | 47 +++++++++++++++++++ src/libs/sqlite/sqlitelibraryinitializer.h | 42 +++++++++++++++++ src/plugins/qmldesigner/qmldesignerplugin.cpp | 11 +++-- tests/unit/unittest/unittests-main.cpp | 3 ++ 6 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 src/libs/sqlite/sqlitelibraryinitializer.cpp create mode 100644 src/libs/sqlite/sqlitelibraryinitializer.h diff --git a/src/libs/sqlite/CMakeLists.txt b/src/libs/sqlite/CMakeLists.txt index 4bf3ae91df0..dd4c9f1a581 100644 --- a/src/libs/sqlite/CMakeLists.txt +++ b/src/libs/sqlite/CMakeLists.txt @@ -10,7 +10,7 @@ add_qtc_library(Sqlite SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_UTF16 SQLITE_DQS=0 SQLITE_ENABLE_STAT4 HAVE_ISNAN HAVE_FDATASYNC HAVE_MALLOC_USABLE_SIZE SQLITE_DEFAULT_MMAP_SIZE=268435456 SQLITE_CORE SQLITE_ENABLE_SESSION SQLITE_ENABLE_PREUPDATE_HOOK - SQLITE_LIKE_DOESNT_MATCH_BLOBS + SQLITE_LIKE_DOESNT_MATCH_BLOBS SQLITE_OMIT_AUTOINIT DEPENDS Qt5::Core Threads::Threads ${CMAKE_DL_LIBS} PUBLIC_INCLUDES "${CMAKE_CURRENT_LIST_DIR}" @@ -46,4 +46,5 @@ add_qtc_library(Sqlite utf8stringvector.cpp utf8stringvector.h sqliteblob.h sqlitetimestamp.h + sqlitelibraryinitializer.cpp sqlitelibraryinitializer.h ) diff --git a/src/libs/sqlite/sqlite-lib.pri b/src/libs/sqlite/sqlite-lib.pri index 87b63eb388e..3eb64fe9d37 100644 --- a/src/libs/sqlite/sqlite-lib.pri +++ b/src/libs/sqlite/sqlite-lib.pri @@ -15,6 +15,7 @@ SOURCES += \ $$PWD/sqlitedatabasebackend.cpp \ $$PWD/sqliteexception.cpp \ $$PWD/sqliteglobal.cpp \ + $$PWD/sqlitelibraryinitializer.cpp \ $$PWD/sqlitesessionchangeset.cpp \ $$PWD/sqlitesessions.cpp \ $$PWD/sqlstatementbuilder.cpp \ @@ -25,6 +26,7 @@ SOURCES += \ HEADERS += \ $$PWD/constraints.h \ $$PWD/sqliteblob.h \ + $$PWD/sqlitelibraryinitializer.h \ $$PWD/sqlitetimestamp.h \ $$PWD/tableconstraints.h \ $$PWD/createtablesqlstatementbuilder.h \ @@ -59,7 +61,7 @@ DEFINES += SQLITE_THREADSAFE=2 SQLITE_ENABLE_FTS5 SQLITE_ENABLE_UNLOCK_NOTIFY \ SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_UTF16 SQLITE_DQS=0 \ SQLITE_ENABLE_STAT4 HAVE_ISNAN HAVE_FDATASYNC HAVE_MALLOC_USABLE_SIZE \ SQLITE_DEFAULT_MMAP_SIZE=268435456 SQLITE_CORE SQLITE_ENABLE_SESSION SQLITE_ENABLE_PREUPDATE_HOOK \ - SQLITE_LIKE_DOESNT_MATCH_BLOBS + SQLITE_LIKE_DOESNT_MATCH_BLOBS SQLITE_OMIT_AUTOINIT CONFIG(debug, debug|release): DEFINES += SQLITE_ENABLE_API_ARMOR diff --git a/src/libs/sqlite/sqlitelibraryinitializer.cpp b/src/libs/sqlite/sqlitelibraryinitializer.cpp new file mode 100644 index 00000000000..c42d1269661 --- /dev/null +++ b/src/libs/sqlite/sqlitelibraryinitializer.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "sqlitelibraryinitializer.h" + +#include "sqlitedatabasebackend.h" + +namespace Sqlite { + +void LibraryInitializer::initialize() +{ + static LibraryInitializer initializer; +} + +LibraryInitializer::LibraryInitializer() +{ + DatabaseBackend::initializeSqliteLibrary(); +} + +LibraryInitializer::~LibraryInitializer() +{ + DatabaseBackend::shutdownSqliteLibrary(); +} + +} // namespace Sqlite diff --git a/src/libs/sqlite/sqlitelibraryinitializer.h b/src/libs/sqlite/sqlitelibraryinitializer.h new file mode 100644 index 00000000000..6df8b19a22e --- /dev/null +++ b/src/libs/sqlite/sqlitelibraryinitializer.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "sqliteglobal.h" + +namespace Sqlite { + +class LibraryInitializer +{ +public: + SQLITE_EXPORT static void initialize(); + +private: + LibraryInitializer(); + ~LibraryInitializer(); +}; + +} // namespace Sqlite diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp index 1d56ef0e8ce..489d7951c13 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -55,18 +55,19 @@ #include #include #include +#include #include #include #include #include -#include #include #include -#include -#include #include -#include +#include #include +#include +#include +#include #include #include @@ -211,6 +212,8 @@ QmlDesignerPlugin::~QmlDesignerPlugin() //////////////////////////////////////////////////// bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage/* = 0*/) { + Sqlite::LibraryInitializer::initialize(); + QDir{}.mkpath(Core::ICore::cacheResourcePath()); if (!Utils::HostOsInfo::canCreateOpenGLContext(errorMessage)) diff --git a/tests/unit/unittest/unittests-main.cpp b/tests/unit/unittest/unittests-main.cpp index 26993dd9ded..5f5146de794 100644 --- a/tests/unit/unittest/unittests-main.cpp +++ b/tests/unit/unittest/unittests-main.cpp @@ -26,6 +26,8 @@ #include "googletest.h" #include +#include + #include #include @@ -52,6 +54,7 @@ public: int main(int argc, char *argv[]) { + Sqlite::LibraryInitializer::initialize(); Sqlite::Database::activateLogging(); QGuiApplication application(argc, argv); From f8647ec42821fa45d8de07b0f09e33654290fbde Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Fri, 9 Apr 2021 18:01:08 +0200 Subject: [PATCH 11/18] Sqlite: Enable SQLITE_DEBUG for debug Change-Id: I086dc07ae7672d1077f8469eccac5ce34d56c04d Reviewed-by: Thomas Hartmann --- tests/unit/unittest/unittest.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro index 2a1a2d8ec56..d6195d21600 100644 --- a/tests/unit/unittest/unittest.pro +++ b/tests/unit/unittest/unittest.pro @@ -37,6 +37,9 @@ QMAKE_LFLAGS += -fno-merge-debug-strings -fuse-ld=gold CONFIG(release, debug|release):QMAKE_LFLAGS += -Wl,--strip-debug } +CONFIG(debug, debug|release): DEFINES += SQLITE_DEBUG + + gcc:!clang: QMAKE_CXXFLAGS += -Wno-noexcept-type msvc{ QMAKE_CXXFLAGS += /bigobj /wd4267 /wd4141 /wd4146 /wd4624 From 16189376373c0390abb7e6d792aa5af87659f7c1 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Fri, 9 Apr 2021 18:53:48 +0200 Subject: [PATCH 12/18] Sqlite: Use config.h instead of setting everything in the build files Change-Id: Ia70a5e78475a8b8078276df03330060c8785bf90 Reviewed-by: Thomas Hartmann --- qbs/modules/sqlite_sources/sqlite-sources.qbs | 11 +-- src/libs/3rdparty/sqlite/config.h | 84 +++++++++++++++++++ src/libs/3rdparty/sqlite/sqlite.h | 29 +++++++ src/libs/3rdparty/sqlite/sqlite.pri | 6 ++ src/libs/sqlite/CMakeLists.txt | 21 ++--- src/libs/sqlite/sqlite-lib.pri | 11 +-- src/libs/sqlite/sqlitebasestatement.cpp | 2 +- src/libs/sqlite/sqlitedatabasebackend.cpp | 2 +- src/libs/sqlite/sqlitesessionchangeset.cpp | 2 +- src/libs/sqlite/sqlitesessions.cpp | 2 +- tests/unit/unittest/CMakeLists.txt | 8 ++ .../unit/unittest/gtest-creator-printing.cpp | 2 +- .../unittest/sqlitedatabasebackend-test.cpp | 2 +- 13 files changed, 146 insertions(+), 36 deletions(-) create mode 100644 src/libs/3rdparty/sqlite/config.h create mode 100644 src/libs/3rdparty/sqlite/sqlite.h diff --git a/qbs/modules/sqlite_sources/sqlite-sources.qbs b/qbs/modules/sqlite_sources/sqlite-sources.qbs index 559c3ec8652..ea80e58b1bd 100644 --- a/qbs/modules/sqlite_sources/sqlite-sources.qbs +++ b/qbs/modules/sqlite_sources/sqlite-sources.qbs @@ -9,16 +9,7 @@ Module { Depends { name: "cpp" } cpp.defines: [ - "SQLITE_THREADSAFE=2", "SQLITE_ENABLE_FTS5", "SQLITE_ENABLE_UNLOCK_NOTIFY", - "SQLITE_ENABLE_JSON1", "SQLITE_DEFAULT_FOREIGN_KEYS=1", "SQLITE_TEMP_STORE=2", - "SQLITE_DEFAULT_WAL_SYNCHRONOUS=1", "SQLITE_MAX_WORKER_THREADS", "SQLITE_DEFAULT_MEMSTATUS=0", - "SQLITE_OMIT_DEPRECATED", "SQLITE_OMIT_DECLTYPE", - "SQLITE_MAX_EXPR_DEPTH=0", "SQLITE_OMIT_SHARED_CACHE", "SQLITE_USE_ALLOCA", - "SQLITE_ENABLE_MEMORY_MANAGEMENT", "SQLITE_ENABLE_NULL_TRIM", "SQLITE_OMIT_EXPLAIN", - "SQLITE_OMIT_LOAD_EXTENSION", "SQLITE_OMIT_UTF16", "SQLITE_DQS=0", - "SQLITE_ENABLE_STAT4", "HAVE_ISNAN", "HAVE_FDATASYNC", "HAVE_MALLOC_USABLE_SIZE", - "SQLITE_DEFAULT_MMAP_SIZE=268435456", "SQLITE_CORE", "SQLITE_ENABLE_SESSION", "SQLITE_ENABLE_PREUPDATE_HOOK", - "SQLITE_LIKE_DOESNT_MATCH_BLOBS", + "_HAVE_SQLITE_CONFIG_H", "SQLITE_CORE" ].concat(buildSharedLib ? "BUILD_SQLITE_LIBRARY" : "BUILD_SQLITE_STATIC_LIBRARY") cpp.dynamicLibraries: base.concat((qbs.targetOS.contains("unix") && !qbs.targetOS.contains("bsd")) diff --git a/src/libs/3rdparty/sqlite/config.h b/src/libs/3rdparty/sqlite/config.h new file mode 100644 index 00000000000..19757d3f8e8 --- /dev/null +++ b/src/libs/3rdparty/sqlite/config.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include + +#if __has_include() +#include +#endif + +#if __has_include() +#define HAVE_UTIME 1 +#endif + +#if (_XOPEN_SOURCE >= 500) && !(_POSIX_C_SOURCE >= 200809L) || _DEFAULT_SOURCE || _BSD_SOURCE +#define HAVE_USLEEP 1 +#endif + +#ifdef _GNU_SOURCE +#define HAVE_STRCHRNUL 1 +#endif + +#if _POSIX_C_SOURCE >= 199309L || _XOPEN_SOURCE >= 500 +#define HAVE_FDATASYNC 1 +#endif + +#if _POSIX_C_SOURCE >= 1 || _BSD_SOURCE +#define HAVE_LOCALTIME_R 1 +#else +#define HAVE_LOCALTIME_S 1 +#endif + +#define HAVE_MALLOC_USABLE_SIZE 1 +#define HAVE_ISNAN 1 + +#define SQLITE_THREADSAFE 2 +#define SQLITE_ENABLE_FTS5 1 +#define SQLITE_ENABLE_UNLOCK_NOTIFY 1 +#define SQLITE_ENABLE_JSON1 1 +#define SQLITE_DEFAULT_FOREIGN_KEYS 1 +#define SQLITE_TEMP_STORE 2 +#define SQLITE_DEFAULT_WAL_SYNCHRONOUS 1 +#define SQLITE_MAX_WORKER_THREADS 1 +#define SQLITE_DEFAULT_MEMSTATUS 0 +#define SQLITE_OMIT_DEPRECATED 1 +#define SQLITE_OMIT_DECLTYPE 1 +#define SQLITE_MAX_EXPR_DEPTH 0 +#define SQLITE_OMIT_SHARED_CACHE 1 +#define SQLITE_USE_ALLOCA 1 +#define SQLITE_ENABLE_MEMORY_MANAGEMENT 1 +#define SQLITE_ENABLE_NULL_TRIM 1 +#define SQLITE_OMIT_EXPLAIN 1 +#define SQLITE_OMIT_LOAD_EXTENSION 1 +#define SQLITE_OMIT_UTF16 1 +#define SQLITE_DQS 0 +#define SQLITE_ENABLE_STAT4 1 +#define SQLITE_DEFAULT_MMAP_SIZE 268435456 +#define SQLITE_ENABLE_SESSION 1 +#define SQLITE_ENABLE_PREUPDATE_HOOK 1 +#define SQLITE_LIKE_DOESNT_MATCH_BLOBS 1 +#define SQLITE_OMIT_AUTOINIT 1 diff --git a/src/libs/3rdparty/sqlite/sqlite.h b/src/libs/3rdparty/sqlite/sqlite.h new file mode 100644 index 00000000000..ba06815b4d9 --- /dev/null +++ b/src/libs/3rdparty/sqlite/sqlite.h @@ -0,0 +1,29 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "config.h" +#include "sqlite3ext.h" diff --git a/src/libs/3rdparty/sqlite/sqlite.pri b/src/libs/3rdparty/sqlite/sqlite.pri index ffc3a706e65..e869f4fc56e 100644 --- a/src/libs/3rdparty/sqlite/sqlite.pri +++ b/src/libs/3rdparty/sqlite/sqlite.pri @@ -1,6 +1,12 @@ INCLUDEPATH *= $$PWD +linux:DEFINES += _POSIX_C_SOURCE=200809L _GNU_SOURCE +osx:DEFINES += _BSD_SOURCE + + HEADERS += $$PWD/sqlite3.h \ + $$PWD/config.h \ + $$PWD/sqlite.h \ $$PWD/sqlite3ext.h SOURCES += $$PWD/sqlite3.c \ diff --git a/src/libs/sqlite/CMakeLists.txt b/src/libs/sqlite/CMakeLists.txt index dd4c9f1a581..42de2ce9e99 100644 --- a/src/libs/sqlite/CMakeLists.txt +++ b/src/libs/sqlite/CMakeLists.txt @@ -1,16 +1,7 @@ add_qtc_library(Sqlite PUBLIC_DEFINES BUILD_SQLITE_LIBRARY - SQLITE_THREADSAFE=2 SQLITE_ENABLE_FTS5 SQLITE_ENABLE_UNLOCK_NOTIFY - SQLITE_ENABLE_JSON1 SQLITE_DEFAULT_FOREIGN_KEYS=1 SQLITE_TEMP_STORE=2 - SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_MEMSTATUS=0 - SQLITE_OMIT_DEPRECATED SQLITE_OMIT_DECLTYPE - SQLITE_MAX_EXPR_DEPTH=0 SQLITE_OMIT_SHARED_CACHE SQLITE_USE_ALLOCA - SQLITE_ENABLE_MEMORY_MANAGEMENT SQLITE_ENABLE_NULL_TRIM SQLITE_OMIT_EXPLAIN - SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_UTF16 SQLITE_DQS=0 - SQLITE_ENABLE_STAT4 HAVE_ISNAN HAVE_FDATASYNC HAVE_MALLOC_USABLE_SIZE - SQLITE_DEFAULT_MMAP_SIZE=268435456 SQLITE_CORE SQLITE_ENABLE_SESSION SQLITE_ENABLE_PREUPDATE_HOOK - SQLITE_LIKE_DOESNT_MATCH_BLOBS SQLITE_OMIT_AUTOINIT + SQLITE_CORE DEPENDS Qt5::Core Threads::Threads ${CMAKE_DL_LIBS} PUBLIC_INCLUDES "${CMAKE_CURRENT_LIST_DIR}" @@ -19,6 +10,8 @@ add_qtc_library(Sqlite ../3rdparty/sqlite/sqlite3.c ../3rdparty/sqlite/sqlite3.h ../3rdparty/sqlite/carray.c + ../3rdparty/sqlite/config.h + ../3rdparty/sqlite/sqlite.h constraints.h createtablesqlstatementbuilder.cpp createtablesqlstatementbuilder.h lastchangedrowid.h @@ -48,3 +41,11 @@ add_qtc_library(Sqlite sqlitetimestamp.h sqlitelibraryinitializer.cpp sqlitelibraryinitializer.h ) + +extend_qtc_library(Sqlite DEFINES _HAVE_SQLITE_CONFIG_H) + +if (APPLE) +extend_qtc_library(Sqlite DEFINES _BSD_SOURCE) +elseif (UNIX) +extend_qtc_library(Sqlite DEFINES _POSIX_C_SOURCE=200809L _GNU_SOURCE _DEFAULT_SOURCE) +endif() diff --git a/src/libs/sqlite/sqlite-lib.pri b/src/libs/sqlite/sqlite-lib.pri index 3eb64fe9d37..59d34a61c2f 100644 --- a/src/libs/sqlite/sqlite-lib.pri +++ b/src/libs/sqlite/sqlite-lib.pri @@ -52,16 +52,7 @@ HEADERS += \ $$PWD/sqliteindex.h \ $$PWD/sqlitebasestatement.h -DEFINES += SQLITE_THREADSAFE=2 SQLITE_ENABLE_FTS5 SQLITE_ENABLE_UNLOCK_NOTIFY \ - SQLITE_ENABLE_JSON1 SQLITE_DEFAULT_FOREIGN_KEYS=1 SQLITE_TEMP_STORE=2 \ - SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_MEMSTATUS=0 \ - SQLITE_OMIT_DEPRECATED SQLITE_OMIT_DECLTYPE \ - SQLITE_MAX_EXPR_DEPTH=0 SQLITE_OMIT_SHARED_CACHE SQLITE_USE_ALLOCA \ - SQLITE_ENABLE_MEMORY_MANAGEMENT SQLITE_ENABLE_NULL_TRIM SQLITE_OMIT_EXPLAIN \ - SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_UTF16 SQLITE_DQS=0 \ - SQLITE_ENABLE_STAT4 HAVE_ISNAN HAVE_FDATASYNC HAVE_MALLOC_USABLE_SIZE \ - SQLITE_DEFAULT_MMAP_SIZE=268435456 SQLITE_CORE SQLITE_ENABLE_SESSION SQLITE_ENABLE_PREUPDATE_HOOK \ - SQLITE_LIKE_DOESNT_MATCH_BLOBS SQLITE_OMIT_AUTOINIT +DEFINES += _HAVE_SQLITE_CONFIG_H SQLITE_CORE CONFIG(debug, debug|release): DEFINES += SQLITE_ENABLE_API_ARMOR diff --git a/src/libs/sqlite/sqlitebasestatement.cpp b/src/libs/sqlite/sqlitebasestatement.cpp index 7f8cd86ab4b..72a040fa04a 100644 --- a/src/libs/sqlite/sqlitebasestatement.cpp +++ b/src/libs/sqlite/sqlitebasestatement.cpp @@ -29,7 +29,7 @@ #include "sqlitedatabasebackend.h" #include "sqliteexception.h" -#include "sqlite3.h" +#include "sqlite.h" #include #include diff --git a/src/libs/sqlite/sqlitedatabasebackend.cpp b/src/libs/sqlite/sqlitedatabasebackend.cpp index 0101e826260..9c096364cb5 100644 --- a/src/libs/sqlite/sqlitedatabasebackend.cpp +++ b/src/libs/sqlite/sqlitedatabasebackend.cpp @@ -35,7 +35,7 @@ #include #include -#include "sqlite3.h" +#include "sqlite.h" #include #include diff --git a/src/libs/sqlite/sqlitesessionchangeset.cpp b/src/libs/sqlite/sqlitesessionchangeset.cpp index 76fc088f92f..eef98bc5d57 100644 --- a/src/libs/sqlite/sqlitesessionchangeset.cpp +++ b/src/libs/sqlite/sqlitesessionchangeset.cpp @@ -29,7 +29,7 @@ #include -#include +#include namespace Sqlite { diff --git a/src/libs/sqlite/sqlitesessions.cpp b/src/libs/sqlite/sqlitesessions.cpp index df668fdc593..5162a9fa593 100644 --- a/src/libs/sqlite/sqlitesessions.cpp +++ b/src/libs/sqlite/sqlitesessions.cpp @@ -28,7 +28,7 @@ #include "sqlitesessionchangeset.h" #include "sqlitetable.h" -#include +#include #include diff --git a/tests/unit/unittest/CMakeLists.txt b/tests/unit/unittest/CMakeLists.txt index 272b721bde2..0fdb966d3b0 100644 --- a/tests/unit/unittest/CMakeLists.txt +++ b/tests/unit/unittest/CMakeLists.txt @@ -223,6 +223,14 @@ endforeach() extend_qtc_test_with_target_sources(Sqlite) +extend_qtc_test(unittest DEFINES _HAVE_SQLITE_CONFIG_H) + +if (APPLE) +extend_qtc_test(unittest DEFINES _BSD_SOURCE) +elseif (UNIX) +extend_qtc_test(unittest DEFINES _POSIX_C_SOURCE=200809L _GNU_SOURCE _DEFAULT_SOURCE) +endif() + # Do not work on the source directory data add_custom_command(TARGET unittest POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_directory diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp index 2f0afc841c7..7f9d0030d9c 100644 --- a/tests/unit/unittest/gtest-creator-printing.cpp +++ b/tests/unit/unittest/gtest-creator-printing.cpp @@ -72,7 +72,7 @@ #include #include -#include +#include namespace { ClangBackEnd::FilePathCaching *filePathCache = nullptr; diff --git a/tests/unit/unittest/sqlitedatabasebackend-test.cpp b/tests/unit/unittest/sqlitedatabasebackend-test.cpp index 2390bd4a3c6..f6c6a62bb2a 100644 --- a/tests/unit/unittest/sqlitedatabasebackend-test.cpp +++ b/tests/unit/unittest/sqlitedatabasebackend-test.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include From f8d04c0732b0a60de81934d2284ef4361dcc5b9e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 May 2021 08:37:04 -0700 Subject: [PATCH 13/18] Add missing #include MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A local, unpushed change highlighted it. qmldebugtranslationclient.cpp:47:42: error: use of deleted function ‘QYouForgotToDeclareStreamingOperators& operator<<(QDataStream&, T) [with T = QUrl]’ I really don't understand how this could compile even without my change. Change-Id: I9f583ca106d24f048885fffd167c35c9e614c786 Reviewed-by: Tim Jenssen --- src/plugins/qmlpreview/qmldebugtranslationclient.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/qmlpreview/qmldebugtranslationclient.cpp b/src/plugins/qmlpreview/qmldebugtranslationclient.cpp index 3ef4351d498..e383784ef59 100644 --- a/src/plugins/qmlpreview/qmldebugtranslationclient.cpp +++ b/src/plugins/qmlpreview/qmldebugtranslationclient.cpp @@ -26,6 +26,8 @@ #include "qmldebugtranslationclient.h" #include +#include + #ifdef FOUND_QML_DEBUG_TRANSLATION_PROTOCOL #include #endif From 80f6f2206157e6d75d2c4e473ca1838aaa00a61c Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 4 May 2021 15:53:55 +0200 Subject: [PATCH 14/18] QmlDesigner: Do not define extra stream operators for QList This is not required and creates issues with Qt 6. Change-Id: I74e875fe785d5baa4d0688d0ef86a9151750e56c Reviewed-by: Miikka Heikkinen Reviewed-by: Thomas Hartmann --- .../designercore/include/propertycontainer.h | 4 --- .../designercore/model/propertycontainer.cpp | 32 ------------------- 2 files changed, 36 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/include/propertycontainer.h b/src/plugins/qmldesigner/designercore/include/propertycontainer.h index 5eebf01fbd4..ae38f9aafce 100644 --- a/src/plugins/qmldesigner/designercore/include/propertycontainer.h +++ b/src/plugins/qmldesigner/designercore/include/propertycontainer.h @@ -66,8 +66,4 @@ private: mutable QVariant m_value; }; -QMLDESIGNERCORE_EXPORT QDataStream &operator<<(QDataStream &stream, const QList &propertyContainerList); -QMLDESIGNERCORE_EXPORT QDataStream &operator>>(QDataStream &stream, QList &propertyContainerList); -QMLDESIGNERCORE_EXPORT QDebug operator<<(QDebug debug, QList &propertyContainerList); - } //namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/model/propertycontainer.cpp b/src/plugins/qmldesigner/designercore/model/propertycontainer.cpp index ae62b4d0e6c..440b91ffa08 100644 --- a/src/plugins/qmldesigner/designercore/model/propertycontainer.cpp +++ b/src/plugins/qmldesigner/designercore/model/propertycontainer.cpp @@ -113,37 +113,5 @@ QDebug operator<<(QDebug debug, const PropertyContainer &propertyContainer) return debug.space(); } -QDataStream &operator<<(QDataStream &stream, const QList &propertyContainerList) -{ - stream << propertyContainerList.count(); - foreach (const PropertyContainer &propertyContainer, propertyContainerList) - stream << propertyContainer; - - return stream; -} - -QDataStream &operator>>(QDataStream &stream, QList &propertyContainerList) -{ - int count; - stream >> count; - Q_ASSERT(count >= 0); - for ( int i = 0; i < count; i++) { - PropertyContainer propertyContainer; - stream >> propertyContainer; - propertyContainerList.append(propertyContainer); - } - - return stream; -} - -QDebug operator<<(QDebug debug, QList &propertyContainerList) -{ - foreach (const PropertyContainer &propertyContainer, propertyContainerList) - debug << propertyContainer; - - return debug.space(); -} - - } //namespace QmlDesigner From 8bfdb39d71c6f6e342052d47bb43748d212607c0 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 4 May 2021 15:32:53 +0200 Subject: [PATCH 15/18] QmlDesigner: Fix InternalConstants for Qt 6 Change-Id: I1f516b4d350c88154dfe193d0833b28b1b46c7e2 Reviewed-by: Miikka Heikkinen Reviewed-by: Thomas Hartmann --- .../imports/StudioTheme/InternalConstants.qml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml index 54bbe343623..19e319be32c 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml @@ -28,10 +28,8 @@ import QtQuick 2.10 QtObject { readonly property int width: 1920 readonly property int height: 1080 - readonly property FontLoader mySystemFont: FontLoader { - name: "Arial" - } - readonly property FontLoader controlIcons: FontLoader { + + property FontLoader controlIcons: FontLoader { source: "icons.ttf" } @@ -150,12 +148,12 @@ QtObject { }) readonly property font font: Qt.font({ - "family": mySystemFont.name, + "family": "Arial", "pointSize": Qt.application.font.pixelSize }) readonly property font largeFont: Qt.font({ - "family": mySystemFont.name, + "family": "Arial", "pointSize": Qt.application.font.pixelSize * 1.6 }) } From 0059f6af74b53bde7914e64352b3f64cd30f5f18 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 4 May 2021 15:36:35 +0200 Subject: [PATCH 16/18] QmlDesigner: Define RegExpValidator in HelperWidgets In Qt 6 there is no RegExpValidator anymore. To support both Qt 5 and Qt 6 we register our own RegExpValidator in HelperWidgets if we compile with Qt 6. Change-Id: I7e66cbf3e29dd034a1c96a22e233058cb7a892e3 Reviewed-by: Miikka Heikkinen Reviewed-by: Thomas Hartmann --- .../RegExpValidator.qml | 6 +++++ .../quick2propertyeditorview.cpp | 26 ++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 share/qtcreator/qmldesigner/propertyEditorQmlSources/RegExpValidator.qml diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/RegExpValidator.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/RegExpValidator.qml new file mode 100644 index 00000000000..f9ace424d9e --- /dev/null +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/RegExpValidator.qml @@ -0,0 +1,6 @@ +import QtQuick 2.15 + +RegularExpressionValidator { + id: root + property alias regExp: root.regularExpression +} diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp index 7032a26ef76..92ac7fdf8f1 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp @@ -25,22 +25,23 @@ #include "quick2propertyeditorview.h" -#include "propertyeditorvalue.h" +#include "aligndistribute.h" +#include "annotationeditor/annotationeditor.h" +#include "bindingeditor/actioneditor.h" +#include "bindingeditor/bindingeditor.h" #include "fileresourcesmodel.h" #include "gradientmodel.h" -#include "gradientpresetdefaultlistmodel.h" #include "gradientpresetcustomlistmodel.h" +#include "gradientpresetdefaultlistmodel.h" #include "itemfiltermodel.h" -#include "simplecolorpalettemodel.h" -#include "bindingeditor/bindingeditor.h" -#include "bindingeditor/actioneditor.h" -#include "annotationeditor/annotationeditor.h" -#include "qmlanchorbindingproxy.h" -#include "theme.h" -#include "aligndistribute.h" #include "propertyeditorcontextobject.h" -#include "tooltip.h" +#include "propertyeditorqmlbackend.h" +#include "propertyeditorvalue.h" +#include "qmlanchorbindingproxy.h" #include "richtexteditor/richtexteditorproxy.h" +#include "simplecolorpalettemodel.h" +#include "theme.h" +#include "tooltip.h" namespace QmlDesigner { @@ -71,6 +72,11 @@ void Quick2PropertyEditorView::registerQmlTypes() Tooltip::registerDeclarativeType(); EasingCurveEditor::registerDeclarativeType(); RichTextEditorProxy::registerDeclarativeType(); + QUrl regExpUrl = QUrl::fromLocalFile(PropertyEditorQmlBackend::propertyEditorResourcesPath() + + "/RegExpValidator.qml"); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qmlRegisterType(regExpUrl, "HelperWidgets", 2, 0, "RegExpValidator"); +#endif } } From 97a932774621073d0446d355348135c6ee33132d Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Thu, 6 May 2021 10:47:23 +0200 Subject: [PATCH 17/18] QmlPuppet: reorder includes Change-Id: If73f76aee81feef160feeb87c78644e26e36072d Reviewed-by: Marco Bubke --- .../qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp index 30aec5b0c99..b45529f5c1a 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp @@ -23,24 +23,22 @@ ** ****************************************************************************/ -#include +#include "iconrenderer/iconrenderer.h" +#include "import3d/import3d.h" +#include + +#include +#include +#include #include #include #include #include - #include #include -#include "iconrenderer/iconrenderer.h" -#include "import3d/import3d.h" -#include - -#include -#include - #ifdef ENABLE_QT_BREAKPAD #include #endif From fb26650d86636fff7b84a7218ebcf95e089431d9 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Thu, 6 May 2021 10:55:29 +0200 Subject: [PATCH 18/18] QmlPuppet: fix crash when multilanguage database is used amends 81a36ac0efd23154e449ccd132492a6893c0dacd Change-Id: Ib4143432704569c84a57540a07f75fa2044aaf0e Reviewed-by: Marco Bubke Reviewed-by: Tim Jenssen --- .../qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp index b45529f5c1a..51b265a593b 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp @@ -27,6 +27,9 @@ #include "import3d/import3d.h" #include +#ifdef MULTILANGUAGE_TRANSLATIONPROVIDER +#include +#endif #include #include @@ -272,6 +275,10 @@ int main(int argc, char *argv[]) && qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_STYLE") && qgetenv("QT_QUICK_CONTROLS_STYLE") != "Desktop"; +#ifdef MULTILANGUAGE_TRANSLATIONPROVIDER + Sqlite::LibraryInitializer::initialize(); +#endif + if (useGuiApplication) { QGuiApplication application(argc, argv); return internalMain(&application);