[partition] Delay requirements checking until pmcore is initialized

This commit is contained in:
Adriaan de Groot 2017-12-02 12:11:56 -05:00
parent ba21a221df
commit 4566e53d01
2 changed files with 13 additions and 6 deletions

View File

@ -539,17 +539,18 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
// Now that we have the config, we load the PartitionCoreModule in the background
// because it could take a while. Then when it's done, we can set up the widgets
// and remove the spinner.
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
connect( watcher, &QFutureWatcher< void >::finished,
this, [ this, watcher ]
m_future = new QFutureWatcher< void >();
connect( m_future, &QFutureWatcher< void >::finished,
this, [ this ]
{
continueLoading();
watcher->deleteLater();
this->m_future->deleteLater();
this->m_future = nullptr;
} );
QFuture< void > future =
QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule );
watcher->setFuture( future );
m_future->setFuture( future );
}
@ -561,13 +562,16 @@ PartitionViewStep::jobs() const
Calamares::RequirementsList PartitionViewStep::checkRequirements()
{
if (m_future)
m_future->waitForFinished();
Calamares::RequirementsList l;
l.append(
{
QLatin1Literal( "partitions" ),
[]{ return QString(); },
[this]{ return tr( "There are no partitons to install on." ); },
false, // satisfied
m_core->deviceModel()->rowCount() > 0, // satisfied
true // required
} );

View File

@ -33,6 +33,8 @@ class PartitionPage;
class PartitionCoreModule;
class QStackedWidget;
template<typename T> class QFutureWatcher;
/**
* The starting point of the module. Instantiates PartitionCoreModule,
* ChoicePage and PartitionPage, then connects them.
@ -78,6 +80,7 @@ private:
PartitionPage* m_manualPartitionPage;
QWidget* m_waitingWidget;
QFutureWatcher<void>* m_future;
};
CALAMARES_PLUGIN_FACTORY_DECLARATION( PartitionViewStepFactory )