Trying to understand the profile.c, please be nice to me. :)

Tomaz Canabrava tcanabrava at
Thu Jan 9 08:10:49 UTC 2014

So, On the my tryto make the world better and separate the logic of the
profiles I'v come to this:

The DiveProfilePlot method will be changed to something similar to this:

void DiveDepthTimeModel::setDive(dive* d,const plot_info& pInfo)
    // We need a way to find out if the dive setted is the same old dive,
but pointers change,
    // and there's no UUID, for now, just repopulate everything.
    struct divecomputer *dc = NULL;

    if (d)
        dc = select_dc(&d->dc);
    populate_plot_entries(dive, dc, pInfo);
    sampleCount =;
    dcSamples = pInfo.entry;
    beginInsertRows(QModelIndex(), 0, sampleCount-1);

The last two lines are magic-lines to tell Qt "Hey, data's ready, show it."
But on the create_plot_data method, there's a     return
call that I didn't really understood.

So, Linus, Dirk, Anyone that understand the internals of the profile.c code:

Can I separate the calls like that?

There was a call to

    /* Create the new plot data */
    if (last_pi_entry)
        free((void *)last_pi_entry);
    last_pi_entry = populate_plot_entries(dive, dc, pInfo);

but that seems a bit wrong ( why should I keep a pointer to the

For now, those are the doubts.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the subsurface mailing list