From 86d3932a16459768a22073eeed6263a74550ff1b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 26 Jun 2022 23:06:31 +0200 Subject: [PATCH] [calamares] Hook up to KDSAG again (instead of DBus activation) --- 3rdparty/kdsingleapplication/CMakeLists.txt | 3 +++ CMakeLists.txt | 11 ++--------- src/calamares/CMakeLists.txt | 6 +----- src/calamares/main.cpp | 20 ++++++++++++++++---- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/3rdparty/kdsingleapplication/CMakeLists.txt b/3rdparty/kdsingleapplication/CMakeLists.txt index aca2df70b..6c0b8e9c0 100644 --- a/3rdparty/kdsingleapplication/CMakeLists.txt +++ b/3rdparty/kdsingleapplication/CMakeLists.txt @@ -1,3 +1,5 @@ +set(KDSINGLEAPPLICATION_STATIC ON) + set(KDSINGLEAPPLICATION_SRCS kdsingleapplication.cpp kdsingleapplication_localsocket.cpp) set(KDSINGLEAPPLICATION_INSTALLABLE_INCLUDES kdsingleapplication.h kdsingleapplication_lib.h) @@ -11,6 +13,7 @@ else() add_library(kdsingleapplication SHARED ${KDSINGLEAPPLICATION_INSTALLABLE_INCLUDES} ${KDSINGLEAPPLICATION_SRCS}) target_compile_definitions(kdsingleapplication PRIVATE KDSINGLEAPPLICATION_SHARED_BUILD) endif() +set_target_properties( kdsingleapplication PROPERTIES AUTOMOC TRUE ) set(KDSINGLEAPPLICATION_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/kdsingleapplication) diff --git a/CMakeLists.txt b/CMakeLists.txt index 707a45c00..6eaa5cebf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -321,7 +321,7 @@ if(ECM_FOUND) include(KDEInstallDirs) endif() -find_package(KF5 QUIET COMPONENTS CoreAddons Crash DBusAddons) +find_package(KF5 QUIET COMPONENTS CoreAddons Crash) set_package_properties( KF5::CoreAddons PROPERTIES @@ -330,14 +330,6 @@ set_package_properties( URL "https://api.kde.org/frameworks/kcoreaddons/" PURPOSE "About Calamares" ) -set_package_properties( - KF5::DBusAddons - PROPERTIES - TYPE REQUIRED - DESCRIPTION "Classes for DBus activation" - URL "https://api.kde.org/frameworks/dbusaddons/" - PURPOSE "Unique instance of Calamares" -) if(NOT KF5Crash_FOUND) if(BUILD_KF5Crash) message(WARNING "BUILD_KF5Crash is set, but KF5::Crash is not available.") @@ -551,6 +543,7 @@ include(GNUInstallDirs) # libraries for Calamares. set(Calamares_LIBRARIES calamares) +add_subdirectory(3rdparty/kdsingleapplication) add_subdirectory(src) add_feature_info(Python ${WITH_PYTHON} "Python job modules") diff --git a/src/calamares/CMakeLists.txt b/src/calamares/CMakeLists.txt index b132f186a..291297494 100644 --- a/src/calamares/CMakeLists.txt +++ b/src/calamares/CMakeLists.txt @@ -36,13 +36,9 @@ calamares_automoc( calamares_bin ) calamares_autouic( calamares_bin ) calamares_autorcc( calamares_bin ) -if(kdsagSources) - set_source_files_properties(${kdsagSources} PROPERTIES AUTOMOC OFF) -endif() - target_link_libraries( calamares_bin - PRIVATE calamares calamaresui calamares-i18n Qt5::Core Qt5::Widgets KF5::CoreAddons KF5::DBusAddons + PRIVATE calamares calamaresui calamares-i18n kdsingleapplication Qt5::Core Qt5::Widgets KF5::CoreAddons ) if(BUILD_KF5Crash) target_link_libraries(calamares_bin PRIVATE KF5::Crash) diff --git a/src/calamares/main.cpp b/src/calamares/main.cpp index fcc946485..495127881 100644 --- a/src/calamares/main.cpp +++ b/src/calamares/main.cpp @@ -16,8 +16,10 @@ #include "utils/Logger.h" #include "utils/Retranslator.h" +// From 3rdparty/ +#include "kdsingleapplication.h" + #include -#include #ifdef BUILD_KF5Crash #include #endif @@ -26,6 +28,8 @@ #include #include +#include + /** @brief Gets debug-level from -D command-line-option * * If unset, use LOGERROR (corresponding to -D1), although @@ -124,9 +128,17 @@ main( int argc, char* argv[] ) KCrash::setFlags( KCrash::SaferDialog | KCrash::AlwaysDirectly ); #endif - bool is_debug = handle_args( a ); - - KDBusService service( is_debug ? KDBusService::Multiple : KDBusService::Unique ); + std::unique_ptr< KDSingleApplication > possiblyUnique; + const bool is_debug = handle_args( a ); + if ( !is_debug ) + { + possiblyUnique = std::make_unique< KDSingleApplication >(); + if ( !possiblyUnique->isPrimaryInstance() ) + { + qCritical() << "Calamares is already running."; + return 87; // EUSERS on Linux + } + } Calamares::Settings::init( is_debug ); if ( !Calamares::Settings::instance() || !Calamares::Settings::instance()->isValid() )