From 3150785ff1aecc4b971ab8faa597d5f4ec6eed02 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 22 Dec 2020 21:29:49 +0100 Subject: [PATCH] [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. --- src/libcalamares/partition/AutoMount.cpp | 6 +++--- src/libcalamares/partition/AutoMount.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcalamares/partition/AutoMount.cpp b/src/libcalamares/partition/AutoMount.cpp index 984662960..0fc253067 100644 --- a/src/libcalamares/partition/AutoMount.cpp +++ b/src/libcalamares/partition/AutoMount.cpp @@ -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 ); diff --git a/src/libcalamares/partition/AutoMount.h b/src/libcalamares/partition/AutoMount.h index b77bdbae6..a9a88e320 100644 --- a/src/libcalamares/partition/AutoMount.h +++ b/src/libcalamares/partition/AutoMount.h @@ -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