plugin: workaround cxx-qt 0.8.1 dyn plugin not calling qml_register_types
This commit is contained in:
parent
8b73f3d692
commit
fa861a4399
1 changed files with 14 additions and 0 deletions
|
|
@ -2,7 +2,21 @@ pub mod cpu_service;
|
||||||
pub mod stats;
|
pub mod stats;
|
||||||
pub mod system_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)]
|
#[ctor::ctor(unsafe)]
|
||||||
fn on_dylib_load() {
|
fn on_dylib_load() {
|
||||||
eprintln!("[nova-plugin] dylib loaded (libNovaStats.so)");
|
eprintln!("[nova-plugin] dylib loaded (libNovaStats.so)");
|
||||||
|
unsafe { qml_register_types_nova_stats() };
|
||||||
|
eprintln!("[nova-plugin] qml_register_types_NovaStats called");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue