Skip to content

Commit

Permalink
fix removal of temporary directories (fixes #21292)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Apr 1, 2019
1 parent 62895d1 commit 8851328
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 20 deletions.
1 change: 1 addition & 0 deletions python/core/auto_generated/qgsarchive.sip.in
Expand Up @@ -9,6 +9,7 @@




class QgsArchive
{
%Docstring
Expand Down
Expand Up @@ -11,8 +11,6 @@





class QgsFetchedContent : QObject
{
%Docstring
Expand Down
8 changes: 6 additions & 2 deletions src/core/qgsapplication.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -1167,7 +1168,6 @@ QgsAuthManager *QgsApplication::authManager()
else
{
// no QgsApplication instance
static QgsAuthManager *sAuthManager = nullptr;
if ( !sAuthManager )
sAuthManager = QgsAuthManager::instance();
return sAuthManager;
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsapplication.h
Expand Up @@ -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();
};

Expand Down
3 changes: 1 addition & 2 deletions src/core/qgsarchive.cpp
Expand Up @@ -20,7 +20,6 @@
#include "qgsziputils.h"
#include "qgsmessagelog.h"
#include "qgsauxiliarystorage.h"
#include <iostream>

#include <QStandardPaths>
#include <QUuid>
Expand All @@ -32,7 +31,7 @@ QgsArchive::QgsArchive()

QgsArchive::QgsArchive( const QgsArchive &other )
: mFiles( other.mFiles )
, mDir( new QTemporaryDir() )
, mDir( new QTemporaryDir() )
{
}

Expand Down
1 change: 1 addition & 0 deletions src/core/qgsarchive.h
Expand Up @@ -20,6 +20,7 @@
#define QGSARCHIVE_H

#include "qgis_core.h"

#include <QStringList>
#include <QTemporaryFile>
#include <QTemporaryDir>
Expand Down
1 change: 0 additions & 1 deletion src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -21,7 +21,6 @@
#include <cmath>

#include <QDir>
#include <QTemporaryFile>
#include <QDomNode>
#include <QDomElement>
#include <QFileInfo>
Expand Down
5 changes: 1 addition & 4 deletions src/core/qgsnetworkcontentfetcherregistry.h
Expand Up @@ -23,15 +23,12 @@
#include <QMap>
#include <QMutex>
#include <QNetworkReply>
#include <QTemporaryFile>

#include "qgis_core.h"

class QTemporaryFile;

#include "qgstaskmanager.h"
#include "qgsnetworkcontentfetchertask.h"

class QTemporaryFile;

/**
* \class QgsFetchedContent
Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsproject.h
Expand Up @@ -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;
};
Expand Down
4 changes: 3 additions & 1 deletion src/core/qgsproviderregistry.cpp
Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions src/core/qgssettings.cpp
Expand Up @@ -15,6 +15,7 @@


#include <cstdlib>

#include <QFileInfo>
#include <QSettings>
#include <QDir>
Expand Down
1 change: 1 addition & 0 deletions src/crssync/CMakeLists.txt
Expand Up @@ -2,6 +2,7 @@ ADD_EXECUTABLE(crssync main.cpp)

INCLUDE_DIRECTORIES(
../core
../core/expression
../core/geometry
../core/metadata
${CMAKE_BINARY_DIR}/src/core
Expand Down
5 changes: 4 additions & 1 deletion src/crssync/main.cpp
Expand Up @@ -18,6 +18,7 @@
#include "qgsapplication.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsconfig.h"
#include "qgsproject.h"

#include <QRegExp>

Expand Down Expand Up @@ -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;
}
1 change: 0 additions & 1 deletion src/gui/qgscolorbutton.cpp
Expand Up @@ -26,7 +26,6 @@
#include "qgsguiutils.h"

#include <QPainter>
#include <QTemporaryFile>
#include <QMouseEvent>
#include <QMenu>
#include <QClipboard>
Expand Down
1 change: 0 additions & 1 deletion src/gui/qgscolorbutton.h
Expand Up @@ -17,7 +17,6 @@

#include <QColorDialog>
#include <QToolButton>
#include <QTemporaryFile>
#include "qgis_gui.h"
#include "qgis_sip.h"

Expand Down
3 changes: 3 additions & 0 deletions src/gui/symbology/qgsstyleexportimportdialog.cpp
Expand Up @@ -33,8 +33,11 @@
#include <QCloseEvent>
#include <QFileDialog>
#include <QMessageBox>
#include <QProgressDialog>
#include <QPushButton>
#include <QStandardItemModel>
#include <QNetworkAccessManager>
#include <QNetworkReply>


QgsStyleExportImportDialog::QgsStyleExportImportDialog( QgsStyle *style, QWidget *parent, Mode mode )
Expand Down
9 changes: 4 additions & 5 deletions src/gui/symbology/qgsstyleexportimportdialog.h
Expand Up @@ -19,11 +19,6 @@

#include <QDialog>
#include <QUrl>
#include <QProgressDialog>
#include <QTemporaryFile>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QStandardItem>

#include "ui_qgsstyleexportimportdialogbase.h"
#include "qgis_gui.h"
Expand All @@ -36,6 +31,10 @@ class QgsStyle;
class QgsStyleGroupSelectionDialog;
class QgsTemporaryCursorOverride;
class QgsStyleModel;
class QTemporaryFile;
class QProgressDialog;
class QNetworkAccessManager;
class QNetworkReply;

/**
* \ingroup gui
Expand Down

0 comments on commit 8851328

Please sign in to comment.