forked from qt-creator/qt-creator
Lua: Add onFinished callback to Process class
Change-Id: I98645f9d33842eb16b80e768523d63d660fe1813 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -60,6 +60,7 @@ void setupProcessModule()
|
||||
const auto stdOut = parameter.get<std::optional<sol::function>>("stdout");
|
||||
const auto stdErr = parameter.get<std::optional<sol::function>>("stderr");
|
||||
const auto stdIn = parameter.get<sol::optional<QString>>("stdin");
|
||||
const auto onFinished = parameter.get<std::optional<sol::function>>("onFinished");
|
||||
|
||||
auto p = std::make_unique<Process>();
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user