Use 'struct membuffer' for profile info string generation

The profile info was generated using nasty string concatenation that the
membuffers are much better at anyway.  And membuffers don't need those
arbitrarily sized fixed buffers (500 bytes? Why 500 bytes?).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2014-01-18 16:21:13 -08:00 committed by Dirk Hohndel
parent 77da20196f
commit 50424df653
4 changed files with 57 additions and 79 deletions

View file

@ -1,6 +1,8 @@
#include "divetooltipitem.h"
#include "divecartesianaxis.h"
#include "profile.h"
#include "dive.h"
#include "membuffer.h"
#include <QPropertyAnimation>
#include <QGraphicsSceneMouseEvent>
#include <QPen>
@ -39,9 +41,11 @@ void ToolTipItem::refresh(struct graphics_context *gc, QPointF pos)
{
clear();
int time = (pos.x() * gc->maxtime) / gc->maxx;
char buffer[500];
get_plot_details(gc, time, buffer, 500);
addToolTip(QString(buffer));
struct membuffer mb = { 0 };
get_plot_details(gc, time, &mb);
addToolTip(QString::fromUtf8(mb.buffer, mb.len));
free_buffer(&mb);
QList<QGraphicsItem*> items = scene()->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder, transform());
Q_FOREACH(QGraphicsItem *item, items) {
@ -229,9 +233,11 @@ void ToolTipItem::refresh(const QPointF& pos)
{
clear();
int time = timeAxis->valueAt( pos );
char buffer[500];
get_plot_details_new(&pInfo, time, buffer, 500);
addToolTip(QString(buffer));
struct membuffer mb = { 0 };
get_plot_details_new(&pInfo, time, &mb);
addToolTip(QString::fromUtf8(mb.buffer, mb.len));
free_buffer(&mb);
QList<QGraphicsItem*> items = scene()->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder, transform());
Q_FOREACH(QGraphicsItem *item, items) {