mirror of
https://github.com/parchlinux/calamares.git
synced 2025-07-03 04:15:37 -04:00
[libcalamaresui] Use modern C++ for (auto)deleting failed modules
This commit is contained in:
parent
eddee7d76a
commit
b66d4856e7
1 changed files with 7 additions and 9 deletions
|
@ -64,7 +64,7 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
|
||||||
const QString& configFileName,
|
const QString& configFileName,
|
||||||
const QString& moduleDirectory )
|
const QString& moduleDirectory )
|
||||||
{
|
{
|
||||||
Module* m = nullptr;
|
std::unique_ptr<Module> m;
|
||||||
|
|
||||||
QString typeString = moduleDescriptor.value( "type" ).toString();
|
QString typeString = moduleDescriptor.value( "type" ).toString();
|
||||||
QString intfString = moduleDescriptor.value( "interface" ).toString();
|
QString intfString = moduleDescriptor.value( "interface" ).toString();
|
||||||
|
@ -79,12 +79,12 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
|
||||||
{
|
{
|
||||||
if ( intfString == "qtplugin" )
|
if ( intfString == "qtplugin" )
|
||||||
{
|
{
|
||||||
m = new ViewModule();
|
m.reset( new ViewModule() );
|
||||||
}
|
}
|
||||||
else if ( intfString == "pythonqt" )
|
else if ( intfString == "pythonqt" )
|
||||||
{
|
{
|
||||||
#ifdef WITH_PYTHONQT
|
#ifdef WITH_PYTHONQT
|
||||||
m = new PythonQtViewModule();
|
m.reset( new PythonQtViewModule() );
|
||||||
#else
|
#else
|
||||||
cError() << "PythonQt view modules are not supported in this version of Calamares.";
|
cError() << "PythonQt view modules are not supported in this version of Calamares.";
|
||||||
#endif
|
#endif
|
||||||
|
@ -96,16 +96,16 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
|
||||||
{
|
{
|
||||||
if ( intfString == "qtplugin" )
|
if ( intfString == "qtplugin" )
|
||||||
{
|
{
|
||||||
m = new CppJobModule();
|
m.reset( new CppJobModule() );
|
||||||
}
|
}
|
||||||
else if ( intfString == "process" )
|
else if ( intfString == "process" )
|
||||||
{
|
{
|
||||||
m = new ProcessJobModule();
|
m.reset( new ProcessJobModule() );
|
||||||
}
|
}
|
||||||
else if ( intfString == "python" )
|
else if ( intfString == "python" )
|
||||||
{
|
{
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
m = new PythonJobModule();
|
m.reset( new PythonJobModule() );
|
||||||
#else
|
#else
|
||||||
cError() << "Python modules are not supported in this version of Calamares.";
|
cError() << "Python modules are not supported in this version of Calamares.";
|
||||||
#endif
|
#endif
|
||||||
|
@ -130,7 +130,6 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cError() << "Bad module directory" << moduleDirectory << "for" << instanceId;
|
cError() << "Bad module directory" << moduleDirectory << "for" << instanceId;
|
||||||
delete m;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,10 +143,9 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
|
||||||
catch ( YAML::Exception& e )
|
catch ( YAML::Exception& e )
|
||||||
{
|
{
|
||||||
cError() << "YAML parser error " << e.what();
|
cError() << "YAML parser error " << e.what();
|
||||||
delete m;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return m;
|
return m.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue