[GNC-dev] Preferred way of writing object oriented code

Maarten Bosmans mkbosmans at gmail.com
Tue Mar 14 15:24:45 EDT 2023


Hi,

In preparation for making some changes to QuickFill.c, I thought it
would be a good idea to get familiar with the GnuCash code by doing
some easy fixes or code improvements.
So I turned on the AddressSanitizer of GCC and ran the test suite. The
first issue I looked at was a delete of a GncGuid that was allocated
with g_malloc(). Trying to untangle that led me through several
parallel implementations of objects and containers: GLib, Qof, and
C++. Let's just say that the codebase has a rich and varied history.

Of course this is not new to any current developers of GnuCash. On C++
page on the wiki it is mentioned that C++ should be preferred over
GLib and Qof. I think that makes sense.
I have a couple of questions for further clarification, as I want to
avoid spending time on preparing patches that you don't want to
accept.
 - I see that GncGuid is implemented using boost::uuid now. But the
implementation still interfaces with glib and qof. Is eliminating that
seen as a worthwhile further improvement? (even if it is just
replacing `gconstpointer` with `const *void`)
 - Could in general any GList instance that is not needed for
interfacing with Gtk potentially be converted to the appropriate C++
container?
 - Does this also mean that any .c file can be converted to .cpp if we
need to make use of a C++ feature? (e.g. std::vector, or templated
functions)

Maarten


More information about the gnucash-devel mailing list