refactored midiPortMenu-creation and -management - fixes crash when removing track which had MIDI-in enabled and enabled MIDI-in for another track afterwards
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1149 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -38,24 +38,26 @@ midiPort::midiPort( const QString & _name, midiClient * _mc,
|
||||
midiEventProcessor * _mep, model * _parent,
|
||||
track * _track, Modes _mode ) :
|
||||
model( _parent ),
|
||||
m_readablePortsMenu( NULL ),
|
||||
m_writablePortsMenu( NULL ),
|
||||
m_midiClient( _mc ),
|
||||
m_midiEventProcessor( _mep ),
|
||||
m_name( _name ),
|
||||
m_mode( _mode ),
|
||||
m_inputChannelModel( 0, 0, MidiChannelCount, this,
|
||||
tr( "Input channel" ) ),
|
||||
m_outputChannelModel( 1, 1, MidiChannelCount, this,
|
||||
tr( "Output channel" ) ),
|
||||
tr( "Input channel" ) ),
|
||||
m_outputChannelModel( 1, 1, MidiChannelCount, this,
|
||||
tr( "Output channel" ) ),
|
||||
m_inputControllerModel( 0, 0, MidiControllerCount, this,
|
||||
tr( "Input controller" ) ),
|
||||
tr( "Input controller" ) ),
|
||||
m_outputControllerModel( 0, 0, MidiControllerCount, this,
|
||||
tr( "Output controller" ) ),
|
||||
tr( "Output controller" ) ),
|
||||
m_readableModel( FALSE, this, tr( "Receive MIDI-events" ) ),
|
||||
m_writableModel( FALSE, this, tr( "Send MIDI-events" ) ),
|
||||
m_defaultVelocityInEnabledModel( FALSE, this,
|
||||
tr( "Default input velocity" ) ),
|
||||
tr( "Default input velocity" ) ),
|
||||
m_defaultVelocityOutEnabledModel( FALSE, this,
|
||||
tr( "Default output velocity" ) )
|
||||
tr( "Default output velocity" ) )
|
||||
{
|
||||
m_midiClient->addPort( this );
|
||||
|
||||
@@ -95,6 +97,11 @@ midiPort::midiPort( const QString & _name, midiClient * _mc,
|
||||
|
||||
midiPort::~midiPort()
|
||||
{
|
||||
// unsubscribe ports
|
||||
m_readableModel.setValue( FALSE );
|
||||
m_writableModel.setValue( FALSE );
|
||||
|
||||
// and finally unregister ourself
|
||||
m_midiClient->removePort( this );
|
||||
}
|
||||
|
||||
|
||||
@@ -35,17 +35,17 @@
|
||||
#include "gui_templates.h"
|
||||
#include "led_checkbox.h"
|
||||
#include "lcd_spinbox.h"
|
||||
#include "midi_client.h"
|
||||
#include "tab_widget.h"
|
||||
#include "tooltip.h"
|
||||
|
||||
|
||||
|
||||
instrumentMidiIOView::instrumentMidiIOView(
|
||||
midiPortMenu * _readable_ports_menu,
|
||||
midiPortMenu * _writable_ports_menu,
|
||||
QWidget * _parent ) :
|
||||
instrumentMidiIOView::instrumentMidiIOView( QWidget * _parent ) :
|
||||
QWidget( _parent ),
|
||||
modelView( NULL )
|
||||
modelView( NULL ),
|
||||
m_rpBtn( NULL ),
|
||||
m_wpBtn( NULL )
|
||||
{
|
||||
m_setupTabWidget = new tabWidget( tr( "MIDI-SETUP FOR THIS CHANNEL" ),
|
||||
this );
|
||||
@@ -92,25 +92,21 @@ instrumentMidiIOView::instrumentMidiIOView(
|
||||
m_defaultVelocityOutCheckBox->move( 28, 164 );
|
||||
|
||||
|
||||
if( _readable_ports_menu != NULL )
|
||||
if( !engine::getMixer()->getMIDIClient()->isRaw() )
|
||||
{
|
||||
QToolButton * rp_btn = new QToolButton( m_setupTabWidget );
|
||||
rp_btn->setText( tr( "MIDI-devices to receive "
|
||||
m_rpBtn = new QToolButton( m_setupTabWidget );
|
||||
m_rpBtn->setText( tr( "MIDI-devices to receive "
|
||||
"MIDI-events from" ) );
|
||||
rp_btn->setIcon( embed::getIconPixmap( "midi_in" ) );
|
||||
rp_btn->setGeometry( 186, 34, 40, 40 );
|
||||
rp_btn->setMenu( _readable_ports_menu );
|
||||
rp_btn->setPopupMode( QToolButton::InstantPopup );
|
||||
}
|
||||
if( _writable_ports_menu != NULL )
|
||||
{
|
||||
QToolButton * wp_btn = new QToolButton( m_setupTabWidget );
|
||||
wp_btn->setText( tr( "MIDI-devices to send MIDI-events "
|
||||
m_rpBtn->setIcon( embed::getIconPixmap( "midi_in" ) );
|
||||
m_rpBtn->setGeometry( 186, 34, 40, 40 );
|
||||
m_rpBtn->setPopupMode( QToolButton::InstantPopup );
|
||||
|
||||
m_wpBtn = new QToolButton( m_setupTabWidget );
|
||||
m_wpBtn->setText( tr( "MIDI-devices to send MIDI-events "
|
||||
"to" ) );
|
||||
wp_btn->setIcon( embed::getIconPixmap( "midi_out" ) );
|
||||
wp_btn->setGeometry( 186, 114, 40, 40 );
|
||||
wp_btn->setMenu( _writable_ports_menu );
|
||||
wp_btn->setPopupMode( QToolButton::InstantPopup );
|
||||
m_wpBtn->setIcon( embed::getIconPixmap( "midi_out" ) );
|
||||
m_wpBtn->setGeometry( 186, 114, 40, 40 );
|
||||
m_wpBtn->setPopupMode( QToolButton::InstantPopup );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +131,14 @@ void instrumentMidiIOView::modelChanged( void )
|
||||
m_sendCheckBox->setModel( &mp->m_writableModel );
|
||||
m_defaultVelocityOutCheckBox->setModel(
|
||||
&mp->m_defaultVelocityOutEnabledModel );
|
||||
if( m_rpBtn )
|
||||
{
|
||||
m_rpBtn->setMenu( mp->m_readablePortsMenu );
|
||||
}
|
||||
if( m_wpBtn )
|
||||
{
|
||||
m_wpBtn->setMenu( mp->m_writablePortsMenu );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -841,9 +841,7 @@ QQueue<instrumentTrackWindow *> instrumentTrackView::s_windows;
|
||||
instrumentTrackView::instrumentTrackView( instrumentTrack * _it,
|
||||
trackContainerView * _tcv ) :
|
||||
trackView( _it, _tcv ),
|
||||
m_window( NULL ),
|
||||
m_readablePortsMenu( NULL ),
|
||||
m_writablePortsMenu( NULL )
|
||||
m_window( NULL )
|
||||
{
|
||||
setAcceptDrops( TRUE );
|
||||
setFixedHeight( 32 );
|
||||
@@ -870,14 +868,14 @@ instrumentTrackView::instrumentTrackView( instrumentTrack * _it,
|
||||
// sequenced MIDI?
|
||||
if( !engine::getMixer()->getMIDIClient()->isRaw() )
|
||||
{
|
||||
m_readablePortsMenu = new midiPortMenu( midiPort::Input );
|
||||
m_writablePortsMenu = new midiPortMenu( midiPort::Output );
|
||||
m_readablePortsMenu->setModel( &_it->m_midiPort );
|
||||
m_writablePortsMenu->setModel( &_it->m_midiPort );
|
||||
_it->m_midiPort.m_readablePortsMenu = new midiPortMenu( midiPort::Input );
|
||||
_it->m_midiPort.m_writablePortsMenu = new midiPortMenu( midiPort::Output );
|
||||
_it->m_midiPort.m_readablePortsMenu->setModel( &_it->m_midiPort );
|
||||
_it->m_midiPort.m_writablePortsMenu->setModel( &_it->m_midiPort );
|
||||
m_midiInputAction = m_tswMidiMenu->addMenu(
|
||||
m_readablePortsMenu );
|
||||
_it->m_midiPort.m_readablePortsMenu );
|
||||
m_midiOutputAction = m_tswMidiMenu->addMenu(
|
||||
m_writablePortsMenu );
|
||||
_it->m_midiPort.m_writablePortsMenu );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -929,6 +927,9 @@ instrumentTrackView::instrumentTrackView( instrumentTrack * _it,
|
||||
instrumentTrackView::~instrumentTrackView()
|
||||
{
|
||||
freeInstrumentTrackWindow();
|
||||
|
||||
delete model()->m_midiPort.m_readablePortsMenu;
|
||||
delete model()->m_midiPort.m_writablePortsMenu;
|
||||
}
|
||||
|
||||
|
||||
@@ -1172,9 +1173,7 @@ instrumentTrackWindow::instrumentTrackWindow( instrumentTrackView * _itv ) :
|
||||
instrument_functions );
|
||||
m_arpView= new arpeggiatorView( &m_track->m_arpeggiator,
|
||||
instrument_functions );
|
||||
m_midiView = new instrumentMidiIOView( m_itv->m_readablePortsMenu,
|
||||
m_itv->m_writablePortsMenu,
|
||||
m_tabWidget );
|
||||
m_midiView = new instrumentMidiIOView( m_tabWidget );
|
||||
m_effectView = new effectRackView( m_track->m_audioPort.getEffects(),
|
||||
m_tabWidget );
|
||||
m_tabWidget->addTab( m_ssView, tr( "ENV/LFO" ), 1 );
|
||||
@@ -1255,15 +1254,6 @@ void instrumentTrackWindow::modelChanged( void )
|
||||
m_midiView->setModel( &m_track->m_midiPort );
|
||||
m_effectView->setModel( m_track->m_audioPort.getEffects() );
|
||||
updateName();
|
||||
|
||||
if( m_itv->m_readablePortsMenu != NULL )
|
||||
{
|
||||
m_itv->m_readablePortsMenu->setModel( &m_track->m_midiPort );
|
||||
}
|
||||
if( m_itv->m_writablePortsMenu != NULL )
|
||||
{
|
||||
m_itv->m_writablePortsMenu->setModel( &m_track->m_midiPort );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user