Skip to content

Commit

Permalink
Check if get_path() is not null before checking is_valid()
Browse files Browse the repository at this point in the history
Fixes #2883
  • Loading branch information
tobbi committed Apr 2, 2024
1 parent 3c243e7 commit cf1f85d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/object/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Camera::get_settings()

result.add_path_ref(_("Path"), *this, get_path_ref(), "path-ref");

if (get_walker() && get_path()->is_valid()) {
if (get_walker() && get_path() && get_path()->is_valid()) {
result.add_walk_mode(_("Path Mode"), &get_path()->m_mode, {}, {});
result.add_bool(_("Adapt Speed"), &get_path()->m_adapt_speed, {}, {});
result.add_path_handle(_("Handle"), m_path_handle, "handle");
Expand All @@ -179,7 +179,7 @@ Camera::get_settings()
void
Camera::after_editor_set()
{
if (get_walker() && get_path()->is_valid()) {
if (get_walker() && get_path() && get_path()->is_valid()) {
if (m_defaultmode != Mode::AUTOSCROLL) {
get_path()->m_nodes.clear();
auto path_obj = get_path_gameobject();
Expand Down Expand Up @@ -385,7 +385,7 @@ Camera::update_shake()
if (m_shaketimer.started()) {

// Old method:

// m_translation.x -= sinf(m_shaketimer.get_timegone() * m_shakespeed) * m_shakedepth_x;
// m_translation.y -= sinf(m_shaketimer.get_timegone() * m_shakespeed) * m_shakedepth_y;

Expand Down
4 changes: 2 additions & 2 deletions src/object/coin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Coin::update(float dt_sec)
v = get_walker()->get_pos(m_col.m_bbox.get_size(), m_path_handle);
}

if (get_path()->is_valid()) {
if (get_path() && get_path()->is_valid()) {
m_col.set_movement(v - get_pos());
}
}
Expand Down Expand Up @@ -325,7 +325,7 @@ Coin::get_settings()
m_add_path = get_walker() && get_path() && get_path()->is_valid();
result.add_bool(_("Following path"), &m_add_path);

if (get_walker() && get_path()->is_valid()) {
if (get_walker() && get_path() && get_path()->is_valid()) {
result.add_walk_mode(_("Path Mode"), &get_path()->m_mode, {}, {});
result.add_bool(_("Adapt Speed"), &get_path()->m_adapt_speed, {}, {});
result.add_int(_("Starting Node"), &m_starting_node, "starting-node", 0, 0U);
Expand Down

0 comments on commit cf1f85d

Please sign in to comment.