Fix automation crash (#6711)

Fix a crash that occurs if the zooming or snapping model of the Song
Editor is used for automation.

The crash is caused by a failed static_cast to a Model* in
Model::parentModel(). The cast fails because in the constructor of
SongEditor the SongEditor is set as the parent of the zooming and
snapping model:
m_zoomingModel->setParent(this);
m_snappingModel->setParent(this);

This commit is rather a "band aid" fix because it only fixes the crash
by changing the static_cast to a dynamic_cast. However this means that
the name of the automation clip is initially empty.

A better solution would be to not use the Qt parent/child relationships
to implement the model hierarchies.
This commit is contained in:
Michael Gregorius
2023-05-26 10:52:35 +02:00
parent d551938cbd
commit 75627a15f9

View File

@@ -54,7 +54,7 @@ public:
Model* parentModel() const
{
return static_cast<Model *>( parent() );
return dynamic_cast<Model *>( parent() );
}
virtual QString displayName() const