Fix bug introduced by #5657 (#5982)

* Fix bug introduced by #5657

	There was a bug introduced by #5657 where reloading a project
and playing it could cause a Segmentation Fault crash. After some
debugging, @DomClark tracked the issue to be likely a use-after-free
being caused by m_oldAutomatedValues not being cleared when the project
was loaded again.
	This commit adds a line to clear the m_oldAutomatedValues map on
Song::clearProject(), which is called from Song::loadProject().
	Now, instead of using a Signal/Slot connection to move the
control of the models back to the controllers, every time the song is
processing the automations, the control of the models that were
processed in the last cycle are moved back to the controller. The same
is done under Song::stop(), so the last cycle models control is moved
back to the controller.
	That removes the need to have a pointer to the controlled model
in the controller object.
	Adds mixer model change request to avoid race condition.

Co-authored-by: Dominic Clark <mrdomclark@gmail.com>
This commit is contained in:
IanCaio
2021-04-21 02:26:29 -03:00
committed by GitHub
parent 45d73921e2
commit fbea78945b
5 changed files with 26 additions and 27 deletions

View File

@@ -37,7 +37,6 @@
#include "JournallingObject.h"
#include "ValueBuffer.h"
class AutomatableModel;
class ControllerConnection;
typedef QVector<ControllerConnection *> ControllerConnectionVector;
@@ -48,7 +47,7 @@ class LMMS_EXPORT ControllerConnection : public QObject, public JournallingObjec
Q_OBJECT
public:
ControllerConnection(Controller * _controller, AutomatableModel * contmod);
ControllerConnection(Controller * _controller);
ControllerConnection( int _controllerId );
virtual ~ControllerConnection();
@@ -112,8 +111,6 @@ protected:
static ControllerConnectionVector s_connections;
AutomatableModel * m_controlledModel;
signals:
// The value changed while the mixer isn't running (i.e: MIDI CC)
void valueChanged();