forked from qt-creator/qt-creator
Sqlite: Optimize the initialization
https: //www.sqlite.org/compile.html#omit_autoinit Change-Id: Iaa91203be21f01a19235a9401cb4fa412eca8276 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -10,7 +10,7 @@ add_qtc_library(Sqlite
|
|||||||
SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_UTF16 SQLITE_DQS=0
|
SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_UTF16 SQLITE_DQS=0
|
||||||
SQLITE_ENABLE_STAT4 HAVE_ISNAN HAVE_FDATASYNC HAVE_MALLOC_USABLE_SIZE
|
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_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}
|
DEPENDS Qt5::Core Threads::Threads ${CMAKE_DL_LIBS}
|
||||||
PUBLIC_INCLUDES
|
PUBLIC_INCLUDES
|
||||||
"${CMAKE_CURRENT_LIST_DIR}"
|
"${CMAKE_CURRENT_LIST_DIR}"
|
||||||
@@ -46,4 +46,5 @@ add_qtc_library(Sqlite
|
|||||||
utf8stringvector.cpp utf8stringvector.h
|
utf8stringvector.cpp utf8stringvector.h
|
||||||
sqliteblob.h
|
sqliteblob.h
|
||||||
sqlitetimestamp.h
|
sqlitetimestamp.h
|
||||||
|
sqlitelibraryinitializer.cpp sqlitelibraryinitializer.h
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ SOURCES += \
|
|||||||
$$PWD/sqlitedatabasebackend.cpp \
|
$$PWD/sqlitedatabasebackend.cpp \
|
||||||
$$PWD/sqliteexception.cpp \
|
$$PWD/sqliteexception.cpp \
|
||||||
$$PWD/sqliteglobal.cpp \
|
$$PWD/sqliteglobal.cpp \
|
||||||
|
$$PWD/sqlitelibraryinitializer.cpp \
|
||||||
$$PWD/sqlitesessionchangeset.cpp \
|
$$PWD/sqlitesessionchangeset.cpp \
|
||||||
$$PWD/sqlitesessions.cpp \
|
$$PWD/sqlitesessions.cpp \
|
||||||
$$PWD/sqlstatementbuilder.cpp \
|
$$PWD/sqlstatementbuilder.cpp \
|
||||||
@@ -25,6 +26,7 @@ SOURCES += \
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/constraints.h \
|
$$PWD/constraints.h \
|
||||||
$$PWD/sqliteblob.h \
|
$$PWD/sqliteblob.h \
|
||||||
|
$$PWD/sqlitelibraryinitializer.h \
|
||||||
$$PWD/sqlitetimestamp.h \
|
$$PWD/sqlitetimestamp.h \
|
||||||
$$PWD/tableconstraints.h \
|
$$PWD/tableconstraints.h \
|
||||||
$$PWD/createtablesqlstatementbuilder.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_OMIT_LOAD_EXTENSION SQLITE_OMIT_UTF16 SQLITE_DQS=0 \
|
||||||
SQLITE_ENABLE_STAT4 HAVE_ISNAN HAVE_FDATASYNC HAVE_MALLOC_USABLE_SIZE \
|
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_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
|
CONFIG(debug, debug|release): DEFINES += SQLITE_ENABLE_API_ARMOR
|
||||||
|
|
||||||
|
|||||||
47
src/libs/sqlite/sqlitelibraryinitializer.cpp
Normal file
47
src/libs/sqlite/sqlitelibraryinitializer.cpp
Normal file
@@ -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
|
||||||
42
src/libs/sqlite/sqlitelibraryinitializer.h
Normal file
42
src/libs/sqlite/sqlitelibraryinitializer.h
Normal file
@@ -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
|
||||||
@@ -55,18 +55,19 @@
|
|||||||
#include <coreplugin/actionmanager/command.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/designmode.h>
|
#include <coreplugin/designmode.h>
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
#include <coreplugin/messagebox.h>
|
#include <coreplugin/messagebox.h>
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <extensionsystem/pluginspec.h>
|
#include <extensionsystem/pluginspec.h>
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
#include <sqlitelibraryinitializer.h>
|
||||||
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -211,6 +212,8 @@ QmlDesignerPlugin::~QmlDesignerPlugin()
|
|||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage/* = 0*/)
|
bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage/* = 0*/)
|
||||||
{
|
{
|
||||||
|
Sqlite::LibraryInitializer::initialize();
|
||||||
|
|
||||||
QDir{}.mkpath(Core::ICore::cacheResourcePath());
|
QDir{}.mkpath(Core::ICore::cacheResourcePath());
|
||||||
|
|
||||||
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorMessage))
|
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorMessage))
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
#include "googletest.h"
|
#include "googletest.h"
|
||||||
|
|
||||||
#include <sqlitedatabase.h>
|
#include <sqlitedatabase.h>
|
||||||
|
#include <sqlitelibraryinitializer.h>
|
||||||
|
|
||||||
#include <sqliteglobal.h>
|
#include <sqliteglobal.h>
|
||||||
#include <utils/temporarydirectory.h>
|
#include <utils/temporarydirectory.h>
|
||||||
|
|
||||||
@@ -52,6 +54,7 @@ public:
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
Sqlite::LibraryInitializer::initialize();
|
||||||
Sqlite::Database::activateLogging();
|
Sqlite::Database::activateLogging();
|
||||||
|
|
||||||
QGuiApplication application(argc, argv);
|
QGuiApplication application(argc, argv);
|
||||||
|
|||||||
Reference in New Issue
Block a user