diff --git a/src/libcalamares/ProcessJob.h b/src/libcalamares/ProcessJob.h index 1ac7f7f08..ba6e650f6 100644 --- a/src/libcalamares/ProcessJob.h +++ b/src/libcalamares/ProcessJob.h @@ -32,7 +32,7 @@ public: bool runInChroot = false, int secondsTimeout = 30, QObject* parent = nullptr ); - virtual ~ProcessJob() override; + virtual ~ProcessJob(); QString prettyName() const override; QString prettyStatusMessage() const override; diff --git a/src/libcalamares/utils/PluginFactory.cpp b/src/libcalamares/utils/PluginFactory.cpp index ff6c9913f..710633866 100644 --- a/src/libcalamares/utils/PluginFactory.cpp +++ b/src/libcalamares/utils/PluginFactory.cpp @@ -26,7 +26,7 @@ #include #include -Q_GLOBAL_STATIC(QObjectCleanupHandler, factorycleanup) +Q_GLOBAL_STATIC( QObjectCleanupHandler, factorycleanup ) extern int kLibraryDebugArea(); @@ -34,89 +34,96 @@ namespace Calamares { PluginFactory::PluginFactory() - : d_ptr_p(new PluginFactoryPrivate) + : d_ptr( new PluginFactoryPrivate ) { - Q_D(PluginFactory); + Q_D( PluginFactory ); d->q_ptr = this; - factorycleanup()->add(this); + factorycleanup()->add( this ); } -PluginFactory::PluginFactory(PluginFactoryPrivate &d) - : d_ptr_p(&d) +PluginFactory::PluginFactory( PluginFactoryPrivate& d ) + : d_ptr( &d ) { - factorycleanup()->add(this); + factorycleanup()->add( this ); } PluginFactory::~PluginFactory() { - delete d_ptr_p; + delete d_ptr; } -void PluginFactory::doRegisterPlugin(const QString &keyword, const QMetaObject *metaObject, CreateInstanceFunction instanceFunction) +void PluginFactory::doRegisterPlugin( const QString& keyword, const QMetaObject* metaObject, CreateInstanceFunction instanceFunction ) { - Q_D(PluginFactory); + Q_D( PluginFactory ); - Q_ASSERT(metaObject); + Q_ASSERT( metaObject ); // we allow different interfaces to be registered without keyword - if (!keyword.isEmpty()) { - if (d->createInstanceHash.contains(keyword)) { + if ( !keyword.isEmpty() ) + { + if ( d->createInstanceHash.contains( keyword ) ) qWarning() << "A plugin with the keyword" << keyword << "was already registered. A keyword must be unique!"; - } - d->createInstanceHash.insert(keyword, PluginFactoryPrivate::Plugin(metaObject, instanceFunction)); - } else { - const QList clashes(d->createInstanceHash.values(keyword)); - const QMetaObject *superClass = metaObject->superClass(); - if (superClass) { - for (const PluginFactoryPrivate::Plugin &plugin : clashes) { - for (const QMetaObject *otherSuper = plugin.first->superClass(); otherSuper; - otherSuper = otherSuper->superClass()) { - if (superClass == otherSuper) { + d->createInstanceHash.insert( keyword, PluginFactoryPrivate::Plugin( metaObject, instanceFunction ) ); + } + else + { + const QList clashes( d->createInstanceHash.values( keyword ) ); + const QMetaObject* superClass = metaObject->superClass(); + if ( superClass ) + { + for ( const PluginFactoryPrivate::Plugin& plugin : clashes ) + { + for ( const QMetaObject* otherSuper = plugin.first->superClass(); otherSuper; + otherSuper = otherSuper->superClass() ) + { + if ( superClass == otherSuper ) qWarning() << "Two plugins with the same interface(" << superClass->className() << ") were registered. Use keywords to identify the plugins."; - } } } } - for (const PluginFactoryPrivate::Plugin &plugin : clashes) { + for ( const PluginFactoryPrivate::Plugin& plugin : clashes ) + { superClass = plugin.first->superClass(); - if (superClass) { - for (const QMetaObject *otherSuper = metaObject->superClass(); otherSuper; - otherSuper = otherSuper->superClass()) { - if (superClass == otherSuper) { + if ( superClass ) + { + for ( const QMetaObject* otherSuper = metaObject->superClass(); otherSuper; + otherSuper = otherSuper->superClass() ) + { + if ( superClass == otherSuper ) qWarning() << "Two plugins with the same interface(" << superClass->className() << ") were registered. Use keywords to identify the plugins."; - } } } } - d->createInstanceHash.insertMulti(keyword, PluginFactoryPrivate::Plugin(metaObject, instanceFunction)); + d->createInstanceHash.insertMulti( keyword, PluginFactoryPrivate::Plugin( metaObject, instanceFunction ) ); } } -QObject *PluginFactory::create(const char *iface, QWidget *parentWidget, QObject *parent, const QString &keyword) +QObject* PluginFactory::create( const char* iface, QWidget* parentWidget, QObject* parent, const QString& keyword ) { - Q_D(PluginFactory); + Q_D( PluginFactory ); - QObject *obj( nullptr ); + QObject* obj = 0; - const QList candidates(d->createInstanceHash.values(keyword)); + const QList candidates( d->createInstanceHash.values( keyword ) ); // for !keyword.isEmpty() candidates.count() is 0 or 1 - for (const PluginFactoryPrivate::Plugin &plugin : candidates) { - for (const QMetaObject *current = plugin.first; current; current = current->superClass()) { - if (0 == qstrcmp(iface, current->className())) { - if (obj) { + for ( const PluginFactoryPrivate::Plugin& plugin : candidates ) + { + for ( const QMetaObject* current = plugin.first; current; current = current->superClass() ) + { + if ( 0 == qstrcmp( iface, current->className() ) ) + { + if ( obj ) qWarning() << "ambiguous interface requested from a DSO containing more than one plugin"; - } - obj = plugin.second(parentWidget, parent); + obj = plugin.second( parentWidget, parent ); break; } } } - if (obj) { - emit objectCreated(obj); - } + if ( obj ) + emit objectCreated( obj ); return obj; } diff --git a/src/libcalamares/utils/PluginFactory.h b/src/libcalamares/utils/PluginFactory.h index d7dc61783..a1f1597b5 100644 --- a/src/libcalamares/utils/PluginFactory.h +++ b/src/libcalamares/utils/PluginFactory.h @@ -222,7 +222,7 @@ public: * \returns A pointer to the created object is returned, or 0 if an error occurred. */ template - T* create( QObject* parent = nullptr ); + T* create( QObject* parent = 0 ); /** * Use this method to create an object. It will try to create an object which inherits @@ -235,7 +235,7 @@ public: * \returns A pointer to the created object is returned, or 0 if an error occurred. */ template - T* create( const QString& keyword, QObject* parent = nullptr ); + T* create( const QString& keyword, QObject* parent = 0 ); Q_SIGNALS: void objectCreated( QObject* object ); @@ -300,7 +300,7 @@ protected: doRegisterPlugin( keyword, &T::staticMetaObject, instanceFunction ); } - PluginFactoryPrivate* const d_ptr_p; + PluginFactoryPrivate* const d_ptr; /** * This function is called when the factory asked to create an Object. @@ -321,7 +321,7 @@ protected: static QObject* createInstance( QWidget* parentWidget, QObject* parent ) { Q_UNUSED( parentWidget ); - ParentType* p( nullptr ); + ParentType* p = 0; if ( parent ) { p = qobject_cast( parent ); @@ -338,7 +338,7 @@ template inline T* PluginFactory::create( QObject* parent ) { QObject* o = create( T::staticMetaObject.className(), - parent && parent->isWidgetType() ? reinterpret_cast( parent ) : nullptr, + parent && parent->isWidgetType() ? reinterpret_cast( parent ) : 0, parent, QString() ); @@ -352,7 +352,7 @@ template inline T* PluginFactory::create( const QString& keyword, QObject* parent ) { QObject* o = create( T::staticMetaObject.className(), - parent && parent->isWidgetType() ? reinterpret_cast( parent ) : nullptr, + parent && parent->isWidgetType() ? reinterpret_cast( parent ) : 0, parent, keyword ); diff --git a/src/libcalamaresui/modulesystem/CppJobModule.h b/src/libcalamaresui/modulesystem/CppJobModule.h index 92c4224d3..9ec8a6eaa 100644 --- a/src/libcalamaresui/modulesystem/CppJobModule.h +++ b/src/libcalamaresui/modulesystem/CppJobModule.h @@ -25,7 +25,8 @@ class QPluginLoader; -namespace Calamares { +namespace Calamares +{ class UIDLLEXPORT CppJobModule : public Module { @@ -42,7 +43,7 @@ protected: private: friend class Module; //so only the superclass can instantiate explicit CppJobModule(); - virtual ~CppJobModule() override; + virtual ~CppJobModule(); QPluginLoader* m_loader; job_ptr m_job; diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.h b/src/libcalamaresui/modulesystem/ProcessJobModule.h index 5bb1699be..7809d0d2f 100644 --- a/src/libcalamaresui/modulesystem/ProcessJobModule.h +++ b/src/libcalamaresui/modulesystem/ProcessJobModule.h @@ -23,7 +23,8 @@ #include "UiDllMacro.h" -namespace Calamares { +namespace Calamares +{ class UIDLLEXPORT ProcessJobModule : public Module { @@ -40,7 +41,7 @@ protected: private: friend class Module; explicit ProcessJobModule(); - virtual ~ProcessJobModule() override; + virtual ~ProcessJobModule(); QString m_command; QString m_workingPath; diff --git a/src/libcalamaresui/modulesystem/ViewModule.h b/src/libcalamaresui/modulesystem/ViewModule.h index bfbbdadf3..d36b58db9 100644 --- a/src/libcalamaresui/modulesystem/ViewModule.h +++ b/src/libcalamaresui/modulesystem/ViewModule.h @@ -24,7 +24,8 @@ class QPluginLoader; -namespace Calamares { +namespace Calamares +{ class ViewStep; @@ -43,7 +44,7 @@ protected: private: friend class Module; //so only the superclass can instantiate explicit ViewModule(); - virtual ~ViewModule() override; + virtual ~ViewModule(); QPluginLoader* m_loader; ViewStep* m_viewStep = nullptr;