From 72d68aadb0c83b2f55cea2cc9e067f689ff99e75 Mon Sep 17 00:00:00 2001 From: darkfi Date: Fri, 9 Aug 2024 12:30:17 +0200 Subject: [PATCH] wallet: fix all the warnings --- bin/darkwallet/src/app.rs | 30 ++++------ bin/darkwallet/src/darkirc.rs | 34 ++++------- bin/darkwallet/src/error.rs | 18 ------ bin/darkwallet/src/expr.rs | 6 ++ bin/darkwallet/src/gfx/mod.rs | 12 ++-- bin/darkwallet/src/main.rs | 28 +-------- bin/darkwallet/src/mesh.rs | 7 ++- bin/darkwallet/src/net.rs | 5 +- bin/darkwallet/src/prop/mod.rs | 53 +++++++++-------- bin/darkwallet/src/prop/wrap.rs | 4 +- bin/darkwallet/src/pubsub.rs | 4 +- bin/darkwallet/src/scene.rs | 16 ++--- bin/darkwallet/src/text/atlas.rs | 5 +- bin/darkwallet/src/text/mod.rs | 18 ++---- bin/darkwallet/src/text/wrap.rs | 6 +- bin/darkwallet/src/ui/button.rs | 15 ++--- bin/darkwallet/src/ui/chatview.rs | 97 ++++++++++++------------------- bin/darkwallet/src/ui/editbox.rs | 32 ++++------ bin/darkwallet/src/ui/image.rs | 20 +++---- bin/darkwallet/src/ui/mesh.rs | 4 +- bin/darkwallet/src/ui/text.rs | 25 ++++---- bin/darkwallet/src/util.rs | 6 +- 22 files changed, 166 insertions(+), 279 deletions(-) diff --git a/bin/darkwallet/src/app.rs b/bin/darkwallet/src/app.rs index 56441dd67..c7015fcc9 100644 --- a/bin/darkwallet/src/app.rs +++ b/bin/darkwallet/src/app.rs @@ -17,15 +17,11 @@ */ use async_recursion::async_recursion; -use chrono::{NaiveDate, NaiveDateTime}; -use darkfi::event_graph; -use darkfi_serial::Encodable; use futures::{stream::FuturesUnordered, StreamExt}; use smol::Task; use std::{ sync::{Arc, Mutex as SyncMutex}, thread, - time::SystemTime, }; use crate::{ @@ -39,7 +35,7 @@ use crate::{ SceneNodeType, Slot, }, text::TextShaperPtr, - ui::{chatview, Button, ChatView, EditBox, Image, Mesh, RenderLayer, Stoppable, Text, Window}, + ui::{Button, ChatView, EditBox, Image, Mesh, RenderLayer, Stoppable, Text, Window}, ExecutorPtr, }; @@ -59,13 +55,6 @@ const KING_PATH: &str = "assets/king.png"; const LIGHTMODE: bool = false; -fn get_systime() -> u64 { - match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) { - Ok(n) => n.as_secs(), - Err(_) => panic!("SystemTime before UNIX EPOCH!"), - } -} - pub struct AsyncRuntime { signal: async_channel::Sender<()>, shutdown: async_channel::Receiver<()>, @@ -821,6 +810,7 @@ impl Drop for App { } // Just for testing +/* fn populate_tree(tree: &sled::Tree) { let chat_txt = include_str!("../chat.txt"); for line in chat_txt.lines() { @@ -834,7 +824,6 @@ fn populate_tree(tree: &sled::Tree) { NaiveDate::from_ymd_opt(2024, 8, 6).unwrap().and_hms_opt(hour, min, 0).unwrap(); let timest = dt.and_utc().timestamp() as u64; - let message_id = [0u8; 32]; let nick = parts[1].to_string(); let text = parts[2].to_string(); @@ -853,6 +842,7 @@ fn populate_tree(tree: &sled::Tree) { // O(n) debug!(target: "app", "populated db with {} lines", tree.len()); } +*/ pub fn create_layer(sg: &mut SceneGraph, name: &str) -> SceneNodeId { debug!(target: "app", "create_layer({name})"); @@ -968,7 +958,7 @@ fn create_editbox(sg: &mut SceneGraph, name: &str) -> SceneNodeId { prop.allow_exprs(); node.add_property(prop).unwrap(); - let mut prop = Property::new("baseline", PropertyType::Float32, PropertySubType::Pixel); + let prop = Property::new("baseline", PropertyType::Float32, PropertySubType::Pixel); node.add_property(prop).unwrap(); let mut prop = Property::new("scroll", PropertyType::Float32, PropertySubType::Pixel); @@ -979,10 +969,10 @@ fn create_editbox(sg: &mut SceneGraph, name: &str) -> SceneNodeId { prop.set_range_u32(0, u32::MAX); node.add_property(prop).unwrap(); - let mut prop = Property::new("font_size", PropertyType::Float32, PropertySubType::Pixel); + let prop = Property::new("font_size", PropertyType::Float32, PropertySubType::Pixel); node.add_property(prop).unwrap(); - let mut prop = Property::new("text", PropertyType::Str, PropertySubType::Null); + let prop = Property::new("text", PropertyType::Str, PropertySubType::Null); node.add_property(prop).unwrap(); let mut prop = Property::new("text_color", PropertyType::Float32, PropertySubType::Color); @@ -1005,10 +995,10 @@ fn create_editbox(sg: &mut SceneGraph, name: &str) -> SceneNodeId { prop.allow_null_values(); node.add_property(prop).unwrap(); - let mut prop = Property::new("z_index", PropertyType::Uint32, PropertySubType::Null); + let prop = Property::new("z_index", PropertyType::Uint32, PropertySubType::Null); node.add_property(prop).unwrap(); - let mut prop = Property::new("debug", PropertyType::Bool, PropertySubType::Null); + let prop = Property::new("debug", PropertyType::Bool, PropertySubType::Null); node.add_property(prop).unwrap(); node.id @@ -1055,10 +1045,10 @@ fn create_chatview( let prop = Property::new("baseline", PropertyType::Float32, PropertySubType::Pixel); node.add_property(prop).unwrap(); - let mut prop = Property::new("z_index", PropertyType::Uint32, PropertySubType::Null); + let prop = Property::new("z_index", PropertyType::Uint32, PropertySubType::Null); node.add_property(prop).unwrap(); - let mut prop = Property::new("debug", PropertyType::Bool, PropertySubType::Null); + let prop = Property::new("debug", PropertyType::Bool, PropertySubType::Null); node.add_property(prop).unwrap(); let mut prop = diff --git a/bin/darkwallet/src/darkirc.rs b/bin/darkwallet/src/darkirc.rs index b897d5857..23cf8ec67 100644 --- a/bin/darkwallet/src/darkirc.rs +++ b/bin/darkwallet/src/darkirc.rs @@ -16,32 +16,19 @@ * along with this program. If not, see . */ -use async_lock::Mutex as AsyncMutex; -use std::sync::{mpsc, Arc, Mutex as SyncMutex}; +use std::sync::{Arc, Mutex as SyncMutex}; use darkfi::{ - async_daemonize, cli_desc, event_graph::{self, proto::ProtocolEventGraph, EventGraph, EventGraphPtr}, net::{session::SESSION_DEFAULT, settings::Settings as NetSettings, P2p, P2pPtr}, - rpc::{ - jsonrpc::JsonSubscriber, - server::{listen_and_serve, RequestHandler}, - }, - system::{sleep, sleep_forever, CondVar, StoppableTask, StoppableTaskPtr, Subscription}, - util::path::{expand_path, get_config_path}, - Error, Result, + system::{sleep, Subscription}, + Error, }; use darkfi_serial::{ - async_trait, deserialize_async, serialize_async, AsyncDecodable, Encodable, SerialDecodable, - SerialEncodable, + async_trait, deserialize_async, serialize_async, Encodable, SerialDecodable, SerialEncodable, }; -use crate::{ - net::ZeroMQAdapter, - scene::{SceneGraph, SceneGraphPtr2}, - text::TextShaper, - ExecutorPtr, -}; +use crate::{scene::SceneGraphPtr2, ExecutorPtr}; #[cfg(target_os = "android")] const EVGRDB_PATH: &str = "/data/data/darkfi.darkwallet/evgrdb/"; @@ -60,7 +47,7 @@ async fn relay_darkirc_events(sg: SceneGraphPtr2, ev_sub: Subscription v, Err(e) => { error!("[IRC CLIENT] Failed deserializing incoming Privmsg event: {}", e); @@ -80,10 +67,10 @@ async fn relay_darkirc_events(sg: SceneGraphPtr2, ev_sub: Subscription; struct DarkIrcData { p2p: P2pPtr, event_graph: EventGraphPtr, + #[allow(dead_code)] ev_task: smol::Task<()>, db: sled::Db, } diff --git a/bin/darkwallet/src/error.rs b/bin/darkwallet/src/error.rs index cb41d2388..87957b598 100644 --- a/bin/darkwallet/src/error.rs +++ b/bin/darkwallet/src/error.rs @@ -42,9 +42,6 @@ pub enum Error { #[error("Property has wrong type")] PropertyWrongType = 7, - #[error("Property has wrong subtype")] - PropertyWrongSubType = 8, - #[error("Property value has the wrong length")] PropertyWrongLen = 9, @@ -102,18 +99,6 @@ pub enum Error { #[error("Node has a sibling with this name")] NodeSiblingNameConflict = 27, - #[error("File not found")] - FileNotFound = 28, - - #[error("Resource is not found")] - ResourceNotFound = 29, - - #[error("Python expr eval error")] - PyEvalErr = 30, - - #[error("Empty S-expr")] - SExprEmpty = 31, - #[error("S-expr global not found")] SExprGlobalNotFound = 32, @@ -123,9 +108,6 @@ pub enum Error { #[error("Publisher was destroyed")] PublisherDestroyed = 34, - #[error("Empty atlas")] - AtlasIsEmpty = 35, - #[error("Channel closed")] ChannelClosed = 36, } diff --git a/bin/darkwallet/src/expr.rs b/bin/darkwallet/src/expr.rs index e001a2b3b..52389d0b4 100644 --- a/bin/darkwallet/src/expr.rs +++ b/bin/darkwallet/src/expr.rs @@ -35,6 +35,7 @@ pub enum SExprVal { } impl SExprVal { + #[allow(dead_code)] fn is_null(&self) -> bool { match self { Self::Null => true, @@ -42,6 +43,7 @@ impl SExprVal { } } + #[allow(dead_code)] fn is_bool(&self) -> bool { match self { Self::Bool(_) => true, @@ -56,6 +58,7 @@ impl SExprVal { } } + #[allow(dead_code)] fn is_f32(&self) -> bool { match self { Self::Float32(_) => true, @@ -63,6 +66,7 @@ impl SExprVal { } } + #[allow(dead_code)] fn is_str(&self) -> bool { match self { Self::Str(_) => true, @@ -70,6 +74,7 @@ impl SExprVal { } } + #[allow(dead_code)] fn as_bool(&self) -> Result { match self { Self::Bool(v) => Ok(*v), @@ -91,6 +96,7 @@ impl SExprVal { } } + #[allow(dead_code)] fn as_str(&self) -> Result { match self { Self::Str(v) => Ok(v.clone()), diff --git a/bin/darkwallet/src/gfx/mod.rs b/bin/darkwallet/src/gfx/mod.rs index cc5486924..c7579486f 100644 --- a/bin/darkwallet/src/gfx/mod.rs +++ b/bin/darkwallet/src/gfx/mod.rs @@ -16,9 +16,7 @@ * along with this program. If not, see . */ -use darkfi_serial::{ - async_trait, Decodable, Encodable, FutAsyncWriteExt, ReadExt, SerialDecodable, SerialEncodable, -}; +use darkfi_serial::{async_trait, SerialDecodable, SerialEncodable}; use log::debug; use miniquad::{ conf, window, Backend, Bindings, BlendFactor, BlendState, BlendValue, BufferId, BufferLayout, @@ -38,7 +36,6 @@ use crate::{ app::{AppPtr, AsyncRuntime}, error::{Error, Result}, pubsub::{Publisher, PublisherPtr, Subscription, SubscriptionId}, - util::ansi_texture, }; // This is very noisy so suppress output by default @@ -439,6 +436,7 @@ impl GraphicsEventPublisher { }) } + /* fn lock_resize(&self, sub_id: SubscriptionId) { *self.lock_resize.lock().unwrap() = Some(sub_id); } @@ -501,6 +499,7 @@ impl GraphicsEventPublisher { fn unlock_touch(&self) { *self.lock_touch.lock().unwrap() = None; } + */ fn notify_resize(&self, w: f32, h: f32) { let ev = (w, h); @@ -627,7 +626,9 @@ impl GraphicsEventPublisher { } struct Stage { + #[allow(dead_code)] app: AppPtr, + #[allow(dead_code)] async_runtime: AsyncRuntime, ctx: Box, @@ -831,9 +832,6 @@ impl EventHandler for Stage { //uniforms_data[64..].copy_from_slice(&data); assert_eq!(128, 2 * UniformType::Mat4.size()); - let (screen_width, screen_height) = window::screen_size(); - let default_view = Rectangle { x: 0., y: 0., w: screen_width, h: screen_height }; - let mut render_ctx = RenderContext { ctx: &mut self.ctx, draw_calls: &self.draw_calls, diff --git a/bin/darkwallet/src/main.rs b/bin/darkwallet/src/main.rs index 146716a10..c1e17bb2e 100644 --- a/bin/darkwallet/src/main.rs +++ b/bin/darkwallet/src/main.rs @@ -19,30 +19,14 @@ #![feature(deadline_api)] #![feature(str_split_whitespace_remainder)] #![feature(duration_millis_float)] +#![feature(stmt_expr_attributes)] // Use these to incrementally fix warnings with cargo fix //#![allow(warnings, unused)] //#![deny(unused_imports)] use async_lock::Mutex as AsyncMutex; -use std::sync::{mpsc, Arc, Mutex as SyncMutex}; - -use darkfi::{ - async_daemonize, cli_desc, - event_graph::{self, proto::ProtocolEventGraph, EventGraph, EventGraphPtr}, - net::{session::SESSION_DEFAULT, settings::Settings as NetSettings, P2p, P2pPtr}, - rpc::{ - jsonrpc::JsonSubscriber, - server::{listen_and_serve, RequestHandler}, - }, - system::{sleep, sleep_forever, CondVar, StoppableTask, StoppableTaskPtr, Subscription}, - util::path::{expand_path, get_config_path}, - Error, Result, -}; -use darkfi_serial::{ - async_trait, deserialize_async, serialize_async, AsyncDecodable, Encodable, SerialDecodable, - SerialEncodable, -}; +use std::sync::{mpsc, Arc}; #[macro_use] extern crate log; @@ -65,12 +49,7 @@ mod text; mod ui; mod util; -use crate::{ - darkirc::DarkIrcBackend, - net::ZeroMQAdapter, - scene::{SceneGraph, SceneGraphPtr2}, - text::TextShaper, -}; +use crate::{darkirc::DarkIrcBackend, net::ZeroMQAdapter, scene::SceneGraph, text::TextShaper}; pub type ExecutorPtr = Arc>; @@ -141,7 +120,6 @@ fn main() { text_shaper, darkirc_backend, ); - let app2 = app.clone(); let app_task = ex.spawn(app.clone().start()); async_runtime.push_task(app_task); diff --git a/bin/darkwallet/src/mesh.rs b/bin/darkwallet/src/mesh.rs index cabcc2438..343700b6f 100644 --- a/bin/darkwallet/src/mesh.rs +++ b/bin/darkwallet/src/mesh.rs @@ -18,19 +18,24 @@ use crate::{ error::Result, - gfx::{DrawMesh, Point, Rectangle, RenderApi, Vertex}, + gfx::{DrawMesh, Rectangle, RenderApi, Vertex}, }; use miniquad::{BufferId, TextureId}; pub type Color = [f32; 4]; +#[allow(dead_code)] pub const COLOR_RED: Color = [1., 0., 0., 1.]; +#[allow(dead_code)] pub const COLOR_DARKGREY: Color = [0.2, 0.2, 0.2, 1.]; +#[allow(dead_code)] pub const COLOR_LIGHTGREY: Color = [0.7, 0.7, 0.7, 1.]; pub const COLOR_GREEN: Color = [0., 1., 0., 1.]; pub const COLOR_BLUE: Color = [0., 0., 1., 1.]; pub const COLOR_WHITE: Color = [1., 1., 1., 1.]; +#[allow(dead_code)] pub const COLOR_BLACK: Color = [1., 1., 1., 1.]; +#[allow(dead_code)] pub const COLOR_GREY: Color = [0.5, 0.5, 0.5, 1.]; #[derive(Clone)] diff --git a/bin/darkwallet/src/net.rs b/bin/darkwallet/src/net.rs index 3efa431ed..66bc6e033 100644 --- a/bin/darkwallet/src/net.rs +++ b/bin/darkwallet/src/net.rs @@ -17,10 +17,7 @@ */ use async_lock::Mutex; -use darkfi_serial::{ - async_trait, deserialize, Decodable, Encodable, FutAsyncWriteExt, ReadExt, SerialDecodable, - SerialEncodable, VarInt, -}; +use darkfi_serial::{async_trait, deserialize, Decodable, Encodable, SerialDecodable, VarInt}; use std::{ io::Cursor, sync::{mpsc, Arc}, diff --git a/bin/darkwallet/src/prop/mod.rs b/bin/darkwallet/src/prop/mod.rs index 8717496c4..1fbfd99c2 100644 --- a/bin/darkwallet/src/prop/mod.rs +++ b/bin/darkwallet/src/prop/mod.rs @@ -17,10 +17,7 @@ */ use crate::error::{Error, Result}; -use darkfi_serial::{ - async_trait, deserialize, Decodable, Encodable, FutAsyncWriteExt, ReadExt, SerialDecodable, - SerialEncodable, VarInt, -}; +use darkfi_serial::{async_trait, Encodable, FutAsyncWriteExt, SerialDecodable, SerialEncodable}; use std::{ io::Write, sync::{Arc, Mutex}, @@ -206,7 +203,9 @@ impl Encodable for PropertyValue { #[derive(Debug, Clone)] pub enum ModifyAction { Clear, + #[allow(dead_code)] Set(usize), + #[allow(dead_code)] Push(usize), } @@ -373,7 +372,7 @@ impl Property { return Err(Error::PropertyNullNotAllowed) } - let vals = &mut self.vals.lock().unwrap(); + let mut vals = self.vals.lock().unwrap(); if i >= vals.len() { return Err(Error::PropertyWrongIndex) } @@ -475,7 +474,7 @@ impl Property { return Err(Error::PropertyIsBounded) } - let vals = &mut self.vals.lock().unwrap(); + let mut vals = self.vals.lock().unwrap(); let i = vals.len(); vals.push(value); drop(vals); @@ -663,13 +662,13 @@ mod tests { #[test] fn test_getset() { - let mut prop = Property::new("foo", PropertyType::Float32, PropertySubType::Null); - assert!(prop.set_f32(1, 4.).is_err()); + let prop = Property::new("foo", PropertyType::Float32, PropertySubType::Null); + assert!(prop.set_f32(Role::App, 1, 4.).is_err()); assert!(prop.is_unset(0).unwrap()); - assert!(prop.set_f32(0, 4.).is_ok()); + assert!(prop.set_f32(Role::App, 0, 4.).is_ok()); assert_eq!(prop.get_f32(0).unwrap(), 4.); assert!(!prop.is_unset(0).unwrap()); - prop.unset(0).unwrap(); + prop.unset(Role::App, 0).unwrap(); assert!(prop.is_unset(0).unwrap()); assert_eq!(prop.get_f32(0).unwrap(), 0.); } @@ -681,13 +680,13 @@ mod tests { assert!(prop.set_defaults_f32(vec![1.0, 0.0]).is_err()); assert!(prop.set_defaults_f32(vec![2.0]).is_ok()); prop.allow_null_values(); - prop.set_null(0).unwrap(); + prop.set_null(Role::App, 0).unwrap(); assert!(prop.get_f32_opt(1).is_err()); assert!(prop.get_f32_opt(0).is_ok()); assert!(prop.get_f32_opt(0).unwrap().is_none()); - prop.clear_values(); + prop.clear_values(Role::App); assert!(prop.get_f32(0).is_ok()); assert!(prop.get_f32_opt(0).unwrap().is_some()); assert_eq!(prop.get_f32(0).unwrap(), 2.0); @@ -695,8 +694,8 @@ mod tests { #[test] fn test_nonnullable() { - let mut prop = Property::new("foo", PropertyType::Float32, PropertySubType::Null); - assert!(prop.set_null(0).is_err()); + let prop = Property::new("foo", PropertyType::Float32, PropertySubType::Null); + assert!(prop.set_null(Role::App, 0).is_err()); assert!(prop.is_unset(0).unwrap()); } @@ -705,24 +704,24 @@ mod tests { let mut prop = Property::new("foo", PropertyType::Float32, PropertySubType::Null); prop.set_unbounded(); assert_eq!(prop.get_len(), 0); - prop.push_f32(2.0).unwrap(); - prop.push_f32(3.0).unwrap(); + prop.push_f32(Role::App, 2.0).unwrap(); + prop.push_f32(Role::App, 3.0).unwrap(); assert_eq!(prop.get_len(), 2); - prop.clear_values(); + prop.clear_values(Role::App); assert_eq!(prop.get_len(), 0); prop.allow_null_values(); - prop.push_null().unwrap(); - prop.push_f32(4.0).unwrap(); - prop.push_f32(5.0).unwrap(); + prop.push_null(Role::App).unwrap(); + prop.push_f32(Role::App, 4.0).unwrap(); + prop.push_f32(Role::App, 5.0).unwrap(); assert_eq!(prop.get_len(), 3); assert!(prop.get_f32_opt(0).unwrap().is_none()); assert!(prop.get_f32_opt(1).unwrap().is_some()); assert!(prop.get_f32_opt(2).unwrap().is_some()); assert!(prop.get_f32_opt(3).is_err()); - let mut prop2 = Property::new("foo", PropertyType::Float32, PropertySubType::Null); - assert!(prop2.push_f32(4.0).is_err()); + let prop2 = Property::new("foo", PropertyType::Float32, PropertySubType::Null); + assert!(prop2.push_f32(Role::App, 4.0).is_err()); } #[test] @@ -730,16 +729,16 @@ mod tests { let mut prop = Property::new("foo", PropertyType::Float32, PropertySubType::Null); let half_pi = 3.1415926535 / 2.; prop.set_range_f32(-half_pi, half_pi); - assert!(prop.set_f32(0, 6.).is_err()); - assert!(prop.set_f32(0, 1.).is_ok()); + assert!(prop.set_f32(Role::App, 0, 6.).is_err()); + assert!(prop.set_f32(Role::App, 0, 1.).is_ok()); } #[test] fn test_enum() { let mut prop = Property::new("foo", PropertyType::Enum, PropertySubType::Null); prop.set_enum_items(vec!["ABC", "XYZ", "FOO"]).unwrap(); - assert!(prop.set_enum(0, "ABC").is_ok()); - assert!(prop.set_enum(0, "BAR").is_err()); + assert!(prop.set_enum(Role::App, 0, "ABC").is_ok()); + assert!(prop.set_enum(Role::App, 0, "BAR").is_err()); } #[test] @@ -748,7 +747,7 @@ mod tests { prop.allow_exprs(); assert_eq!(prop.get_f32(0).unwrap(), 0.); let code = vec![Op::ConstFloat32(4.)]; - prop.set_expr(0, code).unwrap(); + prop.set_expr(Role::App, 0, code).unwrap(); let val = prop.get_cached(0).unwrap(); assert!(val.is_null()); prop.set_cache_f32(0, 4.).unwrap(); diff --git a/bin/darkwallet/src/prop/wrap.rs b/bin/darkwallet/src/prop/wrap.rs index 74abfaf68..c781c6230 100644 --- a/bin/darkwallet/src/prop/wrap.rs +++ b/bin/darkwallet/src/prop/wrap.rs @@ -16,9 +16,7 @@ * along with this program. If not, see . */ -use std::sync::Arc; - -use super::{Property, PropertyPtr, Role}; +use super::{PropertyPtr, Role}; use crate::{ error::{Error, Result}, scene::SceneNode, diff --git a/bin/darkwallet/src/pubsub.rs b/bin/darkwallet/src/pubsub.rs index 5206c7f0b..890faadca 100644 --- a/bin/darkwallet/src/pubsub.rs +++ b/bin/darkwallet/src/pubsub.rs @@ -83,7 +83,7 @@ impl Publisher { } /// Publish a message to subscriptions in the include list - pub async fn notify_with_include(&self, message_result: T, include_list: &[SubscriptionId]) { + pub fn notify_with_include(&self, message_result: T, include_list: &[SubscriptionId]) { // Maybe we should just provide a method to get all IDs // Then people can call notify_with_exclude() instead. // TODO: just collect and clone directly into a Vec @@ -93,7 +93,7 @@ impl Publisher { continue } - if let Err(e) = sub.send(message_result.clone()).await { + if let Err(e) = sub.try_send(message_result.clone()) { panic!("[system::publisher] Error returned sending message in notify_with_include() call! {}", e); } } diff --git a/bin/darkwallet/src/scene.rs b/bin/darkwallet/src/scene.rs index dd0ad8dd3..8b156bdd6 100644 --- a/bin/darkwallet/src/scene.rs +++ b/bin/darkwallet/src/scene.rs @@ -18,16 +18,13 @@ use async_channel::Sender; use async_lock::Mutex; -use darkfi_serial::{ - async_trait, deserialize, Decodable, Encodable, FutAsyncWriteExt, ReadExt, SerialDecodable, - SerialEncodable, VarInt, -}; +use darkfi_serial::{async_trait, FutAsyncWriteExt, SerialDecodable, SerialEncodable}; use futures::{stream::FuturesUnordered, StreamExt}; use std::{fmt, str::FromStr, sync::Arc}; use crate::{ error::{Error, Result}, - prop::{Property, PropertyPtr, PropertyType, Role}, + prop::{Property, PropertyPtr, Role}, ui, }; @@ -106,7 +103,6 @@ impl FromStr for ScenePath { } } -pub type SceneGraphPtr = Arc>; pub type SceneGraphPtr2 = Arc>; pub struct SceneGraph { @@ -176,9 +172,11 @@ impl SceneGraph { Ok(()) } + #[allow(dead_code)] fn root(&self) -> &SceneNode { &self.nodes[0] } + #[allow(dead_code)] fn root_mut(&mut self) -> &mut SceneNode { &mut self.nodes[0] } @@ -574,9 +572,6 @@ impl SceneNode { pub fn get_method(&self, name: &str) -> Option<&Method> { self.methods.iter().find(|method| method.name == name) } - fn get_method_mut(&mut self, name: &str) -> Option<&mut Method> { - self.methods.iter_mut().find(|method| method.name == name) - } pub fn call_method( &mut self, @@ -606,7 +601,6 @@ pub struct CallArg { pub typ: CallArgType, } -type SlotFn = Box) + Send>; pub type SlotId = u32; pub struct Slot { @@ -616,7 +610,9 @@ pub struct Slot { pub struct Signal { pub name: String, + #[allow(dead_code)] pub desc: String, + #[allow(dead_code)] pub fmt: Vec, slots: Vec, freed: Vec, diff --git a/bin/darkwallet/src/text/atlas.rs b/bin/darkwallet/src/text/atlas.rs index 384eea6c2..d06ef3d6e 100644 --- a/bin/darkwallet/src/text/atlas.rs +++ b/bin/darkwallet/src/text/atlas.rs @@ -1,9 +1,8 @@ use miniquad::TextureId; use crate::{ - error::{Error, Result}, - gfx::{Rectangle, RenderApi, RenderApiPtr}, - util::{ansi_texture, zip3}, + error::Result, + gfx::{Rectangle, RenderApi}, }; use super::{Glyph, Sprite, SpritePtr}; diff --git a/bin/darkwallet/src/text/mod.rs b/bin/darkwallet/src/text/mod.rs index 26ddff4fa..611427976 100644 --- a/bin/darkwallet/src/text/mod.rs +++ b/bin/darkwallet/src/text/mod.rs @@ -22,21 +22,16 @@ use harfbuzz_sys::{ freetype::hb_ft_font_create_referenced, hb_buffer_add_utf8, hb_buffer_create, hb_buffer_destroy, hb_buffer_get_glyph_infos, hb_buffer_get_glyph_positions, hb_buffer_guess_segment_properties, hb_buffer_set_cluster_level, hb_buffer_set_content_type, - hb_feature_t, hb_font_destroy, hb_glyph_info_t, hb_glyph_position_t, hb_shape, + hb_font_destroy, hb_glyph_info_t, hb_glyph_position_t, hb_shape, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS, HB_BUFFER_CONTENT_TYPE_UNICODE, }; -use miniquad::TextureId; use std::{ collections::HashMap, os, sync::{Arc, Weak}, }; -use crate::{ - error::Result, - gfx::{Rectangle, RenderApi, RenderApiPtr}, - util::ansi_texture, -}; +use crate::gfx::Rectangle; mod atlas; pub use atlas::{make_texture_atlas, Atlas, RenderedAtlas}; @@ -168,7 +163,6 @@ impl TextShaper { break 'get_idx i } } - drop(font_faces); warn!(target: "text", "no font fallback for char: '{}'", chr); // Skip this char @@ -203,9 +197,6 @@ impl TextShaper { let mut glyphs: Vec = vec![]; - let mut current_x = 0.; - let mut current_y = 0.; - for (face_idx, text) in substrs { //debug!("substr {}", text); let face = &mut faces.0[face_idx]; @@ -230,7 +221,7 @@ impl TextShaper { let utf8_ptr = text.as_ptr() as *const _; // https://harfbuzz.github.io/a-simple-shaping-example.html - let (hb_font, buf, glyph_infos, glyph_pos, glyph_infos_iter, glyph_pos_iter) = unsafe { + let (hb_font, buf, _glyph_infos, _glyph_pos, glyph_infos_iter, glyph_pos_iter) = unsafe { let ft_face_ptr: freetype::freetype_sys::FT_Face = face.raw_mut(); let hb_font = hb_ft_font_create_referenced(ft_face_ptr); let buf = hb_buffer_create(); @@ -255,6 +246,7 @@ impl TextShaper { let glyph_pos_iter: &[hb_glyph_position_t] = std::slice::from_raw_parts(glyph_pos as *const _, length as usize); + // Return glyph_(infos|pos) since iters depend on it (hb_font, buf, glyph_infos, glyph_pos, glyph_infos_iter, glyph_pos_iter) }; @@ -326,7 +318,7 @@ impl TextShaper { //debug!("load_glyph {}", glyph_id); if let Err(err) = face.load_glyph(glyph_id, flags) { - error!(target: "text", "error loading glyph: {}", glyph_id); + error!(target: "text", "error loading glyph {glyph_id}: {err}"); continue } //debug!("load_glyph {} [done]", glyph_id); diff --git a/bin/darkwallet/src/text/wrap.rs b/bin/darkwallet/src/text/wrap.rs index 6802b9f0e..836393c25 100644 --- a/bin/darkwallet/src/text/wrap.rs +++ b/bin/darkwallet/src/text/wrap.rs @@ -16,13 +16,14 @@ struct Token { } impl Token { + #[allow(dead_code)] fn as_str(&self) -> String { glyph_str(&self.glyphs) } } /// Get the string represented by a vec of glyphs. Useful for debugging. -fn glyph_str(glyphs: &Vec) -> String { +pub fn glyph_str(glyphs: &Vec) -> String { glyphs.iter().map(|g| g.substr.as_str()).collect::>().join("") } @@ -58,6 +59,7 @@ fn tokenize(font_size: f32, glyphs: &Vec) -> Vec { // Reset ruler lhs = -1.; + #[allow(unused_assignments)] rhs = 0.; // take() blanked token_glyphs above @@ -91,7 +93,7 @@ fn apply_wrap(line_width: f32, tokens: Vec) -> Vec> { let mut line = vec![]; let mut start = 0.; - for (i, mut token) in tokens.into_iter().enumerate() { + for mut token in tokens { assert!(token.token_type != TokenType::Null); // Triggered by if below diff --git a/bin/darkwallet/src/ui/button.rs b/bin/darkwallet/src/ui/button.rs index f4d854df1..5f24e2f9e 100644 --- a/bin/darkwallet/src/ui/button.rs +++ b/bin/darkwallet/src/ui/button.rs @@ -16,30 +16,27 @@ * along with this program. If not, see . */ -use miniquad::{window, BufferId, KeyCode, KeyMods, MouseButton, TextureId, TouchPhase}; -use rand::{rngs::OsRng, Rng}; +use miniquad::{MouseButton, TouchPhase}; use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, Weak, }; use crate::{ - gfx::{ - DrawCall, DrawInstruction, DrawMesh, GraphicsEventPublisherPtr, Point, Rectangle, - RenderApiPtr, Vertex, - }, - prop::{PropertyBool, PropertyPtr, PropertyUint32, Role}, + gfx::{GraphicsEventPublisherPtr, Point, Rectangle}, + prop::{PropertyBool, PropertyPtr, Role}, pubsub::Subscription, - scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId, Signal}, + scene::{Pimpl, SceneGraphPtr2, SceneNodeId}, ExecutorPtr, }; -use super::{eval_rect, get_parent_rect, read_rect, DrawUpdate, OnModify, Stoppable}; +use super::{eval_rect, read_rect}; pub type ButtonPtr = Arc