Use QScopedPointer-guarded pimpl-objects instead of raw pointer

parent a005b8ef
......@@ -37,12 +37,15 @@ Boston, MA 02110-1301, USA.
namespace KDevelop
{
class ContextPrivate
{
};
Context::Context()
: d(nullptr)
{}
Context::~Context()
{}
Context::~Context() = default;
bool Context::hasType( int aType ) const
{
......@@ -63,10 +66,7 @@ FileContext::FileContext( const QList<QUrl> &urls )
: Context(), d( new FileContextPrivate( urls ) )
{}
FileContext::~FileContext()
{
delete d;
}
FileContext::~FileContext() = default;
int FileContext::type() const
{
......@@ -92,10 +92,7 @@ ProjectItemContext::ProjectItemContext( const QList<ProjectBaseItem*> &items )
: Context(), d( new ProjectItemContextPrivate( items ) )
{}
ProjectItemContext::~ProjectItemContext()
{
delete d;
}
ProjectItemContext::~ProjectItemContext() = default;
int ProjectItemContext::type() const
{
......@@ -125,10 +122,7 @@ OpenWithContext::OpenWithContext(const QList<QUrl>& urls, const QMimeType& mimeT
{
}
OpenWithContext::~OpenWithContext()
{
delete d;
}
OpenWithContext::~OpenWithContext() = default;
int OpenWithContext::type() const
{
......
......@@ -34,6 +34,7 @@ Boston, MA 02110-1301, USA.
#include "interfacesexport.h"
#include <QUrl>
#include <QScopedPointer>
class QMimeType;
template <typename T> class QList;
......@@ -120,7 +121,7 @@ protected:
Context();
private:
class ContextPrivate* const d;
const QScopedPointer<class ContextPrivate> d;
Q_DISABLE_COPY(Context)
};
......@@ -143,7 +144,7 @@ public:
QList<QUrl> urls() const override;
private:
class FileContextPrivate* const d;
const QScopedPointer<class FileContextPrivate> d;
Q_DISABLE_COPY(FileContext)
};
......@@ -168,7 +169,7 @@ public:
QList<ProjectBaseItem*> items() const;
private:
class ProjectItemContextPrivate* const d;
const QScopedPointer<class ProjectItemContextPrivate> d;
Q_DISABLE_COPY(ProjectItemContext)
};
......@@ -202,7 +203,7 @@ public:
QMimeType mimeType() const;
private:
class OpenWithContextPrivate* const d;
const QScopedPointer<class OpenWithContextPrivate> d;
Q_DISABLE_COPY(OpenWithContext)
};
......
......@@ -58,10 +58,7 @@ ContextMenuExtension::ContextMenuExtension()
{
}
ContextMenuExtension::~ContextMenuExtension()
{
delete d;
}
ContextMenuExtension::~ContextMenuExtension() = default;
ContextMenuExtension::ContextMenuExtension( const ContextMenuExtension& rhs )
......
......@@ -23,6 +23,7 @@
#include <QString>
#include <QList>
#include <QScopedPointer>
#include "interfacesexport.h"
......@@ -101,7 +102,7 @@ public:
static void populateMenu(QMenu* menu, const QList<ContextMenuExtension>& extensions);
private:
class ContextMenuExtensionPrivate* const d;
const QScopedPointer<class ContextMenuExtensionPrivate> d;
};
}
......
......@@ -57,7 +57,6 @@ IDocument::IDocument( KDevelop::ICore* core )
IDocument::~IDocument()
{
delete d->scriptWrapper;
delete d;
}
KDevelop::ICore* IDocument::core()
......
......@@ -22,6 +22,7 @@
#define KDEVPLATFORM_IDOCUMENT_H
#include <QUrl>
#include <QScopedPointer>
#include "interfacesexport.h"
......@@ -209,8 +210,8 @@ protected:
void notifyLoaded();
private:
const QScopedPointer<class IDocumentPrivate> d;
friend class IDocumentPrivate;
class IDocumentPrivate* const d;
};
}
......
......@@ -116,10 +116,7 @@ IPlugin::IPlugin( const QString &componentName, QObject *parent )
this, updateState);
}
IPlugin::~IPlugin()
{
delete d;
}
IPlugin::~IPlugin() = default;
void IPlugin::unload()
{
......
......@@ -272,8 +272,8 @@ protected:
virtual void initializeGuiState();
private:
const QScopedPointer<class IPluginPrivate> d;
friend class IPluginPrivate;
class IPluginPrivate* const d;
};
}
......
......@@ -38,7 +38,6 @@ LaunchConfigurationType::LaunchConfigurationType()
LaunchConfigurationType::~LaunchConfigurationType()
{
qDeleteAll(d->starters);
delete d;
}
......
......@@ -145,7 +145,7 @@ Q_SIGNALS:
void signalAddLaunchConfiguration(KDevelop::ILaunchConfiguration* launch);
private:
class LaunchConfigurationTypePrivate* const d;
const QScopedPointer<class LaunchConfigurationTypePrivate> d;
};
}
......
......@@ -113,8 +113,6 @@ ParseJob::~ParseJob()
QMetaObject::invokeMethod(p.data(), "updateReady", Qt::QueuedConnection, Q_ARG(KDevelop::IndexedString, d->url), Q_ARG(KDevelop::ReferencedTopDUContext, d->duContext));
}
}
delete d;
}
ILanguageSupport* ParseJob::languageSupport() const
......
......@@ -230,7 +230,7 @@ protected:
bool hasTracker() const;
private:
class ParseJobPrivate* const d;
const QScopedPointer<class ParseJobPrivate> d;
};
}
......
......@@ -94,10 +94,7 @@ ApplyChangesWidget::ApplyChangesWidget(QWidget* parent)
resize(QSize(800, 400));
}
ApplyChangesWidget::~ApplyChangesWidget()
{
delete d;
}
ApplyChangesWidget::~ApplyChangesWidget() = default;
bool ApplyChangesWidget::hasDocuments() const
{
......
......@@ -31,7 +31,6 @@ class Document;
namespace KDevelop
{
class IndexedString;
class ApplyChangesWidgetPrivate;
class KDEVPLATFORMLANGUAGE_EXPORT ApplyChangesWidget : public QDialog
{
......@@ -61,7 +60,7 @@ class KDEVPLATFORMLANGUAGE_EXPORT ApplyChangesWidget : public QDialog
void indexChanged(int);
private:
ApplyChangesWidgetPrivate * d;
const QScopedPointer<class ApplyChangesWidgetPrivate> d;
};
}
......
......@@ -42,10 +42,7 @@ ArchiveTemplateLoader::ArchiveTemplateLoader()
{
}
ArchiveTemplateLoader::~ArchiveTemplateLoader()
{
delete d;
}
ArchiveTemplateLoader::~ArchiveTemplateLoader() = default;
void ArchiveTemplateLoader::addLocation(ArchiveTemplateLocation* location)
{
......
......@@ -47,7 +47,7 @@ private:
Q_DISABLE_COPY(ArchiveTemplateLoader)
ArchiveTemplateLoader();
class ArchiveTemplateLoaderPrivate* const d;
const QScopedPointer<class ArchiveTemplateLoaderPrivate> d;
};
/**
......
......@@ -58,7 +58,6 @@ CodeGeneratorBase::CodeGeneratorBase()
CodeGeneratorBase::~CodeGeneratorBase()
{
clearChangeSets();
delete d;
}
void CodeGeneratorBase::autoGenerate ( DUContext* context, const KDevelop::DocumentRange* range )
......
......@@ -136,9 +136,10 @@ protected:
void clearChangeSets();
private:
class CodeGeneratorPrivate * const d;
bool displayChanges();
private:
const QScopedPointer<class CodeGeneratorPrivate> d;
};
/**
......
......@@ -54,8 +54,9 @@ namespace KDevelop {
typedef QList<DocumentChangePointer> ChangesList;
typedef QHash<IndexedString, ChangesList> ChangesHash;
struct DocumentChangeSetPrivate
class DocumentChangeSetPrivate
{
public:
DocumentChangeSet::ReplacementPolicy replacePolicy;
DocumentChangeSet::FormatPolicy formatPolicy;
DocumentChangeSet::DUChainUpdateHandling updatePolicy;
......@@ -152,10 +153,7 @@ DocumentChangeSet& DocumentChangeSet::operator=(const DocumentChangeSet& rhs)
return *this;
}
DocumentChangeSet::~DocumentChangeSet()
{
delete d;
}
DocumentChangeSet::~DocumentChangeSet() = default;
DocumentChangeSet::ChangeResult DocumentChangeSet::addChange(const DocumentChange& change)
{
......
......@@ -30,8 +30,6 @@
namespace KDevelop {
struct DocumentChangeSetPrivate;
class KDEVPLATFORMLANGUAGE_EXPORT DocumentChange : public QSharedData
{
public:
......@@ -142,7 +140,7 @@ public:
ChangeResult applyAllChanges();
private:
DocumentChangeSetPrivate * d;
const QScopedPointer<class DocumentChangeSetPrivate> d;
};
}
......
......@@ -143,7 +143,6 @@ SourceFileTemplate::SourceFileTemplate (const SourceFileTemplate& other)
SourceFileTemplate::~SourceFileTemplate()
{
delete d->archive;
delete d;
}
SourceFileTemplate& SourceFileTemplate::operator=(const SourceFileTemplate& other)
......
......@@ -328,7 +328,7 @@ public:
void addAdditionalSearchLocation(const QString& location);
private:
class SourceFileTemplatePrivate* const d;
const QScopedPointer<class SourceFileTemplatePrivate> d;
};
}
......
......@@ -105,10 +105,7 @@ TemplateClassGenerator::TemplateClassGenerator(const QUrl& baseUrl)
d->renderer.setEmptyLinesPolicy(TemplateRenderer::TrimEmptyLines);
}
TemplateClassGenerator::~TemplateClassGenerator()
{
delete d;
}
TemplateClassGenerator::~TemplateClassGenerator() = default;
void TemplateClassGenerator::setTemplateDescription(const SourceFileTemplate& fileTemplate)
{
......
......@@ -173,7 +173,7 @@ public:
TemplateRenderer* renderer() const;
private:
class TemplateClassGeneratorPrivate* const d;
const QScopedPointer<class TemplateClassGeneratorPrivate> d;
};
}
......
......@@ -31,7 +31,6 @@ class QStringList;
namespace KDevelop {
class TemplateRenderer;
struct TemplateEnginePrivate;
/**
* Central template engine where template directories and archives can be registered.
......@@ -53,7 +52,8 @@ private:
Q_DISABLE_COPY(TemplateEngine)
const QScopedPointer<TemplateEnginePrivate> d;
private:
const QScopedPointer<class TemplateEnginePrivate> d;
friend class TemplateRenderer;
};
......
......@@ -28,8 +28,9 @@
namespace KDevelop {
struct TemplateEnginePrivate
class TemplateEnginePrivate
{
public:
Grantlee::Engine engine;
};
......
......@@ -92,10 +92,7 @@ TemplateRenderer::TemplateRenderer()
d->emptyLinesPolicy = KeepEmptyLines;
}
TemplateRenderer::~TemplateRenderer()
{
delete d;
}
TemplateRenderer::~TemplateRenderer() = default;
void TemplateRenderer::addVariables(const QVariantHash& variables)
{
......
......@@ -198,7 +198,7 @@ public:
QString errorString() const;
private:
class TemplateRendererPrivate* const d;
const QScopedPointer<class TemplateRendererPrivate> d;
};
}
......
......@@ -108,10 +108,7 @@ TemplatesModel::TemplatesModel(const QString& typePrefix, QObject* parent)
}
}
TemplatesModel::~TemplatesModel()
{
delete d;
}
TemplatesModel::~TemplatesModel() = default;
void TemplatesModel::refresh()
{
......
......@@ -116,7 +116,7 @@ public:
void addDataPath(const QString &path);
private:
TemplatesModelPrivate* const d;
const QScopedPointer<class TemplatesModelPrivate> d;
};
}
......
......@@ -161,10 +161,7 @@ CodeModel::CodeModel() : d(new CodeModelPrivate())
{
}
CodeModel::~CodeModel()
{
delete d;
}
CodeModel::~CodeModel() = default;
void CodeModel::addItem(const IndexedString& file, const IndexedQualifiedIdentifier& id, CodeModelItem::Kind kind)
{
......
......@@ -21,6 +21,8 @@
#include "identifier.h"
#include <QScopedPointer>
namespace KDevelop {
class Declaration;
......@@ -93,7 +95,7 @@ namespace KDevelop {
static CodeModel& self();
private:
class CodeModelPrivate* d;
const QScopedPointer<class CodeModelPrivate> d;
};
}
......
......@@ -144,10 +144,7 @@ Definitions::Definitions() : d(new DefinitionsPrivate())
{
}
Definitions::~Definitions()
{
delete d;
}
Definitions::~Definitions() = default;
void Definitions::addDefinition(const DeclarationId& id, const IndexedDeclaration& definition)
{
......
......@@ -23,6 +23,7 @@
#include <language/languageexport.h>
#include <util/kdevvarlengtharray.h>
#include <QScopedPointer>
class QTextStream;
......@@ -56,7 +57,7 @@ namespace KDevelop {
void dump(const QTextStream& out);
private:
class DefinitionsPrivate* d;
const QScopedPointer<class DefinitionsPrivate> d;
};
}
......
......@@ -74,10 +74,7 @@ DUChainLock::DUChainLock()
{
}
DUChainLock::~DUChainLock()
{
delete d;
}
DUChainLock::~DUChainLock() = default;
bool DUChainLock::lockForRead(unsigned int timeout)
{
......
......@@ -20,6 +20,7 @@
#define KDEVPLATFORM_DUCHAINLOCK_H
#include <language/languageexport.h>
#include <QScopedPointer>
namespace KDevelop
{
......@@ -100,7 +101,7 @@ public:
bool currentThreadHasWriteLock();
private:
class DUChainLockPrivate* const d;
const QScopedPointer<class DUChainLockPrivate> d;
};
/**
......
......@@ -60,9 +60,7 @@ DumpDotGraph::DumpDotGraph() : d(new DumpDotGraphPrivate()) {
}
DumpDotGraph::~DumpDotGraph() {
delete d;
}
DumpDotGraph::~DumpDotGraph() = default;
void DumpDotGraphPrivate::addDeclaration(QTextStream& stream, Declaration* dec) {
if( m_hadObjects.contains(dec) )
......
......@@ -15,6 +15,7 @@
#define KDEVPLATFORM_DUMPDOTGRAPH_H
#include <QtGlobal>
#include <QScopedPointer>
#include <language/languageexport.h>
class QString;
......@@ -38,7 +39,7 @@ namespace KDevelop {
QString dotGraph(KDevelop::DUContext* context, bool shortened = false);
private:
class DumpDotGraphPrivate* const d;
const QScopedPointer<class DumpDotGraphPrivate> d;
};
}
......
......@@ -113,10 +113,7 @@ Importers::Importers() : d(new ImportersPrivate())
{
}
Importers::~Importers()
{
delete d;
}
Importers::~Importers() = default;
void Importers::addImporter(const DeclarationId& id, const IndexedDUContext& use)
{
......
......@@ -22,6 +22,7 @@
#include <language/languageexport.h>
#include "declarationid.h"
#include <QScopedPointer>
namespace KDevelop {
......@@ -58,7 +59,7 @@ namespace KDevelop {
static Importers& self();
private:
class ImportersPrivate* d;
const QScopedPointer<class ImportersPrivate> d;
};
}
......