diff --git a/plugin/src/lib.rs b/plugin/src/lib.rs index 6c837e5..eca2e48 100644 --- a/plugin/src/lib.rs +++ b/plugin/src/lib.rs @@ -2,7 +2,21 @@ pub mod cpu_service; pub mod stats; pub mod system_stats; +// cxx-qt 0.8.1's PluginType::Dynamic emits a QQmlEngineExtensionPlugin whose +// constructor only anchors qml_register_types_NovaStats with `volatile auto X = &X` +// (linker-keep, not a call), and the qmltyperegistrar static init doesn't call it +// either. Net effect: types never register, NS.* stays undefined in QML. Workaround: +// call it ourselves at .so load time. The function is mangled (returns void, no +// extern "C"), so go through #[link_name] using the itanium-mangled symbol seen in +// `nm libNovaStats.so | grep qml_register_types`. +unsafe extern "C" { + #[link_name = "_Z28qml_register_types_NovaStatsv"] + fn qml_register_types_nova_stats(); +} + #[ctor::ctor(unsafe)] fn on_dylib_load() { eprintln!("[nova-plugin] dylib loaded (libNovaStats.so)"); + unsafe { qml_register_types_nova_stats() }; + eprintln!("[nova-plugin] qml_register_types_NovaStats called"); }