[libcalamares] Use shared_ptr instead of unique_ptr
The value inside a unique_ptr can't be opaque, it needs to be known at any site where the pointer may be deleted. shared_ptr does not have that (deletion is part of the shared_ptr object, which is larger than the unique_ptr) and so can be used for opaque deletions.
This commit is contained in:
parent
1c4bf58fb4
commit
3150785ff1
@ -67,10 +67,10 @@ querySolidAutoMount( QDBusConnection& dbus, AutoMountInfo& info )
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr< AutoMountInfo >
|
||||
std::shared_ptr< AutoMountInfo >
|
||||
automountDisable( bool disable )
|
||||
{
|
||||
auto u = std::make_unique< AutoMountInfo >();
|
||||
auto u = std::make_shared< AutoMountInfo >();
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
querySolidAutoMount( dbus, *u );
|
||||
enableSolidAutoMount( dbus, !disable );
|
||||
@ -79,7 +79,7 @@ automountDisable( bool disable )
|
||||
|
||||
|
||||
void
|
||||
automountRestore( std::unique_ptr< AutoMountInfo >&& t )
|
||||
automountRestore( std::shared_ptr< AutoMountInfo >&& t )
|
||||
{
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
enableSolidAutoMount( dbus, t->wasSolidModuleAutoLoaded );
|
||||
|
@ -36,14 +36,14 @@ struct AutoMountInfo;
|
||||
* Returns an opaque structure which can be passed to automountRestore()
|
||||
* to return the system to the previously-configured automount settings.
|
||||
*/
|
||||
DLLEXPORT std::unique_ptr< AutoMountInfo > automountDisable( bool disable = true );
|
||||
DLLEXPORT std::shared_ptr< AutoMountInfo > automountDisable( bool disable = true );
|
||||
|
||||
/** @brief Restore automount settings
|
||||
*
|
||||
* Pass the value returned from automountDisable() to restore the
|
||||
* previous settings.
|
||||
*/
|
||||
DLLEXPORT void automountRestore( std::unique_ptr< AutoMountInfo >&& t );
|
||||
DLLEXPORT void automountRestore( std::shared_ptr< AutoMountInfo >&& t );
|
||||
|
||||
} // namespace Partition
|
||||
} // namespace CalamaresUtils
|
||||
|
Loading…
Reference in New Issue
Block a user