Fix: prevent event loop error in ROGCC

Leftover code from parts of the refactor and tray crate change were
causing the app to crash due to the UI trying to issue a command on the
slint thread when the slint thread had not been created yet.

Closes #579
This commit is contained in:
Luke D. Jones
2024-12-28 22:02:18 +13:00
parent 98dc155e41
commit d40f4733e2
7 changed files with 23 additions and 88 deletions

View File

@@ -151,6 +151,7 @@ where
} }
if !paths.is_empty() { if !paths.is_empty() {
let mut ctrl = Vec::new(); let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(&b));
for path in paths { for path in paths {
ctrl.push( ctrl.push(
T::builder(&conn) T::builder(&conn)
@@ -1089,7 +1090,11 @@ fn handle_platform_new_properties(
let attrs = attr.available_attrs()?; let attrs = attr.available_attrs()?;
// dbg!(&name, &attrs); // dbg!(&name, &attrs);
println!("{name}::"); println!("{name}::");
if attrs.contains(&"defalt_value".to_string()) { if attrs.contains(&"current_value".to_string()) {
let v = attr.current_value()?;
println!(" current_value: {v}");
}
if attrs.contains(&"default_value".to_string()) {
let v = attr.default_value()?; let v = attr.default_value()?;
println!(" default_value: {v:?}"); println!(" default_value: {v:?}");
} }
@@ -1101,18 +1106,10 @@ fn handle_platform_new_properties(
let v = attr.max_value()?; let v = attr.max_value()?;
println!(" max_value: {v}"); println!(" max_value: {v}");
} }
if attrs.contains(&"scalar_increment".to_string()) {
let v = attr.scalar_increment()?;
println!(" scalar_increment: {v}");
}
if attrs.contains(&"possible_values".to_string()) { if attrs.contains(&"possible_values".to_string()) {
let v = attr.possible_values()?; let v = attr.possible_values()?;
println!(" possible_values: {v:?}"); println!(" possible_values: {v:?}");
} }
if attrs.contains(&"current_value".to_string()) {
let v = attr.current_value()?;
println!(" current_value: {v}");
}
} }
} }
} }

View File

@@ -1,11 +1,8 @@
use rog_platform::firmware_attributes::FirmwareAttributes;
use zbus::Connection;
use log::error; use log::error;
use rog_platform::firmware_attributes::{AttrValue, Attribute}; use rog_platform::firmware_attributes::{AttrValue, Attribute, FirmwareAttributes};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value}; use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
use zbus::{fdo, interface}; use zbus::{fdo, interface, Connection};
use crate::error::RogError; use crate::error::RogError;
use crate::ASUS_ZBUS_PATH; use crate::ASUS_ZBUS_PATH;

View File

@@ -268,7 +268,7 @@ impl DeviceManager {
found.push(path); found.push(path);
} }
} else { } else {
warn!("No serial for SCSI device"); debug!("No serial for SCSI device: {:?}", device.devpath());
} }
} }

View File

@@ -1,4 +1,3 @@
use std::borrow::BorrowMut;
use std::env::args; use std::env::args;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::exit; use std::process::exit;
@@ -203,16 +202,6 @@ async fn main() -> Result<()> {
exit(0); exit(0);
} }
} }
slint::invoke_from_event_loop(move || {
UI.with(|ui| {
let mut ui = ui.take();
if let Some(ui) = ui.borrow_mut() {
ui.window().hide().unwrap();
}
});
})
.unwrap();
} }
sleep(Duration::from_millis(300)); sleep(Duration::from_millis(300));
} }
@@ -223,42 +212,6 @@ async fn main() -> Result<()> {
Ok(()) Ok(())
} }
// /// Bah.. the icon dosn't work on wayland anyway, but we'll leave it in for
// now. fn load_icon() -> IconData {
// let path = PathBuf::from(APP_ICON_PATH);
// let mut rgba = Vec::new();
// let mut height = 512;
// let mut width = 512;
// if path.exists() {
// if let Ok(data) = std::fs::read(path)
// .map_err(|e| error!("Error reading app icon: {e:?}"))
// .map_err(|e| error!("Error opening app icon: {e:?}"))
// {
// let data = std::io::Cursor::new(data);
// let decoder = png_pong::Decoder::new(data).unwrap().into_steps();
// let png_pong::Step { raster, delay: _ } =
// decoder.last().unwrap().unwrap();
// if let png_pong::PngRaster::Rgba8(ras) = raster {
// rgba = ras.as_u8_slice().to_vec();
// width = ras.width();
// height = ras.height();
// info!("Loaded app icon. Not actually supported in Wayland
// yet"); }
// }
// } else {
// error!("Missing {APP_ICON_PATH}");
// }
// IconData {
// height,
// width,
// rgba
//
//
// / }
// }
fn do_cli_help(parsed: &CliStart) -> bool { fn do_cli_help(parsed: &CliStart) -> bool {
if parsed.help { if parsed.help {
println!("{}", CliStart::usage()); println!("{}", CliStart::usage());

View File

@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-12-27 08:21+0000\n" "POT-Creation-Date: 2024-12-28 09:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"

View File

@@ -1,24 +1,7 @@
//! # D-Bus interface proxy for: `xyz.ljones.AsusArmoury` //! # D-Bus interface proxy for: `xyz.ljones.AsusArmoury`
//! //!
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data. //! `zbus-xmlgen system xyz.ljones.Asusd
//! Source: `Interface '/xyz/ljones/asus_armoury/nv_temp_target' from service 'xyz.ljones.Asusd' on system bus`. //! /xyz/ljones/asus_armoury/nv_temp_target`
//!
//! You may prefer to adapt it, instead of using it verbatim.
//!
//! More information can be found in the [Writing a client proxy] section of the zbus
//! documentation.
//!
//! This type implements the [D-Bus standard interfaces], (`org.freedesktop.DBus.*`) for which the
//! following zbus API can be used:
//!
//! * [`zbus::fdo::IntrospectableProxy`]
//! * [`zbus::fdo::PropertiesProxy`]
//! * [`zbus::fdo::PeerProxy`]
//!
//! Consequently `zbus-xmlgen` did not generate code for the above interfaces.
//!
//! [Writing a client proxy]: https://dbus2.github.io/zbus/client.html
//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces,
use zbus::proxy; use zbus::proxy;
#[proxy( #[proxy(
interface = "xyz.ljones.AsusArmoury", interface = "xyz.ljones.AsusArmoury",
@@ -41,16 +24,18 @@ pub trait AsusArmoury {
#[zbus(property)] #[zbus(property)]
fn default_value(&self) -> zbus::Result<i32>; fn default_value(&self) -> zbus::Result<i32>;
/// MaxValue property. Maximum allowed current_value. Returns `-1` if unused or not set. /// MaxValue property. Maximum allowed current_value. Returns `-1` if unused
/// or not set.
#[zbus(property)] #[zbus(property)]
fn max_value(&self) -> zbus::Result<i32>; fn max_value(&self) -> zbus::Result<i32>;
/// MinValue property. Minimum allowed current_value. Returns `-1` if unused or not set. /// MinValue property. Minimum allowed current_value. Returns `-1` if unused
/// or not set.
#[zbus(property)] #[zbus(property)]
fn min_value(&self) -> zbus::Result<i32>; fn min_value(&self) -> zbus::Result<i32>;
/// PossibleValues property. Return the allowed values for `current_value` if used or set, /// PossibleValues property. Return the allowed values for `current_value`
/// otherwise the array is empty. /// if used or set, otherwise the array is empty.
#[zbus(property)] #[zbus(property)]
fn possible_values(&self) -> zbus::Result<Vec<i32>>; fn possible_values(&self) -> zbus::Result<Vec<i32>>;
@@ -58,8 +43,8 @@ pub trait AsusArmoury {
#[zbus(property)] #[zbus(property)]
fn name(&self) -> zbus::Result<String>; fn name(&self) -> zbus::Result<String>;
/// ScalarIncrement property. The increment steps that `current_value` may take. Returns /// ScalarIncrement property. The increment steps that `current_value` may
/// `-1` if not used or set. /// take. Returns `-1` if not used or set.
#[zbus(property)] #[zbus(property)]
fn scalar_increment(&self) -> zbus::Result<i32>; fn scalar_increment(&self) -> zbus::Result<i32>;
} }

View File

@@ -176,6 +176,9 @@ impl FirmwareAttributes {
for entry in dir.flatten() { for entry in dir.flatten() {
let base_path = entry.path(); let base_path = entry.path();
let name = base_path.file_name().unwrap().to_string_lossy().to_string(); let name = base_path.file_name().unwrap().to_string_lossy().to_string();
if name == "pending_reboot" {
continue;
}
let help = read_string(&base_path.join("display_name")).unwrap_or_default(); let help = read_string(&base_path.join("display_name")).unwrap_or_default();
let (default_value, possible_values, min_value, max_value, scalar_increment) = let (default_value, possible_values, min_value, max_value, scalar_increment) =