[libcalamares] Silence compiler warnings about PluginFactories
- d_ptr shadows QObject d_ptr, which clang complains about - rename, and don't use Q_D and similar because it messes with internals.
This commit is contained in:
parent
510af704d8
commit
86b899566e
@ -33,41 +33,38 @@ namespace Calamares
|
|||||||
{
|
{
|
||||||
|
|
||||||
PluginFactory::PluginFactory()
|
PluginFactory::PluginFactory()
|
||||||
: d_ptr( new PluginFactoryPrivate )
|
: pd_ptr( new PluginFactoryPrivate )
|
||||||
{
|
{
|
||||||
Q_D( PluginFactory );
|
pd_ptr->q_ptr = this;
|
||||||
d->q_ptr = this;
|
|
||||||
|
|
||||||
factorycleanup()->add( this );
|
factorycleanup()->add( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginFactory::PluginFactory( PluginFactoryPrivate& d )
|
PluginFactory::PluginFactory( PluginFactoryPrivate& d )
|
||||||
: d_ptr( &d )
|
: pd_ptr( &d )
|
||||||
{
|
{
|
||||||
factorycleanup()->add( this );
|
factorycleanup()->add( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginFactory::~PluginFactory()
|
PluginFactory::~PluginFactory()
|
||||||
{
|
{
|
||||||
delete d_ptr;
|
delete pd_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_ASSERT( metaObject );
|
Q_ASSERT( metaObject );
|
||||||
|
|
||||||
// we allow different interfaces to be registered without keyword
|
// we allow different interfaces to be registered without keyword
|
||||||
if ( !keyword.isEmpty() )
|
if ( !keyword.isEmpty() )
|
||||||
{
|
{
|
||||||
if ( d->createInstanceHash.contains( keyword ) )
|
if ( pd_ptr->createInstanceHash.contains( keyword ) )
|
||||||
qWarning() << "A plugin with the keyword" << keyword << "was already registered. A keyword must be unique!";
|
qWarning() << "A plugin with the keyword" << keyword << "was already registered. A keyword must be unique!";
|
||||||
d->createInstanceHash.insert( keyword, PluginFactoryPrivate::Plugin( metaObject, instanceFunction ) );
|
pd_ptr->createInstanceHash.insert( keyword, PluginFactoryPrivate::Plugin( metaObject, instanceFunction ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const QList<PluginFactoryPrivate::Plugin> clashes( d->createInstanceHash.values( keyword ) );
|
const QList<PluginFactoryPrivate::Plugin> clashes( pd_ptr->createInstanceHash.values( keyword ) );
|
||||||
const QMetaObject* superClass = metaObject->superClass();
|
const QMetaObject* superClass = metaObject->superClass();
|
||||||
if ( superClass )
|
if ( superClass )
|
||||||
{
|
{
|
||||||
@ -94,17 +91,15 @@ void PluginFactory::doRegisterPlugin( const QString& keyword, const QMetaObject*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d->createInstanceHash.insertMulti( keyword, PluginFactoryPrivate::Plugin( metaObject, instanceFunction ) );
|
pd_ptr->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 );
|
|
||||||
|
|
||||||
QObject* obj = nullptr;
|
QObject* obj = nullptr;
|
||||||
|
|
||||||
const QList<PluginFactoryPrivate::Plugin> candidates( d->createInstanceHash.values( keyword ) );
|
const QList<PluginFactoryPrivate::Plugin> candidates( pd_ptr->createInstanceHash.values( keyword ) );
|
||||||
// for !keyword.isEmpty() candidates.count() is 0 or 1
|
// for !keyword.isEmpty() candidates.count() is 0 or 1
|
||||||
|
|
||||||
for ( const PluginFactoryPrivate::Plugin& plugin : candidates )
|
for ( const PluginFactoryPrivate::Plugin& plugin : candidates )
|
||||||
|
@ -148,7 +148,7 @@ namespace Calamares
|
|||||||
class DLLEXPORT PluginFactory : public QObject
|
class DLLEXPORT PluginFactory : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DECLARE_PRIVATE( PluginFactory )
|
friend class PluginFactoryPrivate;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* This constructor creates a factory for a plugin.
|
* This constructor creates a factory for a plugin.
|
||||||
@ -249,7 +249,7 @@ protected:
|
|||||||
doRegisterPlugin( keyword, &T::staticMetaObject, instanceFunction );
|
doRegisterPlugin( keyword, &T::staticMetaObject, instanceFunction );
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginFactoryPrivate* const d_ptr;
|
PluginFactoryPrivate* const pd_ptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is called when the factory asked to create an Object.
|
* This function is called when the factory asked to create an Object.
|
||||||
|
Loading…
Reference in New Issue
Block a user