From b23c4b4da6b9827e301a20370c0791d14ba2f6e2 Mon Sep 17 00:00:00 2001 From: jikstra Date: Sat, 10 Aug 2019 16:51:57 +0200 Subject: [PATCH] Remove debug printlns, refactor a bit --- src/dc_chat.rs | 1 - src/dc_msg.rs | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/dc_chat.rs b/src/dc_chat.rs index 14b6a73de..5497ad927 100644 --- a/src/dc_chat.rs +++ b/src/dc_chat.rs @@ -1081,7 +1081,6 @@ pub fn dc_get_chat_msgs( let process_rows = |rows: rusqlite::MappedRows<_>| { for row in rows { let (curr_id, ts) = row?; - //println!("{}", curr_id); if curr_id as u32 == marker1before { ret.add_id(1); } diff --git a/src/dc_msg.rs b/src/dc_msg.rs index c86a3cb7a..586092375 100644 --- a/src/dc_msg.rs +++ b/src/dc_msg.rs @@ -441,7 +441,6 @@ pub unsafe fn dc_msg_get_timestamp(msg: *const dc_msg_t) -> i64 { pub fn dc_msg_load_from_db<'a>(msg: *mut dc_msg_t<'a>, context: &'a Context, id: u32) -> bool { if msg.is_null() { - println!("xxx msg is null {}", id); return false; } @@ -476,15 +475,13 @@ pub fn dc_msg_load_from_db<'a>(msg: *mut dc_msg_t<'a>, context: &'a Context, id: (*msg).type_0 = row.get(12)?; (*msg).state = row.get(13)?; (*msg).is_dc_message = row.get(14)?; - println!("Before2 text: {}", id); - (*msg).text = match row.get(15) { - Ok(text) => Some(text), + (*msg).text = Some(match row.get(15) { + Ok(text) => text, Err(e) => { warn!(context, 0, "dc_msg_load_from_db: could not get text column for id {} because of {}", id, e); - Some("[ Could not read from db ]".to_string()) + "[ Could not read from db ]".to_string() } - }; - println!("After text: {}", id); + }); (*msg).param = row.get::<_, String>(16)?.parse().unwrap_or_default(); (*msg).starred = row.get(17)?; (*msg).hidden = row.get(18)?; @@ -503,10 +500,13 @@ pub fn dc_msg_load_from_db<'a>(msg: *mut dc_msg_t<'a>, context: &'a Context, id: Ok(()) } }); - // HERE WE ARE! + if let Err(e) = res { - warn!(context, 0, "Error in msg_load_from_db for id {} because of {}", id, e); - return false; + warn!( + context, + 0, "Error in msg_load_from_db for id {} because of {}", id, e + ); + return false; } true } @@ -650,7 +650,6 @@ pub unsafe fn dc_get_msg<'a>(context: &'a Context, msg_id: uint32_t) -> *mut dc_ success = true } - if success { obj } else {