From 612d654f972e7a414694dcd381681809131daea9 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Wed, 21 Oct 2026 11:04:25 -0400 Subject: [PATCH 1/2] Normalize error values before selecting a property editor Apply the same input handling to fetched and caller-supplied properties. Preserve creation of missing typed properties and use PT_ERROR for other returned errors rather than reading their union as a GUID or another requested type. Fixes #854. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- UI/Dialogs/Editors/propeditor/ipropeditor.cpp | 35 ++++++------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/UI/Dialogs/Editors/propeditor/ipropeditor.cpp b/UI/Dialogs/Editors/propeditor/ipropeditor.cpp index 94d0d64fc..17986f6ca 100644 --- a/UI/Dialogs/Editors/propeditor/ipropeditor.cpp +++ b/UI/Dialogs/Editors/propeditor/ipropeditor.cpp @@ -43,35 +43,22 @@ namespace dialog::editor 1, PROP_TYPE(ulPropTag) == PT_ERROR ? CHANGE_PROP_TYPE(ulPropTag, PT_UNSPECIFIED) : ulPropTag}; ULONG ulValues = NULL; - auto hRes = WC_MAPI(lpMAPIProp->GetProps(&sTag, NULL, &ulValues, &sourceProp)); - - // Suppress MAPI_E_NOT_FOUND error when the source type is non error - if (sourceProp && PROP_TYPE(sourceProp->ulPropTag) == PT_ERROR && - sourceProp->Value.err == MAPI_E_NOT_FOUND && PROP_TYPE(ulPropTag) != PT_ERROR) - { - MAPIFreeBuffer(sourceProp); - sourceProp = nullptr; - } + WC_MAPI_S(lpMAPIProp->GetProps(&sTag, NULL, &ulValues, &sourceProp)); + lpsPropValue = sourceProp; + } - if (hRes == MAPI_E_CALL_FAILED) + if (lpsPropValue) + { + // Missing values can be created, but other errors must not be read as the requested type. + if (PROP_TYPE(lpsPropValue->ulPropTag) == PT_ERROR && + lpsPropValue->Value.err == MAPI_E_NOT_FOUND && PROP_TYPE(ulPropTag) != PT_ERROR) { - // Just suppress this - let the user edit anyway - hRes = S_OK; + lpsPropValue = nullptr; } - - // In all cases where we got a value back, we need to reset our property tag to the value we got - // This will address when the source is PT_UNSPECIFIED, when the returned value is PT_ERROR, - // or any other case where the returned value has a different type than requested - if (SUCCEEDED(hRes) && sourceProp) + else { - ulPropTag = sourceProp->ulPropTag; + ulPropTag = lpsPropValue->ulPropTag; } - - lpsPropValue = sourceProp; - } - else if (lpsPropValue && PROP_TYPE(lpsPropValue->ulPropTag) != PT_ERROR) - { - ulPropTag = lpsPropValue->ulPropTag; } auto propertyEditor = std::shared_ptr{}; From f095f0f023b5ad7bca190936084bf9c678a17cc7 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Wed, 21 Oct 2026 12:34:21 -0400 Subject: [PATCH 2/2] Apply clang-format 17 to property editor normalization Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- UI/Dialogs/Editors/propeditor/ipropeditor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UI/Dialogs/Editors/propeditor/ipropeditor.cpp b/UI/Dialogs/Editors/propeditor/ipropeditor.cpp index 17986f6ca..7b95f4720 100644 --- a/UI/Dialogs/Editors/propeditor/ipropeditor.cpp +++ b/UI/Dialogs/Editors/propeditor/ipropeditor.cpp @@ -50,8 +50,8 @@ namespace dialog::editor if (lpsPropValue) { // Missing values can be created, but other errors must not be read as the requested type. - if (PROP_TYPE(lpsPropValue->ulPropTag) == PT_ERROR && - lpsPropValue->Value.err == MAPI_E_NOT_FOUND && PROP_TYPE(ulPropTag) != PT_ERROR) + if (PROP_TYPE(lpsPropValue->ulPropTag) == PT_ERROR && lpsPropValue->Value.err == MAPI_E_NOT_FOUND && + PROP_TYPE(ulPropTag) != PT_ERROR) { lpsPropValue = nullptr; }