diff --git a/src/platform_impl/gtk/mod.rs b/src/platform_impl/gtk/mod.rs index cb837874..698d1d1d 100644 --- a/src/platform_impl/gtk/mod.rs +++ b/src/platform_impl/gtk/mod.rs @@ -19,7 +19,7 @@ use accelerator::{from_gtk_mnemonic, parse_accelerator, to_gtk_mnemonic}; use gtk::{gdk, prelude::*, AboutDialog, Container, Orientation}; use std::{ cell::RefCell, - collections::HashMap, + collections::{hash_map::Entry, HashMap}, rc::Rc, sync::atomic::{AtomicBool, Ordering}, }; @@ -264,9 +264,9 @@ impl Menu { // This is the first time this method has been called on this window // so we need to create the menubar and its parent box - if self.gtk_menubars.get(&id).is_none() { + if let Entry::Vacant(e) = self.gtk_menubars.entry(id) { let menu_bar = gtk::MenuBar::new(); - self.gtk_menubars.insert(id, menu_bar); + e.insert(menu_bar); } else { return Err(crate::Error::AlreadyInitialized); } @@ -759,7 +759,7 @@ impl MenuChild { /// IconMenuItem methods impl MenuChild { pub fn set_icon(&mut self, icon: Option) { - self.icon = icon.clone(); + self.icon.clone_from(&icon); let pixbuf = icon.map(|i| i.inner.to_pixbuf_scale(16, 16)); for items in self.gtk_menu_items.borrow().values() { diff --git a/src/platform_impl/macos/mod.rs b/src/platform_impl/macos/mod.rs index 61914a9e..e63d090c 100644 --- a/src/platform_impl/macos/mod.rs +++ b/src/platform_impl/macos/mod.rs @@ -509,7 +509,7 @@ impl MenuChild { /// IconMenuItem methods impl MenuChild { pub fn set_icon(&mut self, icon: Option) { - self.icon = icon.clone(); + self.icon.clone_from(&icon); self.native_icon = None; for ns_items in self.ns_menu_items.values() { for ns_item in ns_items { diff --git a/src/platform_impl/windows/mod.rs b/src/platform_impl/windows/mod.rs index de31fd23..601bc1c1 100644 --- a/src/platform_impl/windows/mod.rs +++ b/src/platform_impl/windows/mod.rs @@ -758,7 +758,7 @@ impl MenuChild { /// IconMenuItem methods impl MenuChild { pub fn set_icon(&mut self, icon: Option) { - self.icon = icon.clone(); + self.icon.clone_from(&icon); let hbitmap = icon.map(|i| unsafe { i.inner.to_hbitmap() }).unwrap_or(0); let info = create_icon_item_info(hbitmap);