Skip to content

Commit e90aebf

Browse files
committed
fix a crash after row drag between cols
1 parent cf6d124 commit e90aebf

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- better change handling in ientry improves matrixview behaviour
44
- better subrow finding fixes replace from file in nested columns
5+
- fix a crash on row access after row drag between columns
56

67
## 9.0.4 2025/03/20
78

TODO

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
- try
2-
3-
nip4 ~/lady_orig.ws
4-
drag A2 into column I
5-
press V (down) on A2, segv
6-
7-
81
- "reset" in display bar resets the position of scale/offset widgets, but does
92
not reset the menu items (eg. tick on falsecolour)
103

src/icontainer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,9 @@ icontainer_current(iContainer *parent, iContainer *child)
431431

432432
#ifdef DEBUG
433433
printf("icontainer_current: (child %p)\n", child);
434-
printf("\tchild: %s \"%s\"\n",
435-
G_OBJECT_TYPE_NAME(child), IOBJECT(child)->name);
434+
if (child)
435+
printf("\tchild: %s \"%s\"\n",
436+
G_OBJECT_TYPE_NAME(child), IOBJECT(child)->name);
436437
#endif /*DEBUG*/
437438

438439
#ifdef DEBUG_SANITY

src/reduce.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,9 +2112,11 @@ reduce_regenerate_member(Expr *expr, PElement *ths, PElement *out)
21122112
*/
21132113
if (is_super(expr->compile->sym)) {
21142114
Compile *parent = compile_get_parent(expr->compile);
2115+
Subcolumn *scol = row_get_subcolumn(expr->row);
2116+
21152117
PElement instance;
21162118

2117-
PEPOINTE(&instance, &expr->row->scol->base);
2119+
PEPOINTE(&instance, &scol->base);
21182120

21192121
if (!class_new_super(heap, parent, ths, &instance))
21202122
return FALSE;

src/row.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ row_child_add(iContainer *parent, iContainer *child, int pos)
563563
row->child_rhs = row_get_rhs(row);
564564
}
565565

566-
static Subcolumn *
566+
Subcolumn *
567567
row_get_subcolumn(Row *row)
568568
{
569569
return SUBCOLUMN(ICONTAINER(row)->parent);
@@ -607,7 +607,6 @@ row_parent_add(iContainer *child)
607607

608608
/* Update our context.
609609
*/
610-
row->scol = row_get_subcolumn(row);
611610
row->ws = row_get_workspace(row);
612611
row->top_row = row_get_root(row);
613612
}
@@ -623,7 +622,6 @@ row_parent_remove(iContainer *child)
623622
row_deselect(row);
624623
workspace_queue_layout(row->ws);
625624

626-
row->scol = NULL;
627625
row->ws = NULL;
628626
row->top_row = NULL;
629627

@@ -785,14 +783,16 @@ row_set_to_save(Row *row)
785783
Row *enclosing;
786784

787785
if (!row->to_save) {
786+
Subcolumn *scol = row_get_subcolumn(row);
787+
788788
row->to_save = TRUE;
789789

790790
/* All peers must be saved. When we reload, we want to keep
791791
* row ordering. If we just save modded row, they'll move to
792792
* the front of the row list on reload, since they'll be made
793793
* first.
794794
*/
795-
icontainer_map(ICONTAINER(row->scol),
795+
icontainer_map(ICONTAINER(scol),
796796
(icontainer_map_fn) row_set_to_save, NULL, NULL);
797797

798798
/* All rows back up to the top level must also be saved.
@@ -984,7 +984,6 @@ row_init(Row *row)
984984
printf("row_init:\n");
985985
#endif /*DEBUG*/
986986

987-
row->scol = NULL;
988987
row->child_rhs = NULL;
989988
row->ws = NULL;
990989
row->top_row = NULL;
@@ -1177,6 +1176,8 @@ row_link_build2(Expr *expr, Row *row)
11771176
static void *
11781177
row_link_build(Row *row)
11791178
{
1179+
Subcolumn *scol = row_get_subcolumn(row);
1180+
11801181
#ifdef DEBUG_LINK
11811182
printf("row_link_build: ");
11821183
row_name_print(row);
@@ -1185,7 +1186,7 @@ row_link_build(Row *row)
11851186

11861187
/* Build new recomp list. Only for class displays.
11871188
*/
1188-
if (!row->scol->is_top && row->expr &&
1189+
if (!scol->is_top && row->expr &&
11891190
row_link_build2(row->expr, row))
11901191
return row;
11911192

@@ -1502,11 +1503,11 @@ row_regenerate(Row *row)
15021503
* local classes); the enclosing one should
15031504
* be the same as the most enclosing this.
15041505
*/
1505-
Row *this = row->scol->this;
1506+
Subcolumn *scol = row_get_subcolumn(row);
1507+
Row *this = scol->this;
15061508
gboolean res;
15071509

1508-
res = reduce_regenerate_member(expr,
1509-
&this->expr->root, root);
1510+
res = reduce_regenerate_member(expr, &this->expr->root, root);
15101511
expr_new_value(expr);
15111512

15121513
if (!res)
@@ -1528,6 +1529,7 @@ static gboolean
15281529
row_recomp_row(Row *row)
15291530
{
15301531
Rhs *rhs = row->child_rhs;
1532+
Subcolumn *scol = row_get_subcolumn(row);
15311533

15321534
#ifdef DEBUG
15331535
printf("row_recomp_row: ");
@@ -1553,7 +1555,7 @@ row_recomp_row(Row *row)
15531555
/* We're about to zap the graph: make sure this tree of rows has a
15541556
* private copy.
15551557
*/
1556-
if (!subcolumn_make_private(row->scol))
1558+
if (!subcolumn_make_private(scol))
15571559
return FALSE;
15581560

15591561
/* Regenerate from the expr.
@@ -1873,8 +1875,9 @@ row_select_extend(Row *row)
18731875
/* Range select if there was a previous selection, and it was in the
18741876
* same subcolumn.
18751877
*/
1876-
if (last_select && row->scol == last_select->scol) {
1877-
Subcolumn *scol = row->scol;
1878+
if (last_select &&
1879+
row_get_subcolumn(row) == row_get_subcolumn(last_select)) {
1880+
Subcolumn *scol = row_get_subcolumn(row);
18781881
GSList *rows = ICONTAINER(scol)->children;
18791882
int pos = g_slist_index(rows, row);
18801883
int pos_last = g_slist_index(rows, last_select);

src/row.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ struct _Row {
5252

5353
/* Our context.
5454
*/
55-
Subcolumn *scol; /* Enclosing subcolumn */
5655
Rhs *child_rhs; /* Child RHS */
5756
Workspace *ws; /* Enclosing workspace */
5857
Row *top_row; /* Enclosing root row */
@@ -89,6 +88,7 @@ const char *row_name(Row *row);
8988
void row_qualified_name_relative(Symbol *context, Row *row, VipsBuf *buf);
9089
void row_qualified_name(Row *row, VipsBuf *buf);
9190
void *row_name_print(Row *row);
91+
Subcolumn *row_get_subcolumn(Row *row);
9292
Column *row_get_column(Row *row);
9393

9494
void row_error_set(Row *row);

src/subcolumn.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ subcolumn_get_subcolumn(Subcolumn *scol)
430430
Rhs *rhs = HEAPMODEL(scol)->rhs;
431431
Row *row = HEAPMODEL(rhs)->row;
432432

433-
return row->scol;
433+
return row_get_subcolumn(row);
434434
}
435435
}
436436

@@ -445,7 +445,8 @@ subcolumn_get_root_subcolumn(Subcolumn *scol)
445445
else {
446446
Subcolumn *enclosing = subcolumn_get_subcolumn(scol);
447447

448-
return enclosing->is_top ? scol : subcolumn_get_root_subcolumn(enclosing);
448+
return enclosing->is_top ?
449+
scol : subcolumn_get_root_subcolumn(enclosing);
449450
}
450451
}
451452

@@ -454,7 +455,8 @@ subcolumn_get_root_subcolumn(Subcolumn *scol)
454455
Column *
455456
subcolumn_get_column(Subcolumn *scol)
456457
{
457-
Subcolumn *root = scol->is_top ? scol : subcolumn_get_subcolumn(subcolumn_get_root_subcolumn(scol));
458+
Subcolumn *root = scol->is_top ?
459+
scol : subcolumn_get_subcolumn(subcolumn_get_root_subcolumn(scol));
458460

459461
return COLUMN(ICONTAINER(root)->parent);
460462
}

0 commit comments

Comments
 (0)