Skip to content

Bug799751 - autocomplete crash and some#2199

Open
Bob-IT wants to merge 15 commits intoGnucash:stablefrom
Bob-IT:bug799751
Open

Bug799751 - autocomplete crash and some#2199
Bob-IT wants to merge 15 commits intoGnucash:stablefrom
Bob-IT:bug799751

Conversation

@Bob-IT
Copy link
Copy Markdown
Contributor

@Bob-IT Bob-IT commented Apr 6, 2026

The first two commits are really just some cosmetic changes regarding space and naming of GncPluginPage...

The third commit fixes the bug, it was not crashing for me but I think it fixes the issue regarding the General Journal autocomplete. What I think was happening is that the default query for only 30 days was being used to create the register view when selecting 'Show All' and the order was changed from standard order, the query was being updated but the register view was not being refreshed which I think this was a side effect from the change to just load the register when it is visible.
The fix for this is not do any refreshing when the register is created or recreated and leave it to the register focus call back to request a refresh when it is visible.
As a follow up to this the next commit stops the register refreshing when the application is quitting.

The next three commits are something I have wanted to do and that is split out the filter and sort dialogs to separate files and hopefully making it more manageable.

The last five commits is my attempt to convert those files to c++ with no doubt numerous mistakes so can be easily discarded if required.

One last thing to note, while testing this, the settings for 'today', 'earliest' and 'latest' are not saved correctly which reminded me of a bug Chris raised some time ago. I am not really sure the point of saving 'Earliest' and 'Latest' so was considering changing the dialog to use the existing date widget and a period select widget similar to the preference page.
This would obviously be a separate PR.

Copy link
Copy Markdown
Member

@jralls jralls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The design of the filter module can be greatly improved by having a struct or tuple of the filter components in their proper types (e.g. an int for the number of days) and leave the string stuff for explicit IO functions that compose and write or read and parse.


/* Turn off all the check menu items */
for (i = 0; status_actions[i].action_name; i++)
for (int i = 0; status_actions[i].action_name; i++)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change status_actions from a C array into a C++ std::array you can get rid of the sentinel and have

     for (auto action : status_actions)
     {
            g_signal_handlers_block_by_func(action.widget, 

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use std:array but found that if I used this format for the setup in gnc_ppr_filter_by the widget value would be null outside of the setup loop so used the original format for this one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, you've lost me. What widget value is null? You mean here, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the lack clarity, yes that location. I was going to replace that loop with this minus the print statement...

    for (auto action : status_actions)
    {
        auto toggle = GTK_WIDGET(gtk_builder_get_object (builder, action.action_name.c_str()));
        bool value = fd->cleared_match & action.value;
        action.widget = toggle;
g_print("action.name, '%s', action.widget %p\n", action.action_name.c_str(), action.widget);
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(toggle), bool_to_gboolean (value));
    }

action.name, 'filter_status_reconciled', action.widget 0x55b382d113d0
action.name, 'filter_status_cleared', action.widget 0x55b382d12ed0
action.name, 'filter_status_voided', action.widget 0x55b382d14ae0
action.name, 'filter_status_frozen', action.widget 0x55b382d166f0
action.name, 'filter_status_unreconciled', action.widget 0x55b382d0f380

but if I try and retrieve the widget with this in the other locations...

    for (auto action : status_actions)
    {
g_print("  action.name, '%s', action.widget %p\n", action.action_name.c_str(), action.widget);
    }

I get this...

action.name, 'filter_status_reconciled', action.widget (nil)
action.name, 'filter_status_cleared', action.widget (nil)
action.name, 'filter_status_voided', action.widget (nil)
action.name, 'filter_status_frozen', action.widget (nil)
action.name, 'filter_status_unreconciled', action.widget (nil)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Try auto& action : status_actions so you get a reference to the status_action instead of a copy. Everywhere else you'll want const auto& action to indicate that you're not changing the action's contents.

Bob-IT added 13 commits April 8, 2026 14:27
With the General Journal saved to show all and sort by 'Date of Entry',
when restoring the page it was only showing the default number of days
which is 30. This was down to the query being updated but the register
was not refreshed, possibly stemming from the change to defer
refreshing pages that are not visible.

This change stops any page refresh when page is being created or
restored till when the page is in focus.
If the page visible is the last page, as they are closed the focus is
passed to the previous page and results in that register being
refreshed before that page is closed. If the visible page was the first
in the list this does not happen.

Retrieve the status of 'window_quitting' from the main window and
add it as a condition for setting focus and subsequent page refresh.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants