[gnumeric] Performance: faster exit with conditional formatting.



commit 22e228a4ce22c621d4c3c13a20a7a78226573e19
Author: Morten Welinder <terra gnome org>
Date:   Sat Mar 7 16:55:03 2020 -0500

    Performance: faster exit with conditional formatting.

 NEWS           | 1 +
 src/mstyle.c   | 4 +++-
 src/sheet.h    | 1 +
 src/workbook.c | 5 +++++
 4 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/NEWS b/NEWS
index def495aba..248407e8a 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Morten:
        * Fix dialog size problem.
        * Add "--set CELL=CONTENTS" option to ssconvert.
        * Improve tests.
+       * Improve speed on exit with lots of conditional formatting.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.46
diff --git a/src/mstyle.c b/src/mstyle.c
index 02d446b61..64182ad2a 100644
--- a/src/mstyle.c
+++ b/src/mstyle.c
@@ -26,6 +26,7 @@
 #include <value.h>
 #include <gutils.h>
 #include <ranges.h>
+#include <sheet.h>
 #include <gnumeric-conf.h>
 #include <goffice/goffice.h>
 #include <string.h>
@@ -2412,7 +2413,8 @@ gnm_style_unlink_dependents (GnmStyle *style, GnmRange const *r)
                GnmDependent *dep = g_ptr_array_index (style->deps, ui);
                GnmCellPos const *pos = dependent_pos (dep);
 
-               if (range_contains (r, pos->col, pos->row)) {
+               if (dep->sheet->being_destructed ||
+                   range_contains (r, pos->col, pos->row)) {
                        if (debug_style_deps ())
                                g_printerr ("Unlinking %s for %p\n",
                                            cellpos_as_string (pos), style);
diff --git a/src/sheet.h b/src/sheet.h
index 1c1280fe2..83b56e238 100644
--- a/src/sheet.h
+++ b/src/sheet.h
@@ -38,6 +38,7 @@ struct _Sheet {
        Workbook    *workbook;
        gboolean    being_invalidated;
        gboolean    being_constructed;
+       gboolean    being_destructed;
 
        GOUndoGroup *revive;
 
diff --git a/src/workbook.c b/src/workbook.c
index 06735e7b9..07e9a63b8 100644
--- a/src/workbook.c
+++ b/src/workbook.c
@@ -169,9 +169,14 @@ workbook_dispose (GObject *wb_object)
                Sheet *sheet = ptr->data;
                GnmRange r;
 
+               sheet->being_destructed = TRUE;
+
                sheet_destroy_contents (sheet);
                range_init_full_sheet (&r, sheet);
+
                sheet_style_set_range (sheet, &r, sheet_style_default (sheet));
+
+               sheet->being_destructed = FALSE;
        }
 
        /* Now remove the sheets themselves */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]