Skip to content

Commit

Permalink
Merge John Ralls's 'bug798890' into stable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jralls committed Sep 26, 2023
2 parents 15193c5 + 2038903 commit 14e0696
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions gnucash/gnome/gnc-plugin-page-report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ typedef struct GncPluginPageReportPrivate
/// The report-id
int reportId;
gint component_manager_id;

GSimpleActionGroup* action_group;
/// The report which this Page is satisfying
SCM cur_report;
/// The Option DB for this report.
Expand Down Expand Up @@ -201,6 +201,17 @@ static GActionEntry report_actions[] =
{ "ReportStopAction", gnc_plugin_page_report_stop_cb, nullptr, nullptr, nullptr },
};
static guint num_report_actions = G_N_ELEMENTS(report_actions);
static const gchar *initially_insensitive_actions[] =
{
nullptr
};

static const gchar *disable_during_load_actions[] =
{
"FilePrintAction",
"FilePrintPDFAction",
"ReportOptionsAction"
};

/** The default menu items that need to be add to the menu */
static const gchar *gnc_plugin_load_ui_items [] =
Expand Down Expand Up @@ -443,6 +454,8 @@ gnc_plugin_page_report_load_uri (GncPluginPage *page)
g_object_remove_weak_pointer(G_OBJECT(page), (gpointer*)(&weak_page));
}

gnc_plugin_set_actions_enabled(G_ACTION_MAP(priv->action_group),
disable_during_load_actions, TRUE);
// this resets the window for the progressbar to nullptr
gnc_window_set_progressbar_window( nullptr );
}
Expand Down Expand Up @@ -794,6 +807,8 @@ gnc_plugin_page_report_option_change_cb(gpointer data)
/* it's probably already dirty, but make sure */
scm_call_2(dirty_report, priv->cur_report, SCM_BOOL_T);

gnc_plugin_set_actions_enabled(G_ACTION_MAP(priv->action_group),
disable_during_load_actions, FALSE);
// prevent closing this page while loading...
priv->reloading = TRUE;

Expand All @@ -811,6 +826,8 @@ gnc_plugin_page_report_option_change_cb(gpointer data)
// this resets the window for the progressbar to nullptr
gnc_window_set_progressbar_window( nullptr );

gnc_plugin_set_actions_enabled(G_ACTION_MAP(priv->action_group),
disable_during_load_actions, FALSE);
priv->reloading = FALSE;
}

Expand Down Expand Up @@ -1175,14 +1192,11 @@ gnc_plugin_page_report_destroy(GncPluginPageReportPrivate * priv)
scm_gc_unprotect_object(priv->edited_reports);
}

static const gchar *initially_insensitive_actions[] =
{
nullptr
};

static void
gnc_plugin_page_report_init ( GncPluginPageReport *plugin_page )
{
GncPluginPageReportPrivate *priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(plugin_page);
priv->action_group = NULL;
}

static GObject*
Expand Down Expand Up @@ -1277,7 +1291,6 @@ static void
gnc_plugin_page_report_constr_init (GncPluginPageReport *plugin_page, gint reportId)
{
GncPluginPageReportPrivate *priv;
GSimpleActionGroup *simple_action_group;
GncPluginPage *parent;
gboolean use_new;
gchar *name;
Expand All @@ -1304,14 +1317,16 @@ gnc_plugin_page_report_constr_init (GncPluginPageReport *plugin_page, gint repor
gnc_plugin_page_add_book (parent, gnc_get_current_book());

/* Create menu and toolbar information */
simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageReportActions");
g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
priv->action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageReportActions");
g_action_map_add_action_entries (G_ACTION_MAP(priv->action_group),
report_actions,
num_report_actions,
plugin_page);

gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), initially_insensitive_actions,
gnc_plugin_set_actions_enabled (G_ACTION_MAP(priv->action_group), initially_insensitive_actions,
FALSE);
gnc_plugin_set_actions_enabled(G_ACTION_MAP(priv->action_group),
disable_during_load_actions, FALSE);
}

GncPluginPage*
Expand Down Expand Up @@ -1456,7 +1471,9 @@ gnc_plugin_page_report_reload_cb (GSimpleAction *simple,
scm_call_2(dirty_report, priv->cur_report, SCM_BOOL_T);

/* now queue the fact that we need to reload this report */

// Disable some actions reported to crash while loading
gnc_plugin_set_actions_enabled(G_ACTION_MAP(priv->action_group),
disable_during_load_actions, FALSE);
// prevent closing this page while loading...
priv->reloading = TRUE;
// this sets the window for the progressbar
Expand All @@ -1471,6 +1488,8 @@ gnc_plugin_page_report_reload_cb (GSimpleAction *simple,

// this resets the window for the progressbar to nullptr
gnc_window_set_progressbar_window( nullptr );
gnc_plugin_set_actions_enabled(G_ACTION_MAP(priv->action_group),
disable_during_load_actions, FALSE);
priv->reloading = FALSE;
}

Expand Down

0 comments on commit 14e0696

Please sign in to comment.