Skip to content

[Mousepad 0.5] Save geometry on close to prevent warnings or corrupted data in GSettings

Mousepad saves the window geometry after each "real change", that is by handling the configure event with a one second delay. This can result in warnings or corrupted data in GSettings if a backup attempt is in progress at the time of closure.

With Mousepad master, I obtain this kind of warnings when closing:

(mousepad:43109): Mousepad-CRITICAL **: 18:32:32.428: mousepad_settings_store_lookup: assertion 'MOUSEPAD_IS_SETTINGS_STORE (self)' failed
(mousepad:43109): Mousepad-WARNING **: 18:32:32.428: (mousepad-settings.c:249):mousepad_setting_get_boolean: runtime check failed: (result)

With mousepad 0.4.2, I rather obtain corrupted data when reopening:

(mousepad:45385): GLib-CRITICAL **: 19:11:18.568: the GVariant format string 'b' has a type of 'b' but the given value has a type of 's'
(mousepad:45385): GLib-CRITICAL **: 19:11:18.568: g_variant_get_va: assertion 'valid_format_string (format_string, !endptr, value)' failed

This can be reproduced by closing about one second after the last geometry change, maybe more easily by toggling the fullscreen action.

In both cases, since the backup is delayed by the use of a timeout, we have no strict control on when it will occur, so playing even more with idles and priorities does not seem to be a solution here.

That's why this patch adds a non-delayed save on close, with cleanup of the eventual pending source. This fixes this issue, and ensures that the geometry is always saved on close, which is not currently the case (either with Mousepad 0.4.2 or master).

Edited by Gaël Bonithon

Merge request reports