From 75627a15f9fc23fe0a652175406c79dafd879e46 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Fri, 26 May 2023 10:52:35 +0200 Subject: [PATCH] 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. --- include/Model.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Model.h b/include/Model.h index 3e304297f..cc3079796 100644 --- a/include/Model.h +++ b/include/Model.h @@ -54,7 +54,7 @@ public: Model* parentModel() const { - return static_cast( parent() ); + return dynamic_cast( parent() ); } virtual QString displayName() const