To allow efficient moving of downloaded dives from the download
thread to the model, implement a general move function that
moves table data. Instantiate that function for the dive and
dive_site tables.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The way we handle singletons in QML, QML insists on allocating the
objects. This leads to a very idiosyncratic way of handling
singletons: The global instance pointer is set in the constructor.
Unify all these by implementing a "SillySingleton" template. All
of the weird singleton-classes can derive from this template and
don't have to bother with reimplementing the instance() function
with all the safety-checks, etc.
This serves firstly as documentation but also improves debugging
as we will now see wanted and unwanted creation and destruction
of these weird singletons.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To make it easier to pass around trips through QML, give each trip
a unique id. The id is generated in alloc_trip() and uses the same
function to generate unique dive ids.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When exporting dive sites, the dive sites to be selected were collected
in the C-core. But that doesn't have access to the selected dive sites
if in dive site mode. Therefore, collect the dive sites in C++ and
pass down to the core. Use a std::vector to avoid memory management
woes.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
is_dive_site_used() had a "selected" parameter. If true it would
return whether the given dive site had a selected dive. Turns
out all callers had this parameter set to true. Therefore, replace
by a simplified function without the "selected" parameter and
give the function an appropriate name.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is working around a Qt Bug https://bugreports.qt.io/browse/QTBUG-69494
which prevents correct rendering of the OnePlus fonts.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The cylindersObject list was only used by grantlee but not by
the mobile code. Since it is quite heavy, split it out and thus
don't generate it for every dive on mobile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of handing a reference-to-dive to QML, prerender all the needed
properties and store them as values in DiveObjectHelper. Exception:
- date(): generated from timestamp
- time(): generated from timestamp
- cylinderList(): does not depend on dive anyway and should be made
static.
This hopefully avoids the random mobile crashes that we are seeing.
Clearly, this code needs to be optimized, but it is a start.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These were temporary functions as long as DiveObjectHelpers were
used to access dives. All users now access the core directly and
therefore don't have to test DiveObjectHelpers for validity.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Don't provide access to the raw dive in DiveObjectHelper. All users
now access the core directly. This is a step in making DiveObjectHelper
value-based.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of keeping track of a list of DiveObjectHelpers, generate
them on-the-fly in DiveListModel. Thus, there is less danger of
model and core getting out of sync. On the flip-side, now the
DiveListModel and the DiveListSortModel might get out of sync.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
DiveObjectHelper is a tiny wrapper around dive * to allow access
to dive data from QML and grantlee. It doesn't have to be a
full-fledged QObject with support for signals, etc. Therefore,
turn it into a Q_GADGET based object. This allows us passing the
object around as object, not as pointer to DiveObjectHelper.
This makes memory-management distinctly easier.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The canonical way of displaying lists in Qt is via models.
Thus, return the tripId directly from the DiveListModel instead
of going indirectly via a DiveObjectHelper. In the future, this
will allow us to make the DiveObjectHelper value-based, as it
is not generated numerous times for every list item.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These properties are not needed anymore, because the full text search
was decoupled from the DiveObjectHelper.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
1) The full text search was looping over the DiveListModel when
it could simply loop over the core model. Do that instead.
2) Don't generate a DiveObjectHelper to do a full text search.
Currently this is harmless as the DiveObjectHelper is only
a disguised "dive *". But from a conceptual point of view,
it represents the full representation of a dive and we don't
want to generate that in a tight loop.
This will help in
1) Making the DiveObjectHelper a non-reference object.
2) Moving fulltext search to the core and thus making it available
to desktop and more performant.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the previous commit, we just continued downloading dives when
download errors happened, but that also makes problems a lot easier to
miss because now they are possibly just transient reports in the
progress bar that get overwritten by the next dive being downloaded.
So this turns a number of these errors from using 'dev_info()' to use a
new 'download_error()' reporting model, which then uses the generic
subsurface error reporting functionality that is sticky and can handle
multiple errors.
It also adds a few 'dev_info()' calls for actual informational messages
about the state of downloading, although the new ones will probably
mainly end up happening before the progress bar is actually shown. But
it might improve on some of the progress messages.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Eric Charbonnier reported a problem downloading the dives from his
OSTC2, and Jef debugged the libdivecomputer log and says:
"Your ostc has 75 dives, but subsurface downloaded only one, and then
stopped the download. That's because that first dive appears to be
corrupt and fails to parse:
ERROR: Buffer overflow detected! [in /win/subsurface/libdivecomputer/src/hw_ostc_parser.c:981 (hw_ostc_parser_samples_foreach)]
Subsurface (incorrectly) considers that a fatal error and stops the
entire download. From a user point of view, it would be much better to
ignore the problematic dive, and continue downloading the remaining"
Subsurface used to just stop downloading if there were parsing errors,
but Jef further says:
"How parser errors are handled is up to the application. Aborting the
download is probably the worst option here. If a dive fails to parse
(because the dive data is corrupt, the parser contains a bug, etc),
that does not necessary mean the remaining dives can't be downloaded"
so let's change the logic to just continue downloading, and hope other
dives work better.
We might want to do better error reporting, right now the errors tend to
just cause "dev_info()" reports, which just set the progress bar text.
So you'll see it in the progress bar as it happens, but it won't get
really ever noted as an error, and it's easy to miss.
But that error reporting is a separate issue, and this just does the
"continue to the next dive" part.
Reported-by: Eric Charbonnier <eric.charbonnier69@gmail.com>
Suggested-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This balances the tags to a equal amount of start and end tags in the
planner notes html.
This also breaks it up with new-lines, so its a bit easier on the eyes,
and gives a validator the chance to point out on which line a error is.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
The output it spits out can be copy-pasted into a html validator like:
https://validator.w3.org/nu/#textarea
Signed-off-by: Anton Lundin <glance@acc.umu.se>
When gas switching only on stops is selected, the notes
showed an extra line at the not realized stop depth. This
eliminates it. It also makes sure there are no 0 second
spurious entries. And gas switching takes more than zero
time (otherwise we would have to print a line of zero
duration for at the gas switch depth).
Reported-by: tormento <turment@gmail.com>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
That was used to store the disclaimer of the last plan. The
functionality was disfunctional for a long time, therefore
remove the variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The setting of the disclaimer variable was removed inadvertently
some time ago, which removed the disclaimer from the printed plan.
Instead, introduce a function that returns the disclaimer with
the current deco mode. Use that function to generate the dive
notes and for printing.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There used to be code to remove the old planner notes when replanning
a dive. It used a global variable and seemed rather brittle. Moreover,
the place that set the global variable was inadvertently removed.
Therefore has been effectively dead code.
Reimplement the functionality, but be more robust by considering
that the deco-type may have changed: Split the translated disclaimer
string in two parts, before and after the "%s" place-holder.
Search for these two parts. Remove the disclaimer and everything
after the disclaimer.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Replaces some enums with names that do not clash with windows #defines.
Specifically:
ERROR -> ERRORED, PASCAL->PASCALS, IGNORE->IGNORED,FLOAT->FLOATVAL
Signed-off-by: Paul Buxton <paulbuxton.mail@googlemail.com>
The create_plot_info_new() function releases old plot data. This
can only work if the plot_info structure was initialized previously.
The ProfileWidget2 did that by a memset, but other parts of the code
did not.
Therefore, introduce a init_plot_info() function and call that when
generating a plot_info struct. Constructors would make this so much
easier - but since this is called from C, we can't use them.
Fixes#2251
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
I got confirmation from Tiago Thedim Dias that my libdivecomputer patch
makes BLE downloading work from the i200c, and already pushed out the
libdivecomputer changes earlier. This updates the subproject in
subsurface to have those changes.
This also adds the bluetooth name patterns for the i300c and a few other
Aqualung dive computers we hadn't added yet. That should make them show
up in the bleutooth device list even without having to check the "Show
all bluetooth devices" check-box.
Tiago claims he didn't need that, and I wonder if we have some overly
permissive match somewhere, but it's the right thing to do regardless.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Instead of generating cylinder data in the form of
CylinderObjectHelper objects for every DiveObjectHelper,
generate it only if needed. DiveObjectHelper is used extensively
in the mobile interface, which doesn't use the cylinder data.
Let's not generate unnecessary CylinderObjectHelpers in this
case!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
CylinderObjectHelper is used for structured formatting of cylinder
values in grantlee types. Instead of keeping a reference to a
cylinder, turn it into a value type containing the formatted strings.
This should be distinctly safer, as we don't risk having stale
references flying around. Moreover, we don't have to use pointers
but can use containers containing plain CylinderObjectHelper. Thus,
no explicit memory management is needed, making the code distinctly
easier to understand.
Sadly, currently grantlee does not support Q_GADGET based Q_PROPERTY.
Therefore a GRANTLEE_*_LOOKUP block has to be added. This can be
removed in due course, as a patch to remedy this issue is in current
grantlee master.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We used a table lookup for CNS equivalent times. Turns
out the log of this table falls pretty much on a straight
line for po2 <= 1.5bar. We now fit this tabel two two
lines, one for <= 1.5 bar and one above. This four
parameter fit has half the sum of errors squared
than the five parameter fit using a fourth order
polynomial.
Fitting the log has the advantage that this never
crosses 0, which would have the bad effect of
resulting in negative CNS values as we divide
by the table value.
We don't adopt a maximum pO2 cut-off for the CNS calculation
but rather live with the large values that the interpolation
formula produces when extrapolating.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
It turns out that the dive site saving was subtly but horribly buggy.
To save the value of the dive site, it did
show_utf8_blanked(b, t->value, " value='", "'/>\n", 1, anonymize);
which looks sane on the face of it, but the problem is that it puts the
final closing xml marker in the 'append this at the end' case.
That means that if the value is empty, the value won't be saved, but
neither will the closing tag. Resulting in an xml line that looks like
this:
<geo cat='3' origin='0' <geo cat='5' origin='0' value='Other name'/>
where the first geo tag was saved without the ending marker.
That then makes all the xml nesting entirely wrong, and the whole file
fails to save.
Now, the code around it does check that 't->value' is not NULL, but it
doesn't check for a value that is empty or all spaces (which also will
make 'show_utf8()' just skip it.
Fix it by saving the end marker separately:
show_utf8_blanked(b, t->value, " value='", "'", 1, anonymize);
put_format(b, "/>\n");
so that the xml is valid even if the goe marker value wasn'r.
Reported-by: Bob Barker <barkerb1965@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
It needs a newer version of libdivecomputer to actually download, but
early very experimental code exists in the Subsurface-NG branch.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
We don't support null-dives in DiveObjectHelper. Defaulting the
dive parameter to NULL seems to send the wrong message.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When removing the max-weightsystem restriction, the semantics of
the DiveObjectHelper::singleWeightSystem() function changed:
it now returned false for "no weightsystem". Change it back,
to 0 or 1 weightsystems, because the mobile frontend uses this
to check whether it can edit dive systems.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
I'm not sure about this one, as we test name at the start of the
function and event->name shouldn't be NULL, but hey, we have the safe
compare function, so let's use it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Header files should compile regardless of order of inclusion.
Since libdivecomputer.h uses FILE unconditional include of
stdio.h is the correct thing to do.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Enough gas was checking the currently displayed dive instead of the
dive to be planned. Not good in a multi-threaded context. Pass the
actual dive instead.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Pass the dive to be planned to track_ascent_gas and don't use
the displayed_dive. For convenience, pass the cylinder-id, since
the function can now access the cylinder of the dive by itself.
This makes the callers less verbose.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The function comment talks about overwriting displayed_dive, when
in reality the function overwrites a passed in dive.
Also fix a debug-call which dumped the displayed_dive, not the
actual dive to stdout.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The fill_default_cylinder() function calculated the MOD based
on the currently displayed dive. This does not seem to make sense:
- When importing dives, why would we care about the altitude and
salinity of the currently displayed dive, possibly from a different
trip.
- The planner is supposed to be thread-safe and should not touch
global variables.
Of course this means that the importing-functions have to fill
out altitude and salinity before creating the default cylinder,
but this is their problem. For a freshly created dive they will
get the default values, which still seems less random than the
values from the displayed dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of passing the global displayed_dive to
calc_crushing_pressure(), use the dive the planner is working on.
A small step in making the planner thread-safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The parser had global state in the form of a linear regression
and the "plot_depth" variable. Collect that in the deco_state struct and
pass it down the call-chain. Move out the code to update the
regression data to not bother other callers of tissue_tolerance_calc().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
A number of architecture-dependent functions were declared in
dive.h. Move them to file.h so that not all file-manipulating
translation units have to include dive.h. This is a small step
in avoiding mass-recompilation on every change to dive.h
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Move the declarations of the "report_error()" and "set_error_cb()"
functions and the "verbose" variable to errorhelper.h.
Thus, error-reporting translation units don't have to import the
big dive.h header file.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Replace a macro calculating a degree-three polynomial by an
inline function.
Moreover, calculate the powers 1, 2 and 3 of the pressure inside
the function. The compiler will be smart enough to optimize this
to the same code. The only important thing is to write "x*x*x*coeff"
instead of "coeff*x*x*x". The compiler can't optimize the latter
because ... wonderful floating point semantics.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The planner can produce negative cylinder pressures when
more gas is used than available. Let's color the pressure
graph in a highly visible color to alert the user of the
fact that current gas planning is insufficient.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The curve fitting for our gas compressibility was only done in the sane
range of 0-500 bar, which is what a scuba cylinder can reasonably be
expected to perhaps have.
But the planner ends up happily using negative cylinder pressures when
you run out of gas, and then the compressibility gives nonsensical
results.
That's clearly a planner bug, but the nonsensical gas compressibility
values made it harder to see what could be wrong.
So we just clamp the inpot range to the range we have verified against
experimental data. If you try to get compressibility for negative
pressures, you get the compressibility for an ideal and imaginary gas.
And if you try to get compressibility for pressures over 500 bar, we'll
just assume that it's 500 bar.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
For better encapsulation, use clear_git_id() in clear_dive_file_data()
instead of setting saved_git_id directly.
Thus, memory management of the saved_git_id value is encapsulated
and can be modified more easily.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The git parser was using a number of global static variables. Remove
them by introducing a parser state, which is passed down to the
call hierarchy.
Advantages:
1) Removes global variables and makes the parser (mostly) reentrant.
2) More flexible - e.g. when parsing samples, the parser can now
access the dive to check if the cylinder number is valid.
3) Less weak typing through "void *".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The function get_divemode() and git_tree_entry_blob() were not used
outside of load-git.c. Make them of static linkage.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
copy_cylinders() copied the cylinders of one dive onto another dive
and then reset to the original gas values. Presumably, when copy and
pasting cylinders from one dive to another, only the types should
be copied, not the gases.
Moreover, the function could either copy all or only the used cylinders.
Firstly, the code was bogus: when restoring the pressures the indices
were mixed up: the old indices were used. Thus, when there where
uncopied cylinders, not all pressure values were restored.
Secondly, it is not clear that all callers actually want to restore
the pressure data. It rather appears the two (out of three) callers
actually just want to copy the cylinders.
Therefore, split the function in
1) copy_cylinders(): copy the cylinders with pressure data
2) copy_cylinder_types(): copy only the cylinder information
Since there is only one caller of copy_cylinder_types(), the "used_only"
argument can be removed. Since all cylinders are copied there is
no point in storing the pressure data. Don't overwrite it in
the first place.
The resulting two functions should be distinctly easier to understand.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The parsers / downloaders parse into a separate table and do
not directly change the divelist. Therefore, they shouldn't
call mark_divelist_changed().
Likewise split_dive_at() doesn't modify the dive list and
therefore shouldn't call this function.
Calling the function has the unwanted side-effect that undoing
the change will not clear the *-symbol in the title of the
main window.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function was used to count the number of weightsystems
used in a dive. Since the weightsysems are now collected
in a dynamic table it became unused. Remove.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Replace the fixed-size weightsystem table by a dynamically
relocated table. Reuse the table-macros used in other parts
of the code.
The table stores weightsystem entries, not pointers to
weightsystems. Thus, ownership of the description string is
taken when adding a weightsystem. An extra function adds
a cloned weightsystem at the end of the table.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This will be used later when joining and editing dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Sadly, this doesn't give any type safety. But at least it documents
the function arguments.
Make the last item in the enum as a number-of-pressure-entries
sentinel. Use that to size the pressure-values array.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of assigning the the lvalue of the SENSOR_PRESSURE
macro, introduce a general function to set pressure values.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The comment to populate_pressure_information() was mentioning
gas pressures that didn't exist. Remove these parts.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Replace the INTERPOLATED_PRESSURE and SENSOR_PRESSURE macros by
inline functions. Generate a common inline function that reads
a pressure value for a dynamic sensor.
Not all SENSOR_PRESSURE macros can be replaced, because the
macro is also used to set the value and C sadly doesn't know
the concept of "return reference from a function".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is absolutely no reason to use a macro here.
The only argument that can be made is consistency with
the other pressure-macros, but those too are questionable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
DILUENT_PRESSURE and INTERPOLATED_DILUENT_PRESSURE do not exist
anymore. No point in trying to output them.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Another tiny step in making dive.h smaller: move function
declarations to deco.h if these functions are defined in deco.c
and don't directly concern dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The string_to_*() functions were declared in dive.h and qthelper.h.
Moreover in one file they were declared with C in the other with
C++ linkage. This only works because qthelper.h includes dive.h
first.
Fix this anomaly by declaring the functions only in qthelper.h,
but moving them from the C++ to the C part.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since this function doesn't act on a dive and is only related
to cylinders, move it to equipment.c and equipment.h.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
While testing the cylinder type saving fix, I noticed that the RBT
saving was broken. Instead of saving RBT whenever it changed, we'd save
it when it was non-zero. Which doesn't match the git save format, and
also doesn't match what we do when loading an xml file (where we default
to the previous RBT value, and a sample RBT will modify it).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Steve Williams reported a crash when saving a previously loaded dive as
xml, and gave a gdb backtrace.
It turns out that if we can't parse the cylinder use type (OC, diluent,
oxygen, unused) we initialize the cylinder use to an invalid type, and
then when we save it, we mess up.
Fix it up by doing proper limit checking before accessing the
"cylinderuse_text[]" array when saving.
Reported-by: Steve <stevewilliams@internode.on.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
In the error messages shown when failing to start ffmpeg, instruct
the user to set the correct executable in the preferences.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, the git parser happily trashes memory if a git repository
contains too many weightsystems or cylinders. This should only happen
in testing, but nevertheless try to handle it gracefully and ignore
excess cylinders / weightsystems.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
All callers of create_plot_info_new() called calculate_max_limits_new()
a line before. Thus, simply call the latter in the former.
This allows us to automatically free the plot data in create_plot_info_new().
The old code overwrote the corresponding field with NULL.
As a side-effect, this removes a bogus static variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There was a global variable last_pi_entry_new, which stored the
recently allocated plot data. This was freed when new plot data
was generated.
A very scary proposition: You can never have two plot datas at
the same time! But exactly that happens when you export for
example subtitles.
The only reason why this didn't lead to very crazy behavior
is that at least on my Linux machine, the calloc() call would
just return the previously freed memory.
Fix this mess by removing the global variable and freeing the
data in the callers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>