{"record":{"id":"02f1d893b6be2e20","repo":"FyroxEngine/Fyrox","slug":"widget-node-handle-preview-message-method-is-a","errorCode":null,"errorMessage":"Widget {node_handle} `preview_message` method is already registered!","messagePattern":"Widget (.+?) `preview_message` method is already registered!","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"fyrox-ui/src/lib.rs","lineNumber":663,"sourceCode":"impl Debug for Clipboard {\n    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {\n        write!(f, \"Clipboard\")\n    }\n}\n\n#[derive(Default, PartialEq, Debug, Clone)]\nstruct WidgetMethodsRegistry {\n    preview_message: FxHashSet<Handle<UiNode>>,\n    on_update: FxHashSet<Handle<UiNode>>,\n    handle_os_event: FxHashSet<Handle<UiNode>>,\n}\n\nimpl WidgetMethodsRegistry {\n    fn register<T: Control + ?Sized>(&mut self, node: &T) {\n        let node_handle = node.handle();\n\n        if node.preview_messages && !self.preview_message.insert(node_handle) {\n            Log::warn(format!(\n                \"Widget {node_handle} `preview_message` method is already registered!\"\n            ));\n        }\n        if node.handle_os_events && !self.handle_os_event.insert(node_handle) {\n            Log::warn(format!(\n                \"Widget {node_handle} `handle_os_event` method is already registered!\"\n            ));\n        }\n        if node.need_update && !self.on_update.insert(node_handle) {\n            Log::warn(format!(\n                \"Widget {node_handle} `on_update` method is already registered!\"\n            ));\n        }\n    }\n\n    fn unregister<T: Control + ?Sized>(&mut self, node: &T) {\n        let node_handle = node.handle();\n","sourceCodeStart":645,"sourceCodeEnd":681,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-ui/src/lib.rs#L645-L681","documentation":"The widget methods registry tracks which widgets implement preview_message so the UI can route messages to them efficiently. During widget registration (register), inserting the node handle into the preview_message set failed because it was already present, meaning the same widget is being registered twice. The duplicate registration is harmless but signals a double-registration bug.","triggerScenarios":"Calling register() (or the surrounding add_node/registration flow) twice for the same widget whose Control::preview_messages is true — e.g. re-adding a node, re-registering after removal, or a builder path that registers an already-registered node.","commonSituations":"Programmatically re-inserting a widget handle, a custom Control added via both a builder and manual registration, or plugin code that re-registers widgets on reload.","solutions":["Find and remove the duplicate registration call for the widget (register should run once per node).","If the widget was removed and re-added, ensure unregister() runs on removal so the handle leaves the set.","Guard your code with a check (or the registry's own insert result) before registering again.","If the double registration is benign, the warning can be ignored, but fix the call site to keep the registry consistent."],"exampleFix":"// before\nui.register_widget(node); // called again after node already added\nui.register_widget(node);\n// after\nif !registered.contains(&node_handle) {\n    ui.register_widget(node);\n}","handlingStrategy":"validation","validationCode":"// Track registration state in your widget manager\nif self.registered_handles.insert(node_handle) {\n    ui.register_widget(node);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Call the UI registration API once per widget lifecycle.","Pair every register with unregister on removal.","Avoid re-adding the same widget handle to the UI graph.","Treat this warning as a bug signal in plugin/reload code."],"tags":["gui","duplicate-registration","lifecycle"],"backgroundTag":"invalid-state-transition","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}