plugin: give moc qtdeclarative include path so QML attrs reach qmltyperegistrar
This commit is contained in:
parent
78abe800ed
commit
1b07787764
3 changed files with 17 additions and 28 deletions
|
|
@ -2,21 +2,7 @@ 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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue