From fb453b5461c1f122e5ba41d76c2748aa755cd89d Mon Sep 17 00:00:00 2001 From: Max Gaukler Date: Wed, 11 Dec 2024 19:55:04 +0100 Subject: [PATCH] Snap package: Fix extensions hanging Bring the old snap-specific patch into the main code. Now Inkscape does not hang up anymore when extensions are used. Main issue: https://gitlab.com/inkscape/inkscape/-/issues/5414 --- snap/local/glib-spawn-no-close.patch | 16 ---------------- snap/snapcraft.yaml | 1 - src/extension/implementation/script.cpp | 21 ++++++++++++++------- 3 files changed, 14 insertions(+), 24 deletions(-) delete mode 100644 snap/local/glib-spawn-no-close.patch diff --git a/snap/local/glib-spawn-no-close.patch b/snap/local/glib-spawn-no-close.patch deleted file mode 100644 index b12a650c8c..0000000000 --- a/snap/local/glib-spawn-no-close.patch +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Disable closing file descriptors because the snap confinement has some -# that it doesn't want us to close -diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp -index a3896d41b6..88c6b826d5 100644 ---- a/src/extension/implementation/script.cpp -+++ b/src/extension/implementation/script.cpp -@@ -796,7 +796,7 @@ int Script::execute (const std::list &in_command, - try { - Glib::spawn_async_with_pipes(working_directory, // working directory - argv, // arg v -- static_cast(0), // no flags -+ Glib::SPAWN_LEAVE_DESCRIPTORS_OPEN, - sigc::slot(), - &_pid, // Pid - nullptr, // STDIN diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index e78c9c754b..8381ca3fad 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -124,7 +124,6 @@ parts: - -lib/inkscape/*.a - -*canberra*so* # We don't have sound permissions anyway - -usr/lib/*/gtk-2.0 -# TODO removed patch -p1 --batch --directory=$SNAPCRAFT_PART_SRC --input=$SNAPCRAFT_PART_SRC/snap/local/glib-spawn-no-close.patch override-build: | sed -i.bak -e 's|Icon=${INKSCAPE_ICONPATH}|Icon=${SNAP}/share/inkscape/branding/inkscape.svg|g' $SNAPCRAFT_PART_SRC/org.inkscape.Inkscape.desktop.template snapcraftctl build diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index d6b0e337a3..e51d2e7e8c 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -754,14 +754,21 @@ int Script::execute (const std::list &in_command, int stdout_pipe, stderr_pipe; try { + auto spawn_flags = Glib::SpawnFlags::DEFAULT; + if (Glib::getenv("SNAP") != "") { + // If we are running within the Linux "snap" package format, + // we need different spawn flags to avoid that Inkscape hangs when + // starting an extension. + spawn_flags = Glib::SpawnFlags::LEAVE_DESCRIPTORS_OPEN; + } Glib::spawn_async_with_pipes(working_directory, // working directory - argv, // arg v - static_cast(0), // no flags - sigc::slot(), - &_pid, // Pid - nullptr, // STDIN - &stdout_pipe, // STDOUT - &stderr_pipe); // STDERR + argv, // arg v + spawn_flags, // spawn flags + sigc::slot(), + &_pid, // Pid + nullptr, // STDIN + &stdout_pipe, // STDOUT + &stderr_pipe); // STDERR } catch (Glib::Error const &e) { g_critical("Script::execute(): failed to execute program '%s'.\n\tReason: %s", program.c_str(), e.what()); return 0; -- GitLab