Skip to content

Commit af1e66f

Browse files
committed
[DynamicScript] Fix single-shot instances not being properly deleted after finishing.
1 parent 4d66842 commit af1e66f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/DynamicScript.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@ class DynamicScript : public QObject
189189
return !(m_state.setFlag(State::PropertyErrorState, !ok) & State::CriticalErrorState);
190190
}
191191

192+
void setSingleShot(bool ss = true)
193+
{
194+
if (ss == singleShot)
195+
return;
196+
singleShot = ss;
197+
if (ss)
198+
connect(this, &DynamicScript::finished, m_plugin, &Plugin::onDsFinished);
199+
else
200+
disconnect(this, &DynamicScript::finished, m_plugin, &Plugin::onDsFinished);
201+
}
202+
192203
void resetEngine()
193204
{
194205
QWriteLocker lock(&m_mutex);

src/Plugin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ void Plugin::scriptAction(const QByteArray &actId, const QJsonArray &data)
453453
break;
454454

455455
case SA_SingleShot: {
456+
ds->setSingleShot();
456457
const QString &ityp = dataMap.value("type", QStringLiteral("Expression"));
457458
DynamicScript::InputType iType = ityp.isEmpty() || ityp.at(0) == 'E' ? DynamicScript::InputType::Expression : ityp.at(0) == 'S' ? DynamicScript::InputType::Script : DynamicScript::InputType::Module;
458459
ds->singleShot = true;

0 commit comments

Comments
 (0)