aboutsummaryrefslogtreecommitdiffstats
path: root/src/m_gpg_info
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2026-09-22 22:01:19 +0200
committersaturneric <[email protected]>2026-09-22 22:01:19 +0200
commitdcb03040c930af167337bd4f47cb85e65d076b98 (patch)
tree76b4903033a6aad710b372073fdcd935ed69dcc1 /src/m_gpg_info
parentdocs(modules): document SDK and packaging workflow (diff)
downloadmodules-dcb03040c930af167337bd4f47cb85e65d076b98.tar.gz
modules-dcb03040c930af167337bd4f47cb85e65d076b98.zip
refactor(gnupg): use borrowed command execution API
- replace transferred execution contexts with sdk commands - let RunCommands manage command argument lifetimes - preserve component context cleanup after command completion
Diffstat (limited to 'src/m_gpg_info')
-rw-r--r--src/m_gpg_info/GnuPGInfoGatheringModule.cpp38
1 files changed, 14 insertions, 24 deletions
diff --git a/src/m_gpg_info/GnuPGInfoGatheringModule.cpp b/src/m_gpg_info/GnuPGInfoGatheringModule.cpp
index 062157c..a8abdd9 100644
--- a/src/m_gpg_info/GnuPGInfoGatheringModule.cpp
+++ b/src/m_gpg_info/GnuPGInfoGatheringModule.cpp
@@ -207,19 +207,13 @@ auto StartGatheringAllGnuPGInfo() -> int {
StartStartGatheringGnuPGComponentsInfo(gpgme_version, gpgconf_path,
default_home_path);
- QList<GFCommandExecuteContext> exec_contexts;
-
- // NOT borrowed: GFCommandExecuteContext is one of the few remaining
- // structs the module hands over wholesale, and GFExecuteCommandBatchSync
- // still reclaims its cmd and argv. The ownership rule applies to function
- // ARGUMENTS; this field is part of a transferred struct.
- auto exec_context = GFCommandExecuteContext{
- GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL,
- gpgconf_path.toUtf8().constData()),
- 3,
- QStringListToCharArray({"--homedir", default_home_path, "--list-dirs"}),
- GetGpgDirectoryInfos, nullptr};
- exec_contexts.push_back(exec_context);
+ // process.execute borrows everything it is given; RunCommands keeps the
+ // strings alive for the call, so nothing here is allocated for the host.
+ QList<gf::sdk::Command> commands;
+ commands.push_back({gpgconf_path,
+ {"--homedir", default_home_path, "--list-dirs"},
+ GetGpgDirectoryInfos,
+ nullptr});
// One call, one list, nothing to free by hand: the char** and count this
// replaces had to be walked and released by the caller, and the hand-rolled
@@ -251,19 +245,15 @@ auto StartGatheringAllGnuPGInfo() -> int {
new (GFMemAlloc(GFModuleSdkContext(), GF_ARENA_NORMAL, sizeof(Context)))
Context{gpgme_version, gpgconf_path, component_info};
- // Transferred, see the note above.
- auto exec_context = GFCommandExecuteContext{
- GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL,
- gpgconf_path.toUtf8().constData()),
- 4,
- QStringListToCharArray({"--homedir", default_home_path,
- "--list-options", component_info.name}),
- GetGpgOptionInfos, context};
- exec_contexts.push_back(exec_context);
+ // The context is freed by GetGpgOptionInfos once the command finishes.
+ commands.push_back({gpgconf_path,
+ {"--homedir", default_home_path, "--list-options",
+ component_info.name},
+ GetGpgOptionInfos,
+ context});
}
- GFProcessExecute(GFModuleSdkContext(), QListToArray(exec_contexts),
- static_cast<size_t>(exec_contexts.size()));
+ gf::sdk::RunCommands(GFModuleSdkContext(), commands);
gf::sdk::SetStateBool(GFModuleSdkContext(), GFModuleId(),
"gnupg.gathering_done", true);