mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 795804 - Extremely slow save
Only update the status bar when the percentage changes by at least 1% because running the mainloop is expensive on macOS and Microsoft Windows. This speeds up all operations that run the progress bar with overly-fine resolution.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "gnc-gnome-utils.h"
|
||||
#include "gnc-splash.h"
|
||||
@@ -170,7 +171,13 @@ gnc_update_splash_screen (const gchar *string, double percentage)
|
||||
|
||||
if (progress_bar )
|
||||
{
|
||||
if (percentage < 0)
|
||||
double curr_fraction =
|
||||
round(gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(progress_bar)) * 100.0);
|
||||
if (percentage >= 0 && percentage <= 100.0 &&
|
||||
round(percentage) == curr_fraction)
|
||||
return; // No change so don't wast time running the main loop
|
||||
|
||||
if (percentage <= 0)
|
||||
{
|
||||
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar), 0.0);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-plugin-page.h"
|
||||
@@ -167,6 +168,7 @@ gnc_window_show_progress (const char *message, double percentage)
|
||||
{
|
||||
GncWindow *window;
|
||||
GtkWidget *progressbar;
|
||||
double curr_fraction;
|
||||
|
||||
window = progress_bar_hack_window;
|
||||
if (window == NULL)
|
||||
@@ -179,6 +181,13 @@ gnc_window_show_progress (const char *message, double percentage)
|
||||
return;
|
||||
}
|
||||
|
||||
curr_fraction =
|
||||
round(gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(progressbar)) * 100.0);
|
||||
|
||||
if (percentage >= 0 && percentage <= 100 &&
|
||||
round(percentage) == curr_fraction)
|
||||
return; // No change, so don't waste time running the main loop.
|
||||
|
||||
gnc_update_splash_screen(message, percentage);
|
||||
|
||||
if (percentage < 0)
|
||||
@@ -192,13 +201,13 @@ gnc_window_show_progress (const char *message, double percentage)
|
||||
{
|
||||
if (message && *message)
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progressbar), message);
|
||||
if ((percentage == 0) &&
|
||||
if ((percentage == 0.0) &&
|
||||
(GNC_WINDOW_GET_IFACE(window)->ui_set_sensitive != NULL))
|
||||
GNC_WINDOW_GET_IFACE(window)->ui_set_sensitive(window, FALSE);
|
||||
if (percentage <= 100)
|
||||
if (percentage <= 100.0)
|
||||
{
|
||||
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar),
|
||||
percentage / 100);
|
||||
percentage / 100.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user