[libcalamaresui] Avoid metatype warnings at runtime

- Register the types with the Qt type system. This is needed
   because we're passing them as signal and slot parameters
   across threads.
main
Adriaan de Groot 6 years ago
parent f1aa22d9e8
commit 41fecf341b

@ -95,7 +95,7 @@ signals:
void modulesFailed( QStringList ); /// .. or not
// Below, see RequirementsChecker documentation
void requirementsComplete( bool );
void requirementsResult( RequirementsList& );
void requirementsResult( RequirementsList );
void requirementsProgress( const QString& );
private slots:

@ -19,6 +19,7 @@
#define CALAMARES_REQUIREMENT_H
#include <QList>
#include <QMetaType>
#include <QString>
#include <functional>
@ -57,4 +58,7 @@ struct RequirementEntry
using RequirementsList = QList< RequirementEntry >;
} // namespace Calamares
Q_DECLARE_METATYPE(Calamares::RequirementEntry)
#endif

@ -34,7 +34,26 @@
namespace Calamares
{
void
static void
registerMetatypes()
{
static bool done = false;
if ( !done )
{
qRegisterMetaType< RequirementEntry >( "RequirementEntry" );
// It's sensitive to the names of types in parameters; in particular
// althrough QList<RequirementEntry> is the same as RequirementsList,
// because we *name* the type as RequirementsList in the parameters,
// we need to register that (as well). Here, be safe and register
// both names.
qRegisterMetaType< QList< RequirementEntry > >( "QList<RequirementEntry>" );
qRegisterMetaType< RequirementsList >( "RequirementsList" );
done = true;
}
}
static void
check( Module * const &m, RequirementsChecker *c )
{
RequirementsList l = m->checkRequirements();
@ -49,6 +68,8 @@ RequirementsChecker::RequirementsChecker( QVector< Module* > modules, QObject* p
{
m_watchers.reserve( m_modules.count() );
m_collectedRequirements.reserve( m_modules.count() );
registerMetatypes();
}
RequirementsChecker::~RequirementsChecker()

@ -53,7 +53,7 @@ signals:
/// @brief Human-readable progress message
void requirementsProgress( const QString& );
/// @brief Requirements from a single module
void requirementsResult( RequirementsList& );
void requirementsResult( RequirementsList );
/** @brief When all requirements are collected
*
* The argument indicates if all mandatory requirements are satisfied.

Loading…
Cancel
Save