diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-18 16:21:13 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-02-10 07:03:27 -0800 |
commit | 50424df65311d2226bc4f221b9c2f3fa5d965ed3 (patch) | |
tree | e595b31357b3c8a768e8ecead977eaec57a89c23 /qt-ui | |
parent | 77da20196f3efe8eaf4a7bd898f0c6206d146c61 (diff) | |
download | subsurface-50424df65311d2226bc4f221b9c2f3fa5d965ed3.tar.gz |
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>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/profile/divetooltipitem.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
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 <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) { |