From a5010428f84623d9daba4b0eba799577055b7535 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 25 Feb 2008 21:27:58 +0000 Subject: [PATCH] fixed various crashes when removing instrument-track with visible instrument-track-window or loading another instrument/preset git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/branches/lmms-mv@712 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 10 ++++++++++ include/instrument_track.h | 1 + include/instrument_view.h | 4 ++++ src/core/instrument.cpp | 23 +++++++++++++++++------ src/tracks/instrument_track.cpp | 4 ++++ src/widgets/automatable_button.cpp | 3 +-- src/widgets/group_box.cpp | 1 + src/widgets/instrument_function_views.cpp | 3 +++ 8 files changed, 41 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d0a3ad53..6948d7969 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2008-02-25 Tobias Doerffel + * include/instrument_view.h: + * include/instrument_track.h: + * src/widgets/instrument_function_views.cpp: + * src/widgets/group_box.cpp: + * src/widgets/automatable_button.cpp: + * src/tracks/instrument_track.cpp: + fixed various crashes when removing instrument-track with visible + instrument-track-window or loading another instrument/preset + + * src/core/instrument.cpp: * include/oscillator.h: cleanups diff --git a/include/instrument_track.h b/include/instrument_track.h index 544e04958..8325c065c 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -318,6 +318,7 @@ private: QAction * m_midiOutputAction; friend class instrumentTrackButton; + friend class instrumentView; } ; diff --git a/include/instrument_view.h b/include/instrument_view.h index b771a1ec5..987c643d1 100644 --- a/include/instrument_view.h +++ b/include/instrument_view.h @@ -29,6 +29,8 @@ #include "instrument.h" #include "plugin_view.h" +class instrumentTrackWindow; + class instrumentView : public pluginView { @@ -48,6 +50,8 @@ public: virtual void setModel( ::model * _model, bool = FALSE ); + instrumentTrackWindow * getInstrumentTrackWindow( void ); + } ; diff --git a/src/core/instrument.cpp b/src/core/instrument.cpp index e2037e3a6..350f8481f 100644 --- a/src/core/instrument.cpp +++ b/src/core/instrument.cpp @@ -139,6 +139,7 @@ instrumentView::instrumentView( instrument * _instrument, QWidget * _parent ) : { setModel( _instrument ); setFixedSize( 250, 250 ); + setAttribute( Qt::WA_DeleteOnClose, TRUE ); } @@ -146,24 +147,34 @@ instrumentView::instrumentView( instrument * _instrument, QWidget * _parent ) : instrumentView::~instrumentView() { + if( getInstrumentTrackWindow() ) + { + getInstrumentTrackWindow()->m_instrumentView = NULL; + } } + void instrumentView::setModel( ::model * _model, bool ) { if( dynamic_cast( _model ) != NULL ) { modelView::setModel( _model ); - if( dynamic_cast( parentWidget() ) != - NULL ) - { - dynamic_cast( parentWidget() )-> - setWindowIcon( *( model()-> + getInstrumentTrackWindow()->setWindowIcon( *( model()-> getDescriptor()->logo ) ); - } + connect( model(), SIGNAL( destroyed( QObject * ) ), + this, SLOT( close() ) ); } } + + +instrumentTrackWindow * instrumentView::getInstrumentTrackWindow( void ) +{ + return( dynamic_cast( + parentWidget()->parentWidget() ) ); +} + #endif diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index e4f29c11d..483b7d019 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -145,6 +145,7 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) : instrumentTrack::~instrumentTrack() { + delete m_instrument; engine::getMixer()->removePlayHandles( this ); engine::getMixer()->getMIDIClient()->removePort( m_midiPort ); } @@ -778,6 +779,7 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this ) m_instrument->restoreState( node.toElement() ); } + emit instrumentChanged(); } } node = node.nextSibling(); @@ -1146,6 +1148,7 @@ instrumentTrackWindow::instrumentTrackWindow( instrumentTrackView * _itv ) : instrumentTrackWindow::~instrumentTrackWindow() { + delete m_instrumentView; if( engine::getMainWindow()->workspace() ) { parentWidget()->hide(); @@ -1167,6 +1170,7 @@ void instrumentTrackWindow::modelChanged( void ) this, SLOT( updateInstrumentView() ), Qt::QueuedConnection ); m_volumeKnob->setModel( &m_track->m_volumeModel ); + m_volumeKnob->setModel( &m_track->m_volumeModel ); m_surroundArea->setModel( &m_track->m_surroundAreaModel ); m_pianoView->setModel( &m_track->m_piano ); diff --git a/src/widgets/automatable_button.cpp b/src/widgets/automatable_button.cpp index 2a127e1a6..d27179c09 100644 --- a/src/widgets/automatable_button.cpp +++ b/src/widgets/automatable_button.cpp @@ -207,8 +207,6 @@ void automatableButtonGroup::removeButton( automatableButton * _btn ) { m_buttons.erase( qFind( m_buttons.begin(), m_buttons.end(), _btn ) ); _btn->m_group = NULL; - - model()->setRange( 0, m_buttons.size() - 1 ); } @@ -243,6 +241,7 @@ void automatableButtonGroup::modelChanged( void ) void automatableButtonGroup::updateButtons( void ) { + model()->setRange( 0, m_buttons.size() - 1 ); int i = 0; foreach( automatableButton * btn, m_buttons ) { diff --git a/src/widgets/group_box.cpp b/src/widgets/group_box.cpp index 0c84236b9..aa3cf4443 100644 --- a/src/widgets/group_box.cpp +++ b/src/widgets/group_box.cpp @@ -77,6 +77,7 @@ groupBox::groupBox( const QString & _caption, QWidget * _parent ) : groupBox::~groupBox() { + delete m_led; } diff --git a/src/widgets/instrument_function_views.cpp b/src/widgets/instrument_function_views.cpp index 0a025746a..d4e758d3c 100644 --- a/src/widgets/instrument_function_views.cpp +++ b/src/widgets/instrument_function_views.cpp @@ -88,6 +88,7 @@ chordCreatorView::chordCreatorView( chordCreator * _cc, QWidget * _parent ) : chordCreatorView::~chordCreatorView() { + delete m_chordsGroupBox; } @@ -231,6 +232,8 @@ arpeggiatorView::arpeggiatorView( arpeggiator * _arp, QWidget * _parent ) : arpeggiatorView::~arpeggiatorView() { + delete m_arpDirectionBtnGrp; + delete m_arpGroupBox; }