Skip to content

gdate: Add autoptr support

Marco Trevisan requested to merge 3v1n0/glib:gdate-copy-fixes into master

If we pass a dmy GDate structure to g_date_copy(), it will create a new GDate structure setting only the julian format for it, without setting the DMY for it, so the resulting GDate struct won't have these value set unless any getter is used.

The previous copy function also was causing g_date_get_julian() to be called on the original structure, that caused the original one to be modified, while this is not something expected by a copy function.

So just read the values from the original, and depending on the formats set on that, update its values without touching the original struct.

Then set the autoptr function for it.


Another approach to solve this is keeping the current code, but also calling g_date_update_dmy on the result (always or only if date->dmy is TRUE). In such case we'd keep both formats valid, as probably this function meant to do, but it would also change the original date structure as per the function callings, so I'd prefer not to touch that.

So let me know what's the preferred approach, though

Edited by Marco Trevisan

Merge request reports