Re: Unstable Imap Editor

2018-03-28 Thread Geert Janssens
Op woensdag 28 maart 2018 12:09:33 CEST schreef Robert Fewell:
> Could some one explain the following, trying to fix the 2nd problem as I
> thought was the simpler one...
> If I try this ...
> 
> std::vector path {IMAP_FRAME};
> if (category)
> path.emplace_back (category);
> 
> if (qof_instance_has_path_slot (QOF_INSTANCE (acc), path))
> 
> I have a slot but the following does not...
> 
> category_head = g_strdup_printf (IMAP_FRAME "/%s", category);
> 
> if (qof_instance_has_slot (QOF_INSTANCE(acc), category_head))
> 
> These two functions look like this...
> 
> bool qof_instance_has_path_slot (QofInstance const * inst,
> std::vector const & path)
> {
> return inst->kvp_data->get_slot (path) != nullptr;
> }
> 
> gboolean
> qof_instance_has_slot (const QofInstance *inst, const char *path)
> {
> return inst->kvp_data->get_slot({path}) != NULL;
> }
> 
> Does category_head need to be in a different format ?

get_slot expects a vector of path components.

In your first example that is what you pass. That path vector has two 
elements: IMAP_FRAME and category.

In the second example you pass a concatenated string that is used to 
initialize a path vector with one element. That is not what get_slot is 
expecting. It will search its internal model for this string as a key, but 
that doesn't exist. Only category exists as key. Using the vector 
specification it does work.

The primary change here is that internally gnucash is not interpreting the "/" 
as a path separator any more.

Geert


___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: Unstable Imap Editor

2018-03-28 Thread Robert Fewell
Could some one explain the following, trying to fix the 2nd problem as I
thought was the simpler one...
If I try this ...

std::vector path {IMAP_FRAME};
if (category)
path.emplace_back (category);

if (qof_instance_has_path_slot (QOF_INSTANCE (acc), path))

I have a slot but the following does not...

category_head = g_strdup_printf (IMAP_FRAME "/%s", category);

if (qof_instance_has_slot (QOF_INSTANCE(acc), category_head))

These two functions look like this...

bool qof_instance_has_path_slot (QofInstance const * inst,
std::vector const & path)
{
return inst->kvp_data->get_slot (path) != nullptr;
}

gboolean
qof_instance_has_slot (const QofInstance *inst, const char *path)
{
return inst->kvp_data->get_slot({path}) != NULL;
}

Does category_head need to be in a different format ?

Regards,

Bob



On 27 March 2018 at 17:33, Robert Fewell <14ubo...@gmail.com> wrote:

> It was mentioned some where it was slow to load so thought I would have a
> look.
>
> Dropping the GtkTreeModel has improved that but that has highlighted a
> couple of problems so far...
>
> 1st, when retrieving 'import-map-bays', the list consists of the number of
> tokens squared like this...
>  imported 1 transaction which results in 3 tokens and 1 transaction which
> results in 2 tokens in the file which then leads to 25 entries in the
> treeview.
>
> So for the above the list coming back from 'gnc_account_imap_get_info_bayes'
> is 25 entries.
>
> 2nd, when retrieving 'import-map', the list is empty despite having this
> entry...
>
>   Checking Account
>   
> 
>   import-map
>   
> 
>   desc
>   
> 
>   'MY HEALTH
>   32282cd8503549af9cf62265df11b3
> c7
> 
>   
> 
>   
> 
>
> It seems that in account.cpp line 5642 which is..
>
> if (qof_instance_has_slot (QOF_INSTANCE(acc), category_head))
>
> is returning false despite category_head being 'import-map/desc'
>
> Hopefully I will get it sorted and create a PR for it.
>
> Bob
>
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel