这是indexloc提供的服务,不要输入任何密码
Skip to content

Camera layer add/delete frame crashes Pencil2D #1684

@Jose-Moreno

Description

@Jose-Moreno

Issue Summary

As reported by @davidlamhauge in discord, there's an issue where adding and deleting frames will cause the software to crash 100%

According to David this is related to how the interpolation between two frames is handled. I'll quote his comment from the server.

David Says:

I found a bug in the master branch, If you start the program, choose the Camera layer, add a frame, go to frame 1, press Delete Frame and then press Add Frame, the program crashes.

I've looked into it, with fresh eyes, and found out that the problem is in layercamera.cpp in the function linearInterpolateTransform(Camera* cam).
To make the interpolation we create camera1 and camera2, which both can be nullptr. After they are created we try to set their EasingType, which of course will make a segmentation fault if they are nullptr, and the program crashes.
This code works:

    int frameNumber = cam->pos();
    Camera* camera1 = static_cast<Camera*>(getLastKeyFrameAtPosition(frameNumber - 1));
    if (camera1 != nullptr)
        camera1->setEasingType(camera1->getEasingType());

    int nextFrame = getNextKeyFramePosition(frameNumber);
    Camera* camera2 = static_cast<Camera*>(getLastKeyFrameAtPosition(nextFrame));
    if (camera2 != nullptr)
        camera2->setEasingType(camera2->getEasingType());

Note: The Highlights are mine

Expected Results

Pencil2D should not crash by adding or removing frames. Since this seems to be related to a null pointer exception, the source code should also not lead to them (obviously)

Steps to reproduce

  1. Start the program
  2. Select the Camera layer
  3. Add a frame (playhead will move to frame 2nd)
  4. Go to frame 1
  5. Press the Delete Frame button
  6. Press Add Frame button
  7. The program crashes.

System Information

Tested on the latest Nightly. David tested it on master as well.

  • Pencil2D Version:
    Nightly Build Nov 14 2021

commit: 91b1721
date: 2021-11-14_16:46:59

Operating System: Windows 10 Version 2009
CPU Architecture: x86_64
Qt Version: 5.15.2

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions