gromit-mpx icon indicating copy to clipboard operation
gromit-mpx copied to clipboard

Added options for editing max undo-history depth

Open AngelouDi opened this issue 3 years ago • 3 comments

When using the tool I noticed the default amount of undo steps we could make was really low for my needs. It was probably done for memory issues as increasing the max depth to 1000 filled my 16GB ram. Fyi at 2K resolution 100 steps take 1.4GB in my machine.

I added the ability for users to change that through either the .cfg file or the cli.

There is a repeating section of code now throughout the code:

data->undo_steps = (gint) scanner->value.v_float;
data->undobuffer = calloc(data->undo_steps, sizeof(cairo_surface_t*));

for (int i = 0; i < data->undo_steps; i++)
{
  cairo_surface_destroy(data->undobuffer[i]);
  data->undobuffer[i] = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, data->width, data->height);
}

maybe it should be put inside some function?

AngelouDi avatar Jan 23 '22 02:01 AngelouDi

Thanks for the contribution! How many steps would suit your use case? Maybe we can simply increase GROMIT_MAX_UNDO?

bk138 avatar Jan 23 '22 20:01 bk138

50 would be sufficient for me. But that will cause the program to claim around a GB of memory due to the way undo is handled on different surfaces.

This way let's people with different specs to decide on their own.

AngelouDi avatar Jan 24 '22 12:01 AngelouDi

OK, 50 is a lot. I'll review your patch ASAP!

bk138 avatar Jan 24 '22 12:01 bk138

Tentatively closing, feel free to re-open once comments are addressed :-)

bk138 avatar Sep 06 '23 19:09 bk138