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

Tomaz Canabrava tcanabrava at kde.org
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.
    clear();
    struct divecomputer *dc = NULL;

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

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
analyze_plot_info(pi);
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
last_pi_entry?

For now, those are the doubts.

Tomaz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140109/fa33d9ab/attachment.html>


More information about the subsurface mailing list