diff --git a/lib/layout/clipline.c b/lib/layout/clipline.c index cd05b00bf27e..6d4649a966ff 100644 --- a/lib/layout/clipline.c +++ b/lib/layout/clipline.c @@ -340,7 +340,7 @@ lo_ClipLines(MWContext *context, lo_DocState *state, int32 line) } while ((start_clipping != NULL)&&(start_clipping != end_clipping)) { - lo_ScrapeElement(context, start_clipping); + lo_ScrapeElement(context, start_clipping, TRUE); start_clipping = start_clipping->lo_any.next; } @@ -447,7 +447,7 @@ lo_ClipLines(MWContext *context, lo_DocState *state, int32 line) */ if ((eptr->lo_any.y - dy) < 0) { - lo_ScrapeElement(context, eptr); + lo_ScrapeElement(context, eptr, TRUE); eptr = eptr->lo_any.next; continue; } diff --git a/lib/layout/layfree.c b/lib/layout/layfree.c index c71c7091f7ac..e07ca8250448 100644 --- a/lib/layout/layfree.c +++ b/lib/layout/layfree.c @@ -457,8 +457,12 @@ lo_remove_image(lo_DocLists *doc_lists, LO_Element *element) } +/* freeTableOrCellState should should be set to TRUE to free the + associated lo_TableRec for the LO_TABLE layout element or the + lo_TableCell for an LO_CELL layout element */ + void -lo_ScrapeElement(MWContext *context, LO_Element *element) +lo_ScrapeElement(MWContext *context, LO_Element *element, Bool freeTableOrCellState ) { if (element == NULL) { @@ -736,7 +740,7 @@ lo_ScrapeElement(MWContext *context, LO_Element *element) } /* Free the lo_TableCell record associated with this cell */ - if ( element->lo_cell.table_cell != NULL ) + if ( freeTableOrCellState && element->lo_cell.table_cell != NULL ) { lo_TopState *top_state; lo_DocState *state; @@ -752,7 +756,8 @@ lo_ScrapeElement(MWContext *context, LO_Element *element) case LO_TABLE: { - lo_ScrapeTableElement( context, (LO_TableStruct *) element ); + if (freeTableOrCellState) + lo_ScrapeTableElement( context, (LO_TableStruct *) element ); } break; @@ -813,7 +818,7 @@ lo_FreeElement(MWContext *context, LO_Element *element, Bool do_scrape) if (do_scrape != FALSE) { - lo_ScrapeElement(context, element); + lo_ScrapeElement(context, element, FALSE); } #ifdef MEMORY_ARENAS diff --git a/lib/layout/layout.h b/lib/layout/layout.h index 8f214712c2c0..379a9c232407 100644 --- a/lib/layout/layout.h +++ b/lib/layout/layout.h @@ -994,7 +994,7 @@ extern void lo_FreePartialCell(MWContext *context, lo_DocState *state, extern void lo_FreeElement(MWContext *context, LO_Element *, Bool); extern void lo_FreeElementList(MWContext *, LO_Element *); extern void lo_FreeImageAttributes(LO_ImageAttr *image_attr); -extern void lo_ScrapeElement(MWContext *context, LO_Element *); +extern void lo_ScrapeElement(MWContext *context, LO_Element *, Bool); extern int32 lo_FreeRecycleList(MWContext *context, LO_Element *); extern void lo_FreeGridRec(lo_GridRec *); extern void lo_FreeGridCellRec(MWContext *, lo_GridRec *, lo_GridCellRec *); diff --git a/lib/layout/layutil.c b/lib/layout/layutil.c index ce751191a5ac..a60b875887bc 100644 --- a/lib/layout/layutil.c +++ b/lib/layout/layutil.c @@ -1941,10 +1941,10 @@ lo_RecycleElements(MWContext *context, lo_DocState *state, LO_Element *elements) eptr = elements; while(eptr->lo_any.next != NULL) { - lo_ScrapeElement(context, eptr); + lo_ScrapeElement(context, eptr, TRUE); eptr = eptr->lo_any.next; } - lo_ScrapeElement(context, eptr); + lo_ScrapeElement(context, eptr, TRUE); #ifdef MEMORY_ARENAS if ( EDT_IS_EDITOR(context) ) { eptr->lo_any.next = state->top_state->recycle_list;