Bug799751 - autocomplete crash and some#2199
Conversation
jralls
left a comment
There was a problem hiding this comment.
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++) |
There was a problem hiding this comment.
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,
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Sorry, you've lost me. What widget value is null? You mean here, right?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
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.
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.