From 2cfcb9a3e9b3d9817ab98c8a52aa8a167e34c000 Mon Sep 17 00:00:00 2001 From: Dario Gabriel Lipicar Date: Fri, 29 May 2026 11:25:10 -0300 Subject: [PATCH] fix logosAPI variable handling --- logos-calc-module/src/calc_module_plugin.cpp | 5 ++++- logos-calc-ui-cpp/src/calc_ui_cpp_plugin.cpp | 4 +++- logos-calc-ui-cpp/src/calc_ui_cpp_plugin.h | 1 - tutorial-cpp-ui-app.md | 5 +++-- tutorial-wrapping-c-library.md | 13 +++++++------ 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/logos-calc-module/src/calc_module_plugin.cpp b/logos-calc-module/src/calc_module_plugin.cpp index 7677352..76149e0 100644 --- a/logos-calc-module/src/calc_module_plugin.cpp +++ b/logos-calc-module/src/calc_module_plugin.cpp @@ -15,7 +15,10 @@ CalcModulePlugin::~CalcModulePlugin() void CalcModulePlugin::initLogos(LogosAPI* api) { - // IMPORTANT: Use the global `logosAPI` variable from liblogos, NOT a class member. + // IMPORTANT: Assign to the inherited `logosAPI` member, NOT your own class member. + // `logosAPI` is a public member variable of the `PluginInterface` base class + // (declared in the SDK's core/interface.h); the Logos host reads it directly to + // dispatch calls. Storing the pointer in a separate `m_logosAPI` member will NOT work. logosAPI = api; qDebug() << "CalcModulePlugin: LogosAPI initialized"; } diff --git a/logos-calc-ui-cpp/src/calc_ui_cpp_plugin.cpp b/logos-calc-ui-cpp/src/calc_ui_cpp_plugin.cpp index 4d85bcf..cacddba 100644 --- a/logos-calc-ui-cpp/src/calc_ui_cpp_plugin.cpp +++ b/logos-calc-ui-cpp/src/calc_ui_cpp_plugin.cpp @@ -8,7 +8,9 @@ CalcUiCppPlugin::~CalcUiCppPlugin() { delete m_logos; } void CalcUiCppPlugin::initLogos(LogosAPI* api) { if (m_logos) return; - m_logosAPI = api; + // Assign to the inherited `logosAPI` member from PluginInterface — the Logos + // host reads it directly to dispatch calls; a separate member won't be seen. + logosAPI = api; m_logos = new LogosModules(api); // Register this object as the Remote Objects source so the QML replica // can see its properties and call its slots. diff --git a/logos-calc-ui-cpp/src/calc_ui_cpp_plugin.h b/logos-calc-ui-cpp/src/calc_ui_cpp_plugin.h index 1429f7f..98e64bd 100644 --- a/logos-calc-ui-cpp/src/calc_ui_cpp_plugin.h +++ b/logos-calc-ui-cpp/src/calc_ui_cpp_plugin.h @@ -42,7 +42,6 @@ signals: void eventResponse(const QString& eventName, const QVariantList& args); private: - LogosAPI* m_logosAPI = nullptr; LogosModules* m_logos = nullptr; }; diff --git a/tutorial-cpp-ui-app.md b/tutorial-cpp-ui-app.md index 292da9f..d3ebe85 100644 --- a/tutorial-cpp-ui-app.md +++ b/tutorial-cpp-ui-app.md @@ -244,7 +244,6 @@ signals: void eventResponse(const QString& eventName, const QVariantList& args); private: - LogosAPI* m_logosAPI = nullptr; LogosModules* m_logos = nullptr; }; ``` @@ -269,7 +268,9 @@ CalcUiCppPlugin::~CalcUiCppPlugin() { delete m_logos; } void CalcUiCppPlugin::initLogos(LogosAPI* api) { - m_logosAPI = api; + // Assign to the inherited `logosAPI` member from PluginInterface — the Logos + // host reads it directly to dispatch calls; a separate member won't be seen. + logosAPI = api; m_logos = new LogosModules(api); // Register this object as the Remote Objects source setBackend(this); diff --git a/tutorial-wrapping-c-library.md b/tutorial-wrapping-c-library.md index ea6e2ec..ec88708 100644 --- a/tutorial-wrapping-c-library.md +++ b/tutorial-wrapping-c-library.md @@ -481,7 +481,7 @@ signals: - `initLogos` must be `Q_INVOKABLE` but **not** `override` — the base class `PluginInterface` does not declare it as virtual; the Logos host calls it reflectively via `QMetaObject::invokeMethod` - `eventResponse` signal is required for event forwarding between modules. Emit it to push data to subscribers (e.g., QML UIs listening via `logos.onModuleEvent()`) - `name()` must return the same string as the `name` field in `metadata.json` -- **No `m_logosAPI` member variable** — the `LogosAPI`\* pointer is stored in the global `logosAPI` variable defined in `liblogos`, not in a class member. See the `initLogos` implementation below. +- **No `m_logosAPI` member variable** — store the `LogosAPI`\* pointer in the inherited `logosAPI` member, a public member variable of the `PluginInterface` base class (declared in the SDK's `core/interface.h`), not in your own class member. The Logos host reads this inherited member directly to dispatch inter-module calls. See the `initLogos` implementation below. ### 2.6 `src/calc_module_plugin.cpp` — Plugin Implementation @@ -507,9 +507,10 @@ CalcModulePlugin::~CalcModulePlugin() void CalcModulePlugin::initLogos(LogosAPI* api) { - // IMPORTANT: Use the global `logosAPI` variable from liblogos, NOT a class member. - // `logosAPI` is defined in the Logos SDK headers and is used by the API - // internally. Storing the pointer in a local `m_logosAPI` member will NOT work. + // IMPORTANT: Assign to the inherited `logosAPI` member, NOT your own class member. + // `logosAPI` is a public member variable of the `PluginInterface` base class + // (declared in the SDK's core/interface.h); the Logos host reads it directly to + // dispatch calls. Storing the pointer in a separate `m_logosAPI` member will NOT work. logosAPI = api; qDebug() << "CalcModulePlugin: LogosAPI initialized"; } @@ -1085,10 +1086,10 @@ Cannot load library calc_module_plugin.so: libcalc.so: cannot open shared object ### `initLogos` stores API pointer in wrong variable -If inter-module calls or API features silently fail, check that `initLogos` assigns to the **global** `logosAPI` variable (defined in the Logos SDK / liblogos), not to a class member like `m_logosAPI`: +If inter-module calls or API features silently fail, check that `initLogos` assigns to the inherited `logosAPI` member — a public member variable of the `PluginInterface` base class (declared in the SDK's `core/interface.h`) — not to a class member like `m_logosAPI`. The Logos host reads this inherited member directly to dispatch inter-module calls: ```cpp -// CORRECT — uses the global variable from liblogos +// CORRECT — assigns to the inherited `logosAPI` member from PluginInterface void MyPlugin::initLogos(LogosAPI* api) { logosAPI = api;