diff --git a/python/core/auto_generated/qgsarchive.sip.in b/python/core/auto_generated/qgsarchive.sip.in index fe9930043a9f..1877d1babc10 100644 --- a/python/core/auto_generated/qgsarchive.sip.in +++ b/python/core/auto_generated/qgsarchive.sip.in @@ -9,6 +9,7 @@ + class QgsArchive { %Docstring diff --git a/python/core/auto_generated/qgsnetworkcontentfetcherregistry.sip.in b/python/core/auto_generated/qgsnetworkcontentfetcherregistry.sip.in index 62fb76f650a9..f51504fb5657 100644 --- a/python/core/auto_generated/qgsnetworkcontentfetcherregistry.sip.in +++ b/python/core/auto_generated/qgsnetworkcontentfetcherregistry.sip.in @@ -11,8 +11,6 @@ - - class QgsFetchedContent : QObject { %Docstring diff --git a/src/core/qgsapplication.cpp b/src/core/qgsapplication.cpp index 72ad34a36b4d..3ea27fe61eb1 100644 --- a/src/core/qgsapplication.cpp +++ b/src/core/qgsapplication.cpp @@ -130,6 +130,7 @@ const char *QgsApplication::QGIS_ORGANIZATION_DOMAIN = "qgis.org"; const char *QgsApplication::QGIS_APPLICATION_NAME = "QGIS3"; QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers = nullptr; +QgsAuthManager *QgsApplication::sAuthManager = nullptr; QgsApplication::QgsApplication( int &argc, char **argv, bool GUIenabled, const QString &profileFolder, const QString &platformName ) : QApplication( argc, argv, GUIenabled ) @@ -1167,7 +1168,6 @@ QgsAuthManager *QgsApplication::authManager() else { // no QgsApplication instance - static QgsAuthManager *sAuthManager = nullptr; if ( !sAuthManager ) sAuthManager = QgsAuthManager::instance(); return sAuthManager; @@ -1177,7 +1177,11 @@ QgsAuthManager *QgsApplication::authManager() void QgsApplication::exitQgis() { - delete QgsApplication::authManager(); + // don't create to delete + if ( instance() ) + delete instance()->mAuthManager; + else + delete sAuthManager; //Ensure that all remaining deleteLater QObjects are actually deleted before we exit. //This isn't strictly necessary (since we're exiting anyway) but doing so prevents a lot of diff --git a/src/core/qgsapplication.h b/src/core/qgsapplication.h index d267c02b7a28..be9708908410 100644 --- a/src/core/qgsapplication.h +++ b/src/core/qgsapplication.h @@ -885,6 +885,8 @@ class CORE_EXPORT QgsApplication : public QApplication // ... but in case QgsApplication is never instantiated (eg with custom designer widgets), we fall back to static members static ApplicationMembers *sApplicationMembers; + static QgsAuthManager *sAuthManager; + static ApplicationMembers *members(); }; diff --git a/src/core/qgsarchive.cpp b/src/core/qgsarchive.cpp index da1f53e16958..2fac26d807fe 100644 --- a/src/core/qgsarchive.cpp +++ b/src/core/qgsarchive.cpp @@ -20,7 +20,6 @@ #include "qgsziputils.h" #include "qgsmessagelog.h" #include "qgsauxiliarystorage.h" -#include #include #include @@ -32,7 +31,7 @@ QgsArchive::QgsArchive() QgsArchive::QgsArchive( const QgsArchive &other ) : mFiles( other.mFiles ) - , mDir( new QTemporaryDir() ) + , mDir( new QTemporaryDir() ) { } diff --git a/src/core/qgsarchive.h b/src/core/qgsarchive.h index 7fb0f1c54db3..f7b40204f260 100644 --- a/src/core/qgsarchive.h +++ b/src/core/qgsarchive.h @@ -20,6 +20,7 @@ #define QGSARCHIVE_H #include "qgis_core.h" + #include #include #include diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp index c26e9cadd36b..82281690dbcd 100644 --- a/src/core/qgscoordinatereferencesystem.cpp +++ b/src/core/qgscoordinatereferencesystem.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/src/core/qgsnetworkcontentfetcherregistry.h b/src/core/qgsnetworkcontentfetcherregistry.h index c44b1d1e24e5..e96a005c65f3 100644 --- a/src/core/qgsnetworkcontentfetcherregistry.h +++ b/src/core/qgsnetworkcontentfetcherregistry.h @@ -23,15 +23,12 @@ #include #include #include -#include #include "qgis_core.h" - -class QTemporaryFile; - #include "qgstaskmanager.h" #include "qgsnetworkcontentfetchertask.h" +class QTemporaryFile; /** * \class QgsFetchedContent diff --git a/src/core/qgsproject.h b/src/core/qgsproject.h index 9a51ce645875..2dcbbe6b66e6 100644 --- a/src/core/qgsproject.h +++ b/src/core/qgsproject.h @@ -1507,6 +1507,9 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera friend class QgsProjectDirtyBlocker; + // Required to avoid creating a new project in it's destructor + friend class QgsProviderRegistry; + // Required by QGIS Server for switching the current project instance friend class QgsConfigCache; }; diff --git a/src/core/qgsproviderregistry.cpp b/src/core/qgsproviderregistry.cpp index b750d5d0bed0..c32e43509745 100644 --- a/src/core/qgsproviderregistry.cpp +++ b/src/core/qgsproviderregistry.cpp @@ -264,7 +264,9 @@ typedef void cleanupProviderFunction_t(); void QgsProviderRegistry::clean() { - QgsProject::instance()->removeAllMapLayers(); + // avoid recreating a new project just to clean it + if ( QgsProject::sProject ) + QgsProject::instance()->removeAllMapLayers(); Providers::const_iterator it = mProviders.begin(); diff --git a/src/core/qgssettings.cpp b/src/core/qgssettings.cpp index ad2249471346..3feee35e14f0 100644 --- a/src/core/qgssettings.cpp +++ b/src/core/qgssettings.cpp @@ -15,6 +15,7 @@ #include + #include #include #include diff --git a/src/crssync/CMakeLists.txt b/src/crssync/CMakeLists.txt index 8c31ad768551..a82b22603b68 100644 --- a/src/crssync/CMakeLists.txt +++ b/src/crssync/CMakeLists.txt @@ -2,6 +2,7 @@ ADD_EXECUTABLE(crssync main.cpp) INCLUDE_DIRECTORIES( ../core + ../core/expression ../core/geometry ../core/metadata ${CMAKE_BINARY_DIR}/src/core diff --git a/src/crssync/main.cpp b/src/crssync/main.cpp index 99de960bef25..9b8270d22497 100644 --- a/src/crssync/main.cpp +++ b/src/crssync/main.cpp @@ -18,6 +18,7 @@ #include "qgsapplication.h" #include "qgscoordinatereferencesystem.h" #include "qgsconfig.h" +#include "qgsproject.h" #include @@ -84,5 +85,7 @@ int main( int argc, char **argv ) std::cout << -res << " CRSs could not be updated." << std::endl; } - exit( 0 ); + QgsApplication::exitQgis(); + + return 0; } diff --git a/src/gui/qgscolorbutton.cpp b/src/gui/qgscolorbutton.cpp index 9a9ec06dd298..4e55a340ba46 100644 --- a/src/gui/qgscolorbutton.cpp +++ b/src/gui/qgscolorbutton.cpp @@ -26,7 +26,6 @@ #include "qgsguiutils.h" #include -#include #include #include #include diff --git a/src/gui/qgscolorbutton.h b/src/gui/qgscolorbutton.h index b6ac1b2331ba..1a3c43d48ae8 100644 --- a/src/gui/qgscolorbutton.h +++ b/src/gui/qgscolorbutton.h @@ -17,7 +17,6 @@ #include #include -#include #include "qgis_gui.h" #include "qgis_sip.h" diff --git a/src/gui/symbology/qgsstyleexportimportdialog.cpp b/src/gui/symbology/qgsstyleexportimportdialog.cpp index 985548fb6aee..f7de5985c955 100644 --- a/src/gui/symbology/qgsstyleexportimportdialog.cpp +++ b/src/gui/symbology/qgsstyleexportimportdialog.cpp @@ -33,8 +33,11 @@ #include #include #include +#include #include #include +#include +#include QgsStyleExportImportDialog::QgsStyleExportImportDialog( QgsStyle *style, QWidget *parent, Mode mode ) diff --git a/src/gui/symbology/qgsstyleexportimportdialog.h b/src/gui/symbology/qgsstyleexportimportdialog.h index db0617d2065d..e1cfcd41a625 100644 --- a/src/gui/symbology/qgsstyleexportimportdialog.h +++ b/src/gui/symbology/qgsstyleexportimportdialog.h @@ -19,11 +19,6 @@ #include #include -#include -#include -#include -#include -#include #include "ui_qgsstyleexportimportdialogbase.h" #include "qgis_gui.h" @@ -36,6 +31,10 @@ class QgsStyle; class QgsStyleGroupSelectionDialog; class QgsTemporaryCursorOverride; class QgsStyleModel; +class QTemporaryFile; +class QProgressDialog; +class QNetworkAccessManager; +class QNetworkReply; /** * \ingroup gui