diff --git a/wfassoc/src/highlevel.rs b/wfassoc/src/highlevel.rs index a750dda..befa42a 100644 --- a/wfassoc/src/highlevel.rs +++ b/wfassoc/src/highlevel.rs @@ -687,18 +687,25 @@ impl Program { // Now try fetch its diaplay name in modern way first. // If there is no modern way, use legacy way instead. // If there is still no display name, use ProgId self instead as display name. - let name = match progid_key.get_friendly_type_name(view)? { - Some(name) => name.extract()?, - None => match progid_key.get_default(view)? { - Some(name) => name.extract()?, - None => progid_key.inner().to_string(), - }, - }; + let mut name: Option = None; + if let None = name { + name = progid_key + .get_friendly_type_name(view)? + .map(|name| name.extract().ok()) + .flatten(); + } + if let None = name { + name = progid_key + .get_default(view)? + .map(|name| name.extract().ok()) + .flatten(); + } + let name = name.unwrap_or(progid_key.inner().to_string()); // Now try to fetch icon. let icon = progid_key .get_default_icon(view)? - .map(|ico| ico.extract(concept::IconSizeKind::Small)) - .transpose()?; + .map(|ico| ico.extract(concept::IconSizeKind::Small).ok()) + .flatten(); // Okey, return it. Ok(Some(ProgramExtStatus::new(name, icon))) diff --git a/wfassoc/src/lowlevel.rs b/wfassoc/src/lowlevel.rs index 2385353..41d6728 100644 --- a/wfassoc/src/lowlevel.rs +++ b/wfassoc/src/lowlevel.rs @@ -160,10 +160,7 @@ pub enum IconResVariant { impl IconResVariant { pub fn extract(&self, kind: concept::IconSizeKind) -> Result { let rc = match self { - IconResVariant::Plain(v) => { - eprintln!("plain: {v}"); - concept::IconRc::with_ico_file(v.as_str(), kind)? - }, + IconResVariant::Plain(v) => concept::IconRc::with_ico_file(v.as_str(), kind)?, IconResVariant::RefStr(v) => { // Try expand path part if possible let path_part = strip_quote(v.get_path()); @@ -171,13 +168,11 @@ impl IconResVariant { Ok(expand_string) => expand_string.expand()?, Err(_) => path_part.to_string(), }; - eprintln!("refstr: {path_part}"); // Get index part. let index_part = v.get_index(); - eprintln!("refstr: {index_part}"); // Resolve icon resource concept::IconRc::new(&path_part, index_part, kind)? - }, + } }; Ok(rc) } @@ -238,10 +233,8 @@ impl StrResVariant { Ok(expand_string) => expand_string.expand()?, Err(_) => path_part.to_string(), }; - eprintln!("{path_part}"); // Get index part let index_part = v.get_index(); - eprintln!("{index_part}"); // Resolve string resource let rc = concept::StrRc::new(&path_part, index_part)?; rc.into_string() @@ -419,7 +412,7 @@ fn check_privilege(territory: OpenKeyTerritory, purpose: OpenKeyPurpose) -> Resu } /// Remove quote pair if possible. -/// +/// /// In some cases, the path part of [concept::IconRefStr] or [concept::StrRefStr] is quoted by quote. /// This can no be recognized by Win32 functions. /// So in this case, we should remove this quote pair.