From 50424df65311d2226bc4f221b9c2f3fa5d965ed3 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 18 Jan 2014 16:21:13 -0800 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/profile/divetooltipitem.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'qt-ui/profile') diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp index fb8729679..0f7191474 100644 --- a/qt-ui/profile/divetooltipitem.cpp +++ b/qt-ui/profile/divetooltipitem.cpp @@ -1,6 +1,8 @@ #include "divetooltipitem.h" #include "divecartesianaxis.h" #include "profile.h" +#include "dive.h" +#include "membuffer.h" #include #include #include @@ -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 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 items = scene()->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder, transform()); Q_FOREACH(QGraphicsItem *item, items) { -- cgit v1.2.3-70-g09d2