Skip to content

Using multiple winio instances in the same process will cause panic #35

@Chaoses-Ib

Description

@Chaoses-Ib

As said in #24, I'm writing plugins using winio, so there may be multiple instances of winio in the same process. However, this will cause panic because they all register the same class name:

fn register() {
unsafe {
set_preferred_app_mode(PreferredAppMode::AllowDark);
}
let cls = WNDCLASSEXW {
cbSize: std::mem::size_of::<WNDCLASSEXW>() as _,
style: 0,
lpfnWndProc: Some(window_proc),
cbClsExtra: 0,
cbWndExtra: 0,
hInstance: unsafe { GetModuleHandleW(null()) },
hIcon: null_mut(),
hCursor: unsafe { LoadCursorW(null_mut(), IDC_ARROW) },
hbrBackground: unsafe { GetStockObject(WHITE_BRUSH) },
lpszMenuName: null(),
lpszClassName: WINDOW_CLASS_NAME,
hIconSm: null_mut(),
};
syscall!(BOOL, unsafe { RegisterClassExW(&cls) }).unwrap();
}

A panic occurred panic.payload="called `Result::unwrap()` on an `Err` value: Os { code: 1410, kind: Uncategorized, message: \"Class already exists.\" }" panic.location="C:\\Users\\Chaoses\\.cargo\\git\\checkouts\\winio-267028aeb854993e\\ca97049\\winio-ui-win32\\src\\ui\\window.rs:344:55"

How about using the new added app name or something else to avoid conflicts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions