From c831f480022d489851d583517d4d5f5c8139ea79 Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Mon, 24 Jan 2022 12:21:00 +0530 Subject: [PATCH] Fixed Bug in init_from_engine. Earlier it was registering the KLocalizedContextHolder with a different KLocalizedContext than the context object. --- Cargo.toml | 2 +- src/klocalizedcontext.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f6c2af8..c7f5c61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "ki18n" description = "A crate to use KF5I18n from rust." author = ["Ayush Singh "] -version = "1.1.1" +version = "2.0.0" edition = "2021" links = "KF5I18n" license = "MIT" diff --git a/src/klocalizedcontext.rs b/src/klocalizedcontext.rs index 77ac9c2..3aaa8f0 100644 --- a/src/klocalizedcontext.rs +++ b/src/klocalizedcontext.rs @@ -38,9 +38,8 @@ impl KLocalizedContext { pub fn init_from_engine(engine: &QmlEngine) -> Self { let engine_ptr = engine.cpp_ptr(); cpp!(unsafe [engine_ptr as "QQmlEngine*"] -> KLocalizedContext as "KLocalizedContextHolder" { - auto klocalized = new KLocalizedContext(engine_ptr); - auto klocalizedholder = KLocalizedContextHolder(klocalized); - engine_ptr->rootContext()->setContextObject(klocalized); + auto klocalizedholder = KLocalizedContextHolder(engine_ptr); + engine_ptr->rootContext()->setContextObject(klocalizedholder.klocalized.get()); return klocalizedholder; }) }