Skip to content

Commit

Permalink
fix sendEvent mem leak (#365)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Sep 23, 2020
1 parent 19227d6 commit 1d94688
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 32 deletions.
30 changes: 15 additions & 15 deletions src/Conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,32 +384,32 @@ sdf::Actor ignition::gazebo::convert(const msgs::Actor &_in)
for (int i = 0; i < _in.animations_size(); ++i)
{
const auto &anim = _in.animations(i);
auto newAnim = new sdf::Animation();
newAnim->SetName(anim.name());
newAnim->SetFilename(anim.filename());
newAnim->SetScale(anim.scale());
newAnim->SetInterpolateX(anim.interpolate_x());
out.AddAnimation(*newAnim);
sdf::Animation newAnim;
newAnim.SetName(anim.name());
newAnim.SetFilename(anim.filename());
newAnim.SetScale(anim.scale());
newAnim.SetInterpolateX(anim.interpolate_x());
out.AddAnimation(newAnim);
}
out.SetScriptLoop(_in.script_loop());
out.SetScriptDelayStart(_in.script_delay_start());
out.SetScriptAutoStart(_in.script_auto_start());
for (int i = 0; i < _in.trajectories_size(); ++i)
{
const auto &traj = _in.trajectories(i);
auto newTraj = new sdf::Trajectory();
newTraj->SetId(traj.id());
newTraj->SetType(traj.type());
newTraj->SetTension(traj.tension());
sdf::Trajectory newTraj;
newTraj.SetId(traj.id());
newTraj.SetType(traj.type());
newTraj.SetTension(traj.tension());
for (int j = 0; j < traj.waypoints_size(); ++j)
{
const auto &point = traj.waypoints(j);
auto newPoint = new sdf::Waypoint();
newPoint->SetTime(point.time());
newPoint->SetPose(msgs::Convert(point.pose()));
newTraj->AddWaypoint(*newPoint);
sdf::Waypoint newPoint;
newPoint.SetTime(point.time());
newPoint.SetPose(msgs::Convert(point.pose()));
newTraj.AddWaypoint(newPoint);
}
out.AddTrajectory(*newTraj);
out.AddTrajectory(newTraj);
}
return out;
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/plugins/align_tool/AlignTool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ AlignTool::AlignTool()
: GuiSystem(), dataPtr(std::make_unique<AlignToolPrivate>())
{
// Deselect all entities upon loading plugin
auto deselectEvent = new gui::events::DeselectAllEntities(true);
gui::events::DeselectAllEntities deselectEvent(true);
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
deselectEvent);
&deselectEvent);
}

/////////////////////////////////////////////////
Expand Down
8 changes: 4 additions & 4 deletions src/gui/plugins/entity_tree/EntityTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,19 @@ void EntityTree::Update(const UpdateInfo &, EntityComponentManager &_ecm)
void EntityTree::OnEntitySelectedFromQml(unsigned int _entity)
{
std::vector<Entity> entitySet {_entity};
auto event = new gui::events::EntitiesSelected(entitySet, true);
gui::events::EntitiesSelected event(entitySet, true);
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
event);
&event);
}

/////////////////////////////////////////////////
void EntityTree::DeselectAllEntities()
{
auto event = new gui::events::DeselectAllEntities(true);
gui::events::DeselectAllEntities event(true);
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
event);
&event);
}

/////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/gui/plugins/resource_spawner/ResourceSpawner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ void ResourceSpawner::LoadConfig(const tinyxml2::XMLElement *)
/////////////////////////////////////////////////
void ResourceSpawner::OnResourceSpawn(const QString &_sdfPath)
{
auto event = new gui::events::SpawnPreviewPath(_sdfPath.toStdString());
gui::events::SpawnPreviewPath event(_sdfPath.toStdString());
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
event);
&event);
}

// Register this plugin
Expand Down
11 changes: 6 additions & 5 deletions src/gui/plugins/scene3d/Scene3D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,10 @@ void IgnRenderer::Render()

if (ignition::gui::App())
{
gui::events::Render event;
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
new gui::events::Render());
&event);
}
}

Expand Down Expand Up @@ -1012,10 +1013,10 @@ void IgnRenderer::DeselectAllEntities(bool _sendEvent)

if (_sendEvent)
{
auto deselectEvent = new gui::events::DeselectAllEntities();
gui::events::DeselectAllEntities deselectEvent;
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
deselectEvent);
&deselectEvent);
}
}

Expand Down Expand Up @@ -1596,11 +1597,11 @@ void IgnRenderer::UpdateSelectedEntity(const rendering::NodePtr &_node,
// Notify other widgets of the currently selected entities
if (_sendEvent || deselectedAll)
{
auto selectEvent = new gui::events::EntitiesSelected(
gui::events::EntitiesSelected selectEvent(
this->dataPtr->renderUtil.SelectedEntities());
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
selectEvent);
&selectEvent);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/gui/plugins/shapes/Shapes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ void Shapes::OnMode(const QString &_mode)
return;
}

auto event = new gui::events::SpawnPreviewModel(modelSdfString);
gui::events::SpawnPreviewModel event(modelSdfString);
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
event);
&event);
}

// Register this plugin
Expand Down
4 changes: 2 additions & 2 deletions src/gui/plugins/transform_control/TransformControl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ void TransformControl::OnSnapUpdate(
this->dataPtr->rpySnapVals = math::Vector3d(_roll, _pitch, _yaw);
this->dataPtr->scaleSnapVals = math::Vector3d(_scaleX, _scaleY, _scaleZ);

auto event = new gui::events::SnapIntervals(
gui::events::SnapIntervals event(
this->dataPtr->xyzSnapVals,
this->dataPtr->rpySnapVals,
this->dataPtr->scaleSnapVals);
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(), event);
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(), &event);

this->newSnapValues();
}
Expand Down

0 comments on commit 1d94688

Please sign in to comment.