slint-ui/slint · error
C++: NativeWindowHandle created with null hwnd
Error message
C++: NativeWindowHandle created with null hwnd
What it means
Error "C++: NativeWindowHandle created with null hwnd" thrown in slint-ui/slint.
Source
Thrown at api/cpp/platform.rs:794
struct CppRawHandle(Arc<RawHandlePair>);
impl From<(RawWindowHandle, RawDisplayHandle)> for CppRawHandle {
fn from(pair: (RawWindowHandle, RawDisplayHandle)) -> Self {
Self(Arc::new(RawHandlePair(pair)))
}
}
type CppRawHandleOpaque = *const c_void;
#[unsafe(no_mangle)]
pub unsafe extern "C" fn slint_new_raw_window_handle_win32(
hwnd: *mut c_void,
_hinstance: *mut c_void,
) -> CppRawHandleOpaque {
let handle = CppRawHandle::from((
RawWindowHandle::Win32(raw_window_handle::Win32WindowHandle::new(
(hwnd as isize).try_into().expect("C++: NativeWindowHandle created with null hwnd"),
)),
RawDisplayHandle::Windows(raw_window_handle::WindowsDisplayHandle::new()),
));
Box::into_raw(Box::new(handle)) as CppRawHandleOpaque
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn slint_new_raw_window_handle_x11_xcb(
window: u32,
visual_id: u32,
connection: *mut c_void,
screen: core::ffi::c_int,
) -> CppRawHandleOpaque {
use raw_window_handle::{XcbDisplayHandle, XcbWindowHandle};
let handle = CppRawHandle::from((
RawWindowHandle::Xcb({
let mut hnd = XcbWindowHandle::new(
windowView on GitHub (pinned to 3fd8f2ec03)
Solutions
- Do not create a NativeWindowHandle with a null HWND on Windows.
- Obtain a valid window handle before calling.
When it happens
Trigger: Thrown at api/cpp/platform.rs:794 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of slint-ui/slint@3fd8f2ec03 (2026-08-19).
Data as JSON: /api/errors/64c20f9cb5528785.
Report an issue: GitHub.