Skip to content

Commit

Permalink
scm_to_value<QofInstance*>() handle Swigged ptrs as well as GUIDs.
Browse files Browse the repository at this point in the history
Some swigged engine functions used to set options return Swigged ptrs.
  • Loading branch information
jralls committed Aug 1, 2021
1 parent 16a36d9 commit 81d2618
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libgnucash/app-utils/gnc-optiondb.i
Expand Up @@ -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;
Expand Down

0 comments on commit 81d2618

Please sign in to comment.