fix: OFX param instance lifecycle and thread-safety fixes

- Fix SIGSEGV in PluginMisc.Keyer by linking Param::SetInstance to instances.
    Olive's custom param instances (IntegerInstance, DoubleInstance, etc.) were
    not passing the SetInstance pointer to the OpenFX HostSupport base class,
    leaving _paramSetInstance as nullptr. When Keyer called paramSetValue during
    createInstanceAction, the suite function dereferenced the null pointer in
    paramChangedByPlugin(). Now newParam() passes 'this' to every constructor.

  - Fix render-thread crash when OFX plugins set params during rendering.
    MinOFX calls paramSetValue inside createInstanceAction from the render
    thread. SubmitUndoCommand() used to push undo commands directly to
    UndoStack, which modifies QAction state (GUI-only). Added IsGuiThread()
    check: non-GUI threads execute redo_now() and discard the command without
    touching the undo stack.

  - Enable PluginMisc.MergeOver and PluginMisc.Keyer integration tests.
    MergeOver now supplies both Source and Bg textures; Keyer uses U16 format.
    Both pass in the full test suite.

  - Make ViewerQueue thread-safe with QMutex around AppendTimewise/PurgeBefore.
    Adds copy ctor and assignment to support mutex-per-instance semantics.
This commit is contained in:
2026-05-14 22:32:34 +08:00
parent 4aa4d59770
commit e85c6cf60a
6 changed files with 122 additions and 67 deletions
+22 -12
View File
@@ -426,12 +426,18 @@ TEST(PluginMisc, MergeOver)
GTEST_SKIP() << "OFX integration test not enabled";
}
// FIXME: Merge plugin crashes during render. Needs investigation.
// The crash happens inside PluginRenderer::RenderPlugin, likely due to:
// 1. Multi-input plugin handling issues
// 2. Missing parameter initialization for the merge operation
// 3. Clip format compatibility issues between A and B inputs
GTEST_SKIP() << "Merge plugin crashes - needs fix in multi-input handling";
VideoParams params(320, 240, core::PixelFormat::U8, 4);
TexturePtr input = CreateSolidTexture(params, 0x80);
ASSERT_NE(input, nullptr);
NodeValueRow row;
row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName),
NodeValue(NodeValue::kTexture, input));
row.insert(QStringLiteral("Bg"),
NodeValue(NodeValue::kTexture, input));
bool result = RenderPlugin("net.sf.openfx.MergePlugin", params, row, true);
EXPECT_TRUE(result) << "Merge plugin should produce output";
}
// ============================================================================
@@ -444,12 +450,16 @@ TEST(PluginMisc, Keyer)
GTEST_SKIP() << "OFX integration test not enabled";
}
// FIXME: Keyer plugin crashes during render. Needs investigation.
// The crash happens inside PluginRenderer::RenderPlugin. Possible causes:
// 1. Keyer requires additional optional inputs (Bg, InM, OutM) to be explicitly unset
// 2. Parameter initialization issues (keyColor, mode, etc.)
// 3. The plugin explicitly disables UByte support, U16/F32 may need special handling
GTEST_SKIP() << "Keyer plugin crashes - needs investigation";
VideoParams params(320, 240, core::PixelFormat::U16, 4);
TexturePtr input = CreateSolidTexture(params, 0x80);
ASSERT_NE(input, nullptr);
NodeValueRow row;
row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName),
NodeValue(NodeValue::kTexture, input));
bool result = RenderPlugin("net.sf.openfx.KeyerPlugin", params, row, true);
EXPECT_TRUE(result) << "Keyer plugin should produce output";
}
// ============================================================================