Skip to content

Commit

Permalink
Merge pull request #626 from vizzuhq/valgrind_fix
Browse files Browse the repository at this point in the history
Fix invalid read/write
  • Loading branch information
schaumb authored Nov 29, 2024
2 parents cc50a3a + 4b61927 commit 2952c2c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions src/apps/weblib/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,25 +267,25 @@ void Interface::setAnimControlValue(ObjectRegistryHandle chart,
const char *value)
{
auto &&chartPtr = getChart(chart);
auto &ctrl = chartPtr->getAnimControl();
auto &&ctrl = chartPtr->getAnimControl();

if (path == "seek") { ctrl.seek(value); }
if (path == "seek") { ctrl->seek(value); }
else if (path == "cancel") {
ctrl.cancel();
ctrl->cancel();
}
else if (path == "stop") {
ctrl.stop();
ctrl->stop();
}
else if (auto &&set_accessor =
Refl::Access::getAccessor<::Anim::Control::Option>(
path)
.set) {
set_accessor(ctrl.getOptions(), value);
set_accessor(ctrl->getOptions(), value);
}
else {
throw std::logic_error("invalid animation command");
}
ctrl.update();
ctrl->update();
}

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

auto &&chartPtr = getChart(chart);
auto &ctrl = chartPtr->getAnimControl();
auto &&ctrl = chartPtr->getAnimControl();

if (auto &&get_accessor =
Refl::Access::getAccessor<::Anim::Control::Option>(path)
.get) {
res = get_accessor(ctrl.getOptions());
res = get_accessor(ctrl->getOptions());
}
else
throw std::logic_error("invalid animation command");
Expand Down Expand Up @@ -396,7 +396,7 @@ void Interface::update(ObjectRegistryHandle chart, double timeInMSecs)
std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double, std::milli>{timeInMSecs});

widget->getChart().getAnimControl().update(
widget->getChart().getAnimControl()->update(
::Anim::TimePoint{nanoSecs});
}

Expand Down
4 changes: 2 additions & 2 deletions src/chart/main/chart.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class Chart
{
return actPlot;
}
::Anim::Control &getAnimControl()
std::shared_ptr<::Anim::Control> getAnimControl()
{
return animator.getControl();
return animator.getActAnimation();
}
Anim::AnimationPtr getAnimation()
{
Expand Down
2 changes: 1 addition & 1 deletion test/qtest/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Window::Window(QWidget *parent) :
void Window::animStep()
{
auto now = std::chrono::steady_clock::now();
chart.getChart().getChart().getAnimControl().update(now);
chart.getChart().getChart().getAnimControl()->update(now);
#ifndef __clang_analyzer__
return QTimer::singleShot(25,
[this]
Expand Down
4 changes: 2 additions & 2 deletions test/unit/chart/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,10 @@ std::multimap<std::string, event_as, std::less<>> get_events(
}

using clock_t = std::chrono::steady_clock;
chart.getAnimControl().update(clock_t::now());
chart.getAnimControl()->update(clock_t::now());
chart.setBoundRect(chart.getLayout().boundary);
chart.draw(MyCanvas{}.getCanvas());
chart.getAnimControl().update(clock_t::now());
chart.getAnimControl()->update(clock_t::now());

skip->*ends == "finished"_is_true;
return events;
Expand Down

0 comments on commit 2952c2c

Please sign in to comment.