Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid read/write #626

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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