Formatting Dive tags string
Berthold Stoeger
bstoeger at mail.tuwien.ac.at
Wed Apr 4 02:55:22 PDT 2018
Hi Jérémie,
On Mittwoch, 4. April 2018 11:36:18 CEST Jérémie Guichard wrote:
>
> Lubomir mentioned he could look into this 'issue' but did not have much
> free time, since I do have some on my side I can look into this change. I
> do prefer to consult the community before doing it though. Here are the
> different solutions that came to my mind:
>
> 1) Add a output parameter to last printed struct tag_entry* in the list to
> the current taglist_get_tagstring allowing callers to iterate when needed
> (not my favorite)
> 2) It seems strange for a UI specific function to be part of dive.h/.c I
> would rather move this functionality to 'Qt level' say in qthelper.h/.c (or
> other better location if one of you have a better proposal) and implement
> it using QStrings (avoiding the pre-allocated buffer issue). This is
> already what is done for get_gas_string for example. It is my preferred
> proposal since all usage I could find of taglist_get_tagstring are in Qt
> code and this function is purely UI related code...
The backend people prefer not to move too much functionality to C++. So you
will probably have less convincing to do if you construct the string with
"membuffer" and return a "char *" that is freed by the caller:
char *s = taglist_get_tagstring(...);
QString tags(s);
free(s);
If there are more such instances, we could think about a helper function:
QString QStringFromC(char *c)
{
QString res(c);
free(c);
return res;
}
Berthold
More information about the subsurface
mailing list