Zitat von Phil Longstaff <[email protected]>:

On Wed, 2011-01-12 at 15:40 -0500, Christian Stimming wrote:
Author: cstim
Date: 2011-01-12 15:40:51 -0500 (Wed, 12 Jan 2011)
New Revision: 20081
Trac: http://svn.gnucash.org/trac/changeset/20081

Modified:
   gnucash/trunk/src/engine/gncInvoice.c
   gnucash/trunk/src/engine/gncInvoice.h
Log:
Add function for creating a new copy of an existing GncInvoice.

In some places we have gncXxxCopy() and in some, gncXxxClone().  I don't
really care which, but we should standardize.

Even worse, the semantics of those functions are also vastly different: Some of the *Clone functions are intended to create a duplicate of the source object but in a different QofBook, including setting kvp values with the GUID of the old in the new object and vice versa, i.e. gncCloneInvoice(). Not quite what I would call a "clone". OTOH xaccTransClone() and xaccSplitClone() are "normal" deep copy constructors, but xaccCloneAccount() is not, and xaccCloneAccountSimple() also is not. Gee.

In my case, the use case for the function is a button "Duplicate this invoice", so the invoice and all its content should be duplicated inside the same QofBook and will subsequently be edited so that it can be distinguished from the original invoice. This requires a normal copy constructor (deep copy).

If the normal constructor function is called gncFooCreate, a standard copy constructor should be called gncFooCopy. All other non-standard functions should be named significantly different, like gncFooCopyIntoDifferentBook (maybe not) or gncFooOtherBookCopy (that's a serious proposal).

Christian


_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to