Proposed fix for 1352 Mk2, move the loaded instrument to the parent thread

This commit is contained in:
Dave French
2015-01-05 18:39:44 +00:00
parent e5c4df372e
commit 7588f235ee
2 changed files with 33 additions and 1 deletions

View File

@@ -33,6 +33,7 @@
#include "Track.h"
#include "JournallingObject.h"
#include "InstrumentTrack.h"
class QVBoxLayout;
@@ -182,6 +183,19 @@ signals:
} ;
class InstrumentLoaderThread : public QThread
{
Q_OBJECT
public:
InstrumentLoaderThread( QObject *parent = 0, InstrumentTrack *it = 0,
QString name = "" );
void run();
private:
InstrumentTrack *m_it;
QString m_name;
QThread *m_containerThread;
};
#endif

View File

@@ -325,7 +325,9 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
InstrumentTrack * it = dynamic_cast<InstrumentTrack *>(
Track::create( Track::InstrumentTrack,
m_tc ) );
it->loadInstrument( value );
InstrumentLoaderThread *ilt = new InstrumentLoaderThread(
this, it, value );
ilt->start();
//it->toggledInstrumentTrackButton( true );
_de->accept();
}
@@ -453,6 +455,22 @@ void TrackContainerView::scrollArea::wheelEvent( QWheelEvent * _we )
InstrumentLoaderThread::InstrumentLoaderThread( QObject *parent, InstrumentTrack *it, QString name ) :
QThread( parent ),
m_it( it ),
m_name( name )
{
m_containerThread = thread();
}
void InstrumentLoaderThread::run()
{
Instrument *i = m_it->loadInstrument( m_name );
QObject *parent = i->parent();
i->setParent( 0 );
i->moveToThread( m_containerThread );
i->setParent( parent );
}