Fix crash when switching opened projects (#7797)
* Fix crash when switching opened projects #7793 When the DAW is already running with an open project and you attempt to open another project via File > Open, a segfault used to occur. The crash seems to have been caused by model()->value(), which was called in Fader::getModelValueAsDbString(). The model() function looked like it should return a pointer to an AutomatableModel. I suspect that when a model was dropped in favor of loading models for a new project, the AutomatableModel pointer became a null pointer. Add a check to the AutomatableModel pointer so getModelValueAsDbString returns early (before accessing member functions) if the pointer is null. This fixes the crash.
This commit is contained in:
@@ -512,9 +512,16 @@ void Fader::modelValueChanged()
|
||||
|
||||
QString Fader::getModelValueAsDbString() const
|
||||
{
|
||||
const auto value = model()->value();
|
||||
|
||||
QString label(tr("Volume: %1 dB"));
|
||||
// Check that the pointer isn't dangling, which can happen if the
|
||||
// model was dropped in order to load a new project from an existing one.
|
||||
auto* newModel = model();
|
||||
if (!newModel)
|
||||
{
|
||||
// model() was a dangling pointer, so return a sane default value.
|
||||
return label.arg(tr("-inf"));
|
||||
}
|
||||
const auto value = newModel->value();
|
||||
|
||||
if (modelIsLinear())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user