Skip to content

Commit 2952c2c

Browse files
authored
Merge pull request #626 from vizzuhq/valgrind_fix
Fix invalid read/write
2 parents cc50a3a + 4b61927 commit 2952c2c

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/apps/weblib/interface.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,25 +267,25 @@ void Interface::setAnimControlValue(ObjectRegistryHandle chart,
267267
const char *value)
268268
{
269269
auto &&chartPtr = getChart(chart);
270-
auto &ctrl = chartPtr->getAnimControl();
270+
auto &&ctrl = chartPtr->getAnimControl();
271271

272-
if (path == "seek") { ctrl.seek(value); }
272+
if (path == "seek") { ctrl->seek(value); }
273273
else if (path == "cancel") {
274-
ctrl.cancel();
274+
ctrl->cancel();
275275
}
276276
else if (path == "stop") {
277-
ctrl.stop();
277+
ctrl->stop();
278278
}
279279
else if (auto &&set_accessor =
280280
Refl::Access::getAccessor<::Anim::Control::Option>(
281281
path)
282282
.set) {
283-
set_accessor(ctrl.getOptions(), value);
283+
set_accessor(ctrl->getOptions(), value);
284284
}
285285
else {
286286
throw std::logic_error("invalid animation command");
287287
}
288-
ctrl.update();
288+
ctrl->update();
289289
}
290290

291291
const char *Interface::getAnimControlValue(ObjectRegistryHandle chart,
@@ -294,12 +294,12 @@ const char *Interface::getAnimControlValue(ObjectRegistryHandle chart,
294294
thread_local std::string res;
295295

296296
auto &&chartPtr = getChart(chart);
297-
auto &ctrl = chartPtr->getAnimControl();
297+
auto &&ctrl = chartPtr->getAnimControl();
298298

299299
if (auto &&get_accessor =
300300
Refl::Access::getAccessor<::Anim::Control::Option>(path)
301301
.get) {
302-
res = get_accessor(ctrl.getOptions());
302+
res = get_accessor(ctrl->getOptions());
303303
}
304304
else
305305
throw std::logic_error("invalid animation command");
@@ -396,7 +396,7 @@ void Interface::update(ObjectRegistryHandle chart, double timeInMSecs)
396396
std::chrono::duration_cast<std::chrono::nanoseconds>(
397397
std::chrono::duration<double, std::milli>{timeInMSecs});
398398

399-
widget->getChart().getAnimControl().update(
399+
widget->getChart().getAnimControl()->update(
400400
::Anim::TimePoint{nanoSecs});
401401
}
402402

src/chart/main/chart.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class Chart
5454
{
5555
return actPlot;
5656
}
57-
::Anim::Control &getAnimControl()
57+
std::shared_ptr<::Anim::Control> getAnimControl()
5858
{
59-
return animator.getControl();
59+
return animator.getActAnimation();
6060
}
6161
Anim::AnimationPtr getAnimation()
6262
{

test/qtest/window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Window::Window(QWidget *parent) :
3333
void Window::animStep()
3434
{
3535
auto now = std::chrono::steady_clock::now();
36-
chart.getChart().getChart().getAnimControl().update(now);
36+
chart.getChart().getChart().getAnimControl()->update(now);
3737
#ifndef __clang_analyzer__
3838
return QTimer::singleShot(25,
3939
[this]

test/unit/chart/events.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,10 @@ std::multimap<std::string, event_as, std::less<>> get_events(
383383
}
384384

385385
using clock_t = std::chrono::steady_clock;
386-
chart.getAnimControl().update(clock_t::now());
386+
chart.getAnimControl()->update(clock_t::now());
387387
chart.setBoundRect(chart.getLayout().boundary);
388388
chart.draw(MyCanvas{}.getCanvas());
389-
chart.getAnimControl().update(clock_t::now());
389+
chart.getAnimControl()->update(clock_t::now());
390390

391391
skip->*ends == "finished"_is_true;
392392
return events;

0 commit comments

Comments
 (0)