[calamares] Allow test-loading of View modules

The view modules need a QApplication, not just a core application,
and a ViewManager instance, so create those before really loading
the module.
This commit is contained in:
Adriaan de Groot 2018-03-05 13:36:16 +01:00
parent a0f7ef64d4
commit 58de7cea94

View file

@ -30,7 +30,9 @@
#include "Job.h"
#include "JobQueue.h"
#include "Settings.h"
#include "ViewManager.h"
#include <QApplication>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QCoreApplication>
@ -40,26 +42,10 @@
struct ModuleConfig
{
QString
moduleName() const
{
return m_module;
}
QString
configFile() const
{
return m_jobConfig;
}
QString
language() const
{
return m_language;
}
QString
globalConfigFile() const
{
return m_globalConfig;
}
QString moduleName() const { return m_module; }
QString configFile() const { return m_jobConfig; }
QString language() const { return m_language; }
QString globalConfigFile() const { return m_globalConfig; }
QString m_module;
QString m_jobConfig;
@ -202,6 +188,7 @@ int
main( int argc, char* argv[] )
{
QCoreApplication a( argc, argv );
QApplication* aw = nullptr;
ModuleConfig module = handle_args( a );
if ( module.moduleName().isEmpty() )
@ -233,6 +220,13 @@ main( int argc, char* argv[] )
return 1;
}
cDebug() << " .. got" << m->name() << m->typeString() << m->interfaceString();
if ( m->type() == Calamares::Module::Type::View )
{
aw = new QApplication( argc, argv );
(void)Calamares::ViewManager::instance( nullptr );
}
if ( !m->isLoaded() )
{
m->loadSelf();
@ -268,5 +262,10 @@ main( int argc, char* argv[] )
++count;
}
if ( aw )
{
delete aw;
}
return failure_count ? 1 : 0;
}