diff --git a/src/plugins/lua/bindings/qtcprocess.cpp b/src/plugins/lua/bindings/qtcprocess.cpp index d5a02440590..0aa6ccfa9b3 100644 --- a/src/plugins/lua/bindings/qtcprocess.cpp +++ b/src/plugins/lua/bindings/qtcprocess.cpp @@ -60,6 +60,7 @@ void setupProcessModule() const auto stdOut = parameter.get>("stdout"); const auto stdErr = parameter.get>("stderr"); const auto stdIn = parameter.get>("stdin"); + const auto onFinished = parameter.get>("onFinished"); auto p = std::make_unique(); @@ -86,6 +87,16 @@ void setupProcessModule() }); // clang-format on } + + if (onFinished) { + // clang-format off + QObject::connect(p.get(), &Process::done, + p.get(), + [p = p.get(), cb = *onFinished]() { + void_safe_call(cb); + }); + // clang-format on + } return p; }; diff --git a/src/plugins/lua/meta/process.lua b/src/plugins/lua/meta/process.lua index 017524fc7cd..21c2a7127d2 100644 --- a/src/plugins/lua/meta/process.lua +++ b/src/plugins/lua/meta/process.lua @@ -24,6 +24,7 @@ process.Process = {} ---@field stdin? string The input to write to stdin. ---@field stdout? function The callback to call when the process writes to stdout. ---@field stderr? function The callback to call when the process writes to stderr. +---@field onFinished? function () The callback to call when the process finishes. process.ProcessParameters = {} ---Creates a new process object.