chore: reduce local stack warnings

This commit is contained in:
Lionel DARNIS 2026-05-23 20:49:24 +02:00
parent 4743bb8ec9
commit 675f3b59e3
15 changed files with 63 additions and 48 deletions

2
iced

@ -1 +1 @@
Subproject commit 6b069b2b4bc252d8fdc4d2a93ff533376c4f0dee
Subproject commit f4870187088a14d398f2075c5ccda611387dcdcc

View file

@ -100,9 +100,10 @@ impl<T: Application> Cosmic<T>
where
T::Message: Send + 'static,
{
pub fn init(
(mut core, flags): (Core, T::Flags),
) -> (Self, iced::Task<crate::Action<T::Message>>) {
pub fn init((core, flags): (Core, T::Flags)) -> (Self, iced::Task<crate::Action<T::Message>>) {
#[cfg(all(feature = "dbus-config", target_os = "linux"))]
let mut core = core;
#[cfg(all(feature = "dbus-config", target_os = "linux"))]
{
use iced_futures::futures::executor::block_on;
@ -625,9 +626,9 @@ impl<T: Application> Cosmic<T> {
.app
.core()
.main_window_id()
.is_some_and(|main_id| main_id == id)
.is_some_and(|main_id| main_id == _id)
{
self.app.core_mut().window.sharp_corners = maximized;
self.app.core_mut().window.sharp_corners = _maximized;
}
}

View file

@ -284,7 +284,7 @@ where
// app = app.window(window_settings);
core.main_window = Some(iced_core::window::Id::RESERVED);
}
let mut app = iced::daemon(
let app = iced::daemon(
BootData(Rc::new(RefCell::new(Some(BootDataInner::<App> {
flags,
core,

View file

@ -1,7 +1,7 @@
//! Distribute content vertically.
use crate::iced;
use iced::core::alignment::{self, Alignment};
use iced::core::event::{self, Event};
use iced::core::event::Event;
use iced::core::layout;
use iced::core::mouse;
use iced::core::overlay;

View file

@ -10,11 +10,7 @@ use crate::{
widget::{
self,
autosize::{self, Autosize, autosize},
column::Column,
layer_container,
row::Row,
space::horizontal,
space::vertical,
},
};
@ -217,12 +213,6 @@ impl Context {
icon: widget::icon::Handle,
) -> crate::widget::Button<'a, Message> {
let suggested = self.suggested_size(icon.symbolic);
let (applet_padding_major_axis, applet_padding_minor_axis) = self.suggested_padding(true);
let (horizontal_padding, vertical_padding) = if self.is_horizontal() {
(applet_padding_major_axis, applet_padding_minor_axis)
} else {
(applet_padding_minor_axis, applet_padding_major_axis)
};
let symbolic = icon.symbolic;
let icon = widget::icon(icon)
.class(if symbolic {
@ -465,10 +455,8 @@ impl Context {
&self,
content: impl Into<Element<'a, Message>>,
) -> Autosize<'a, Message, crate::Theme, crate::Renderer> {
let force_configured = matches!(&self.panel_type, PanelType::Other(n) if n.is_empty());
let w = autosize(content, AUTOSIZE_MAIN_ID.clone());
let mut limits = Limits::NONE;
let suggested_window_size = self.suggested_window_size();
if let Some(width) = self
.suggested_bounds
@ -579,7 +567,7 @@ pub fn run<App: Application>(flags: App::Flags) -> iced::Result {
// window_settings = window_settings.clone();
core.main_window = Some(iced_core::window::Id::RESERVED);
}
let mut app = iced::daemon(
let app = iced::daemon(
BootData(Rc::new(RefCell::new(Some(BootDataInner::<App> {
flags,
core,

View file

@ -1,7 +1,7 @@
//! Distribute content horizontally.
use crate::iced;
use iced::core::alignment::{self, Alignment};
use iced::core::event::{self, Event};
use iced::core::event::Event;
use iced::core::layout::{self, Layout};
use iced::core::mouse;
use iced::core::overlay;
@ -10,7 +10,6 @@ use iced::core::widget::{Operation, Tree};
use iced::core::{
Clipboard, Element, Length, Padding, Pixels, Rectangle, Shell, Size, Vector, Widget, widget,
};
use iced::touch;
/// A container that distributes its contents horizontally.
///

View file

@ -45,7 +45,7 @@ pub fn subscription<App: ApplicationExt>() -> Subscription<crate::Action<App::Me
std::process::exit(1);
}
output
let _ = output
.send(crate::Action::Cosmic(crate::app::Action::DbusConnection(
conn.clone(),
)))

View file

@ -769,7 +769,7 @@ impl DesktopEntryData {
pub async fn spawn_desktop_exec<S, I, K, V>(
exec: S,
env_vars: I,
app_id: Option<&str>,
_app_id: Option<&str>,
terminal: bool,
) where
S: AsRef<str>,
@ -816,13 +816,17 @@ pub async fn spawn_desktop_exec<S, I, K, V>(
// https://systemd.io/DESKTOP_ENVIRONMENTS
//
// Similar to what Gnome sets, for now.
if let Some(pid) = crate::process::spawn(cmd).await {
if let Some(_pid) = crate::process::spawn(cmd).await {
#[cfg(feature = "desktop-systemd-scope")]
if let Ok(session) = zbus::Connection::session().await {
if let Ok(systemd_manager) = SystemdMangerProxy::new(&session).await {
let _ = systemd_manager
.start_transient_unit(
&format!("app-cosmic-{}-{}.scope", app_id.unwrap_or(&executable), pid),
&format!(
"app-cosmic-{}-{}.scope",
_app_id.unwrap_or(&executable),
_pid
),
"fail",
&[
(
@ -833,7 +837,7 @@ pub async fn spawn_desktop_exec<S, I, K, V>(
),
(
"PIDs".to_string(),
zbus::zvariant::Value::from(vec![pid])
zbus::zvariant::Value::from(vec![_pid])
.try_to_owned()
.unwrap(),
),

View file

@ -63,6 +63,17 @@ pub mod font;
#[doc(inline)]
pub use iced;
#[doc(inline)]
pub use iced_core;
#[doc(inline)]
pub use iced_futures;
#[doc(inline)]
pub use iced_runtime;
#[doc(inline)]
pub use iced_widget;
#[doc(inline)]
#[cfg(feature = "wayland")]
pub use iced_winit;
pub mod icon_theme;
pub mod keyboard_nav;

View file

@ -152,7 +152,7 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
);
}
let mut button = if builder.variant.vertical {
let button = if builder.variant.vertical {
crate::widget::column::with_children(content)
.padding(builder.padding)
.spacing(builder.spacing)
@ -169,9 +169,11 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
};
#[cfg(feature = "a11y")]
{
let button = {
let mut button = button;
button = button.name(builder.name).description(builder.description);
}
button
};
let button = button
.padding(0)

View file

@ -83,7 +83,7 @@ where
.width(builder.width)
.height(builder.height);
let mut button = super::custom_image_button(content, builder.variant.on_remove)
let button = super::custom_image_button(content, builder.variant.on_remove)
.padding(0)
.selected(builder.variant.selected)
.id(builder.id)
@ -91,9 +91,11 @@ where
.class(builder.class);
#[cfg(feature = "a11y")]
{
let button = {
let mut button = button;
button = button.name(builder.name).description(builder.description);
}
button
};
button.into()
}

View file

@ -66,7 +66,7 @@ pub fn icon() -> Handle {
impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Message> {
fn from(mut builder: Button<'a, Message>) -> Element<'a, Message> {
let mut button: super::Button<'a, Message> = row::with_capacity(2)
let button: super::Button<'a, Message> = row::with_capacity(2)
.push({
// TODO: Avoid allocation
crate::widget::text(builder.label.to_string())
@ -94,13 +94,15 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
.class(builder.class);
#[cfg(feature = "a11y")]
{
let button = {
let mut button = button;
if !builder.label.is_empty() {
button = button.name(builder.label);
}
button = button.description(builder.description);
}
button
};
if builder.tooltip.is_empty() {
button.into()

View file

@ -119,7 +119,7 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
.into()
});
let mut button: super::Button<'a, Message> = row::with_capacity(3)
let button: super::Button<'a, Message> = row::with_capacity(3)
// Optional icon to place before label.
.push_maybe(leading_icon)
// Optional label between icons.
@ -138,13 +138,15 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
.class(builder.class);
#[cfg(feature = "a11y")]
{
let button = {
let mut button = button;
if !builder.label.is_empty() {
button = button.name(builder.label)
}
button = button.description(builder.description);
}
button
};
if builder.tooltip.is_empty() {
button.into()

View file

@ -26,7 +26,7 @@ pub fn spin_button<'a, T, M>(
where
T: Copy + Sub<Output = T> + Add<Output = T> + PartialOrd,
{
let mut button = SpinButton::new(
let button = SpinButton::new(
label,
value,
step,
@ -37,9 +37,11 @@ where
);
#[cfg(feature = "a11y")]
{
let button = {
let mut button = button;
button = button.name(name.into());
}
button
};
button
}
@ -57,7 +59,7 @@ pub fn vertical<'a, T, M>(
where
T: Copy + Sub<Output = T> + Add<Output = T> + PartialOrd,
{
let mut button = SpinButton::new(
let button = SpinButton::new(
label,
value,
step,
@ -68,9 +70,11 @@ where
);
#[cfg(feature = "a11y")]
{
let button = {
let mut button = button;
button = button.name(name.into());
}
button
};
button
}

View file

@ -2198,7 +2198,7 @@ pub fn update<'a, Message: Clone + 'static>(
x,
y,
mime_types,
surface,
surface: _surface,
},
)) if *rectangle == Some(dnd_id) => {
cold();
@ -2241,7 +2241,7 @@ pub fn update<'a, Message: Clone + 'static>(
}
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Motion { x, y }))
Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Motion { x, y: _ }))
if *rectangle == Some(dnd_id) =>
{
let state = state();