scm_to_value<QofInstance*>() handle Swigged ptrs as well as GUIDs.

Some swigged engine functions used to set options return Swigged ptrs.
This commit is contained in:
John Ralls 2021-02-19 16:13:59 -08:00
parent 16a36d9104
commit 81d261897e

View File

@ -164,7 +164,16 @@ template <> inline const QofInstance*
scm_to_value<const QofInstance*>(SCM new_value)
{
if (new_value == SCM_BOOL_F || !scm_is_pair(new_value))
return nullptr;
{
void* ptr{};
SWIG_ConvertPtr(new_value, &ptr, SWIGTYPE_p_QofInstance_s, 0);
if (ptr)
return static_cast<const QofInstance*>(ptr);
SWIG_ConvertPtr(new_value, &ptr, SWIGTYPE_p_gnc_commodity, 0);
if (ptr)
return static_cast<const QofInstance*>(ptr);
}
auto guid_str{scm_to_utf8_stringn(scm_car(new_value), nullptr)};
auto type{scm_to_utf8_stringn(scm_cdr(new_value), nullptr)};
GncGUID new_guid;