Add locking to trackContainer::m_tracks
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1527 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
||||
2008-09-01 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
|
||||
* include/track_container.h:
|
||||
* src/core/song.cpp:
|
||||
* src/core/track_container.cpp:
|
||||
* src/core/track.cpp:
|
||||
Add locking to trackContainer::m_tracks. This should fix most crashes
|
||||
causes by moving/adding TCOs. This also seems to fix the no-sound bug
|
||||
that I hate so much.
|
||||
|
||||
2008-09-02 Csaba Hruska <csaba.hruska/at/gmail.com>
|
||||
|
||||
* include/song.h:
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#ifndef _TRACK_CONTAINER_H
|
||||
#define _TRACK_CONTAINER_H
|
||||
|
||||
#include <QReadWriteLock>
|
||||
|
||||
#include "track.h"
|
||||
#include "journalling_object.h"
|
||||
|
||||
@@ -64,10 +66,12 @@ public:
|
||||
|
||||
void clearAllTracks( void );
|
||||
|
||||
/*
|
||||
trackList & tracks( void )
|
||||
{
|
||||
return( m_tracks );
|
||||
}
|
||||
*/
|
||||
|
||||
const trackList & tracks( void ) const
|
||||
{
|
||||
@@ -83,6 +87,8 @@ public:
|
||||
signals:
|
||||
void trackAdded( track * _track );
|
||||
|
||||
protected:
|
||||
mutable QReadWriteLock m_tracksMutex;
|
||||
|
||||
private:
|
||||
trackList m_tracks;
|
||||
|
||||
@@ -564,6 +564,7 @@ void song::playPattern( pattern * _patternToPlay, bool _loop )
|
||||
void song::updateLength( void )
|
||||
{
|
||||
m_length = 0;
|
||||
m_tracksMutex.lockForRead();
|
||||
for( trackList::const_iterator it = tracks().begin();
|
||||
it != tracks().end(); ++it )
|
||||
{
|
||||
@@ -573,6 +574,7 @@ void song::updateLength( void )
|
||||
m_length = cur;
|
||||
}
|
||||
}
|
||||
m_tracksMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -638,11 +640,13 @@ void song::stopExport( void )
|
||||
|
||||
void song::insertBar( void )
|
||||
{
|
||||
for( trackList::iterator it = tracks().begin();
|
||||
m_tracksMutex.lockForRead();
|
||||
for( trackList::const_iterator it = tracks().begin();
|
||||
it != tracks().end(); ++it )
|
||||
{
|
||||
( *it )->insertTact( m_playPos[Mode_PlaySong] );
|
||||
}
|
||||
m_tracksMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -650,11 +654,13 @@ void song::insertBar( void )
|
||||
|
||||
void song::removeBar( void )
|
||||
{
|
||||
for( trackList::iterator it = tracks().begin();
|
||||
m_tracksMutex.lockForRead();
|
||||
for( trackList::const_iterator it = tracks().begin();
|
||||
it != tracks().end(); ++it )
|
||||
{
|
||||
( *it )->removeTact( m_playPos[Mode_PlaySong] );
|
||||
}
|
||||
m_tracksMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -666,7 +672,6 @@ void song::addBBTrack( void )
|
||||
track * t = track::create( track::BBTrack, this );
|
||||
engine::getBBTrackContainer()->setCurrentBB(
|
||||
bbTrack::numOfBBTrack( t ) );
|
||||
engine::getMixer()->unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2029,10 +2029,10 @@ tact track::length( void ) const
|
||||
*/
|
||||
void track::toggleSolo( void )
|
||||
{
|
||||
trackContainer::trackList & tl = m_trackContainer->tracks();
|
||||
const trackContainer::trackList & tl = m_trackContainer->tracks();
|
||||
|
||||
bool solo_before = FALSE;
|
||||
for( trackContainer::trackList::iterator it = tl.begin();
|
||||
for( trackContainer::trackList::const_iterator it = tl.begin();
|
||||
it != tl.end(); ++it )
|
||||
{
|
||||
if( *it != this )
|
||||
@@ -2046,7 +2046,7 @@ void track::toggleSolo( void )
|
||||
}
|
||||
|
||||
const bool solo = m_soloModel.value();
|
||||
for( trackContainer::trackList::iterator it = tl.begin();
|
||||
for( trackContainer::trackList::const_iterator it = tl.begin();
|
||||
it != tl.end(); ++it )
|
||||
{
|
||||
if( solo )
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
trackContainer::trackContainer( void ) :
|
||||
model( NULL ),
|
||||
journallingObject(),
|
||||
m_tracks()
|
||||
m_tracks(),
|
||||
m_tracksMutex()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,10 +61,12 @@ void trackContainer::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
//mainWindow::saveWidgetState( this, _this );
|
||||
|
||||
// save settings of each track
|
||||
m_tracksMutex.lockForRead();
|
||||
for( int i = 0; i < m_tracks.size(); ++i )
|
||||
{
|
||||
m_tracks[i]->saveState( _doc, _this );
|
||||
}
|
||||
m_tracksMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +140,9 @@ void trackContainer::addTrack( track * _track )
|
||||
{
|
||||
if( _track->type() != track::HiddenAutomationTrack )
|
||||
{
|
||||
m_tracksMutex.lockForWrite();
|
||||
m_tracks.push_back( _track );
|
||||
m_tracksMutex.unlock();
|
||||
emit trackAdded( _track );
|
||||
}
|
||||
}
|
||||
@@ -150,7 +155,9 @@ void trackContainer::removeTrack( track * _track )
|
||||
int index = m_tracks.indexOf( _track );
|
||||
if( index != -1 )
|
||||
{
|
||||
m_tracksMutex.lockForWrite();
|
||||
m_tracks.remove( index );
|
||||
m_tracksMutex.unlock();
|
||||
|
||||
if( engine::getSong() )
|
||||
{
|
||||
@@ -173,10 +180,12 @@ void trackContainer::updateAfterTrackAdd( void )
|
||||
|
||||
void trackContainer::clearAllTracks( void )
|
||||
{
|
||||
//m_tracksMutex.lockForWrite();
|
||||
while( !m_tracks.isEmpty() )
|
||||
{
|
||||
delete m_tracks.first();
|
||||
}
|
||||
//m_tracksMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -185,6 +194,7 @@ void trackContainer::clearAllTracks( void )
|
||||
int trackContainer::countTracks( track::TrackTypes _tt ) const
|
||||
{
|
||||
int cnt = 0;
|
||||
m_tracksMutex.lockForRead();
|
||||
for( int i = 0; i < m_tracks.size(); ++i )
|
||||
{
|
||||
if( m_tracks[i]->type() == _tt || _tt == track::NumTrackTypes )
|
||||
@@ -192,6 +202,7 @@ int trackContainer::countTracks( track::TrackTypes _tt ) const
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
m_tracksMutex.unlock();
|
||||
return( cnt );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user