plugin: anchor cxx-qt plugin init symbol so the linker keeps QQmlEngineExtensionPlugin
This commit is contained in:
parent
db2bcb2e69
commit
dad977d4c5
1 changed files with 12 additions and 2 deletions
|
|
@ -2,9 +2,19 @@ pub mod cpu_service;
|
|||
pub mod stats;
|
||||
pub mod system_stats;
|
||||
|
||||
// Fires when the .so is dlopen'd. Tells us the plugin file actually loaded,
|
||||
// independent of whether qml_register_types runs.
|
||||
// cxx-qt-build emits a QQmlEngineExtensionPlugin C++ class with Q_PLUGIN_METADATA
|
||||
// alongside an `init_cxx_qt_qml_module_<name>_plugin()` symbol whose only purpose is
|
||||
// to anchor that translation unit. Without referencing it from Rust, the linker
|
||||
// drops the .o containing the plugin class - Qt then dlopens the .so, finds no
|
||||
// plugin metadata, and never calls qml_register_types_NovaStats.
|
||||
unsafe extern "C" {
|
||||
fn init_cxx_qt_qml_module_NovaStats_plugin() -> bool;
|
||||
}
|
||||
|
||||
#[ctor::ctor(unsafe)]
|
||||
fn on_dylib_load() {
|
||||
eprintln!("[nova-plugin] dylib loaded (libNovaStats.so)");
|
||||
unsafe {
|
||||
init_cxx_qt_qml_module_NovaStats_plugin();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue