Revert be2338ff0
(intended just to reduce warnings)
- keep the calamaresstyle formatting changes, - drop shadowing and nullptr changes. FIXES #805
This commit is contained in:
parent
a14e98ce95
commit
ddb6455365
@ -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;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <QObjectCleanupHandler>
|
||||
#include <QDebug>
|
||||
|
||||
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<PluginFactoryPrivate::Plugin> 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<PluginFactoryPrivate::Plugin> 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<PluginFactoryPrivate::Plugin> candidates(d->createInstanceHash.values(keyword));
|
||||
const QList<PluginFactoryPrivate::Plugin> 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;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ public:
|
||||
* \returns A pointer to the created object is returned, or 0 if an error occurred.
|
||||
*/
|
||||
template<typename T>
|
||||
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<typename T>
|
||||
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<ParentType*>( parent );
|
||||
@ -338,7 +338,7 @@ template<typename T>
|
||||
inline T* PluginFactory::create( QObject* parent )
|
||||
{
|
||||
QObject* o = create( T::staticMetaObject.className(),
|
||||
parent && parent->isWidgetType() ? reinterpret_cast<QWidget*>( parent ) : nullptr,
|
||||
parent && parent->isWidgetType() ? reinterpret_cast<QWidget*>( parent ) : 0,
|
||||
parent,
|
||||
QString() );
|
||||
|
||||
@ -352,7 +352,7 @@ template<typename T>
|
||||
inline T* PluginFactory::create( const QString& keyword, QObject* parent )
|
||||
{
|
||||
QObject* o = create( T::staticMetaObject.className(),
|
||||
parent && parent->isWidgetType() ? reinterpret_cast<QWidget*>( parent ) : nullptr,
|
||||
parent && parent->isWidgetType() ? reinterpret_cast<QWidget*>( parent ) : 0,
|
||||
parent,
|
||||
keyword );
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user