[gnumeric] ssconvert: fix hash usage problem.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ssconvert: fix hash usage problem.
- Date: Fri, 20 Apr 2018 18:46:12 +0000 (UTC)
commit b8f6e211a3a9351c6c620528f684b8b1253eab9f
Author: Morten Welinder <terra gnome org>
Date: Fri Apr 20 14:45:49 2018 -0400
ssconvert: fix hash usage problem.
ChangeLog | 3 +++
NEWS | 1 +
src/ssconvert.c | 27 ++++++++++++++++-----------
3 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c98a92e..ee0bc35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2018-04-20 Morten Welinder <terra gnome org>
+ * src/ssconvert.c (merge_single): Avoid a
+ hash-changed-while-iterating problem. [#795408]
+
* src/xml-sax-write.c (xml_write_cell_and_position): In the
clipboard case, write result values too.
diff --git a/NEWS b/NEWS
index 5a7ea24..cb42ba8 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ Morten:
* Fix paste from LibreOffice.
* Fix paste to LibreOffice -- use Biff8. [#795280]
* Allow inter-process paste-special. [#346630]
+ * Fix ssconvert --merge-to problem with names. [#795408]
--------------------------------------------------------------------------
Gnumeric 1.12.39
diff --git a/src/ssconvert.c b/src/ssconvert.c
index addb9a4..e1ab773 100644
--- a/src/ssconvert.c
+++ b/src/ssconvert.c
@@ -343,22 +343,15 @@ suggest_size (GSList *wbs, int *csuggest, int *rsuggest)
}
static void
-cb_fixup_name_wb (G_GNUC_UNUSED gconstpointer key,
+cb_collect_names (G_GNUC_UNUSED gconstpointer key,
GnmNamedExpr *nexpr,
- Workbook *wb)
+ GSList **plist)
{
- GnmParsePos newpos = nexpr->pos;
-
if (!expr_name_is_active (nexpr))
return;
-
- if (nexpr->pos.wb) {
- newpos.wb = wb;
- expr_name_set_pos (nexpr, &newpos);
- }
+ *plist = g_slist_prepend (*plist, expr_name_ref (nexpr));
}
-
/* Append the sheets of workbook wb2 to workbook wb. Resize sheets
if necessary. Fix workbook links in sheet if necessary.
Merge names in workbook scope (conflicts result in an error). */
@@ -409,13 +402,25 @@ merge_single (Workbook *wb, Workbook *wb2,
GOUndo *undo;
char *sheet_name;
gboolean err;
+ GSList *names = NULL;
g_object_ref (sheet);
workbook_sheet_delete (sheet);
sheet->workbook = wb;
/* Fix names that reference the old workbook */
- gnm_sheet_foreach_name (sheet, (GHFunc)cb_fixup_name_wb, wb);
+ gnm_sheet_foreach_name (sheet, (GHFunc)cb_collect_names, &names);
+ while (names) {
+ GnmNamedExpr *nexpr = names->data;
+ names = g_slist_delete_link (names, names);
+
+ if (nexpr->pos.wb) {
+ GnmParsePos newpos = nexpr->pos;
+ newpos.wb = wb;
+ expr_name_set_pos (nexpr, &newpos);
+ }
+ expr_name_unref (nexpr);
+ }
undo = gnm_sheet_resize (sheet, cmax, rmax, cc, &err);
if (undo)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]