diff --git a/ChangeLog b/ChangeLog index 37ff80b3a..2ca0ef22f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,13 @@ * plugins/sf2_player/sf2_player.h: support HQ-mode except for interpolation for sampleRates > 96k + * include/controller_dialog.h: + * include/controller_view.h: + * src/gui/controller_dialog.cpp: + * src/gui/widgets/controller_view.cpp: + * Makefile.am: + fix segfault when trying to show a controller dialog the second time + 2008-04-12 Tobias Doerffel * plugins/lb302/lb302.cpp: diff --git a/Makefile.am b/Makefile.am index 7dac1517c..b39be37fa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -219,6 +219,7 @@ lmms_SOURCES = \ $(srcdir)/src/gui/automation_editor.cpp \ $(srcdir)/src/gui/bb_editor.cpp \ $(srcdir)/src/gui/controller_connection_dialog.cpp \ + $(srcdir)/src/gui/controller_dialog.cpp \ $(srcdir)/src/gui/effect_control_dialog.cpp \ $(srcdir)/src/gui/effect_select_dialog.cpp \ $(srcdir)/src/gui/embed.cpp \ diff --git a/include/controller_dialog.h b/include/controller_dialog.h index 6ac831a34..2cbf94edd 100644 --- a/include/controller_dialog.h +++ b/include/controller_dialog.h @@ -34,28 +34,21 @@ class controllerDialog : public QWidget, public modelView { + Q_OBJECT public: - controllerDialog( controller * _controller, QWidget * _parent ) : - modelView( _controller ), - QWidget( _parent ) - {}; + controllerDialog( controller * _controller, QWidget * _parent ); - virtual ~controllerDialog() {}; + virtual ~controllerDialog(); -public slots: - //void editControls( void ); - //void deletePlugin( void ); - //void displayHelp( void ); - //void closeEffects( void ); - - signals: + void closed(); protected: virtual void contextMenuEvent( QContextMenuEvent * _me ) {}; virtual void paintEvent( QPaintEvent * _pe ) {}; virtual void modelChanged( void ) {}; + virtual void closeEvent( QCloseEvent * _ce ); } ; diff --git a/include/controller_view.h b/include/controller_view.h index 720309b39..68e6e227f 100644 --- a/include/controller_view.h +++ b/include/controller_view.h @@ -49,23 +49,23 @@ class controllerView : public QWidget, public modelView public: controllerView( controller * _controller, QWidget * _parent ); virtual ~controllerView(); -/* - inline effect * getEffect( void ) + + inline controller * getController( void ) { - return( castModel() ); + return( castModel() ); } - inline const effect * getEffect( void ) const + + inline const controller * getController( void ) const { - return( castModel() ); + return( castModel() ); } -*/ public slots: void editControls( void ); //void deletePlugin( void ); //void displayHelp( void ); - //void closeEffects( void ); + void closeControls( void ); signals: diff --git a/src/gui/controller_dialog.cpp b/src/gui/controller_dialog.cpp new file mode 100644 index 000000000..289bb81db --- /dev/null +++ b/src/gui/controller_dialog.cpp @@ -0,0 +1,57 @@ +#ifndef SINGLE_SOURCE_COMPILE + +/* + * controller_dialog.cpp - per-controller-specific view for changing a + * controller's settings + * + * Copyright (c) 2008 Paul Giblock + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#include +#include + +#include "controller_dialog.h" +#include "controller.h" + + +controllerDialog::controllerDialog( controller * _controller, QWidget * _parent ) : + modelView( _controller ), + QWidget( _parent ) +{ +}; + + + +controllerDialog::~controllerDialog() +{ +}; + + + +void controllerDialog::closeEvent( QCloseEvent * _ce ) +{ + _ce->ignore(); + emit( closed() ); +}; + +#include "controller_dialog.moc" + +#endif diff --git a/src/gui/widgets/controller_view.cpp b/src/gui/widgets/controller_view.cpp index 4b7517022..ed408e318 100644 --- a/src/gui/widgets/controller_view.cpp +++ b/src/gui/widgets/controller_view.cpp @@ -62,15 +62,23 @@ controllerView::controllerView( controller * _model, QWidget * _parent ) : toolTip::add( m_bypass, tr( "On/Off" ) ); QPushButton * ctls_btn = new QPushButton( tr( "Controls" ), - this ); - QFont f = ctls_btn->font(); - ctls_btn->setFont( pointSize<7>( f ) ); - ctls_btn->setGeometry( 140, 2, 50, 14 ); - connect( ctls_btn, SIGNAL( clicked() ), - this, SLOT( editControls() ) ); + this ); + + QFont f = ctls_btn->font(); + ctls_btn->setFont( pointSize<7>( f ) ); + ctls_btn->setGeometry( 140, 2, 50, 14 ); + connect( ctls_btn, SIGNAL( clicked() ), + this, SLOT( editControls() ) ); - //m_subWindow = new QMdiSubWindow( getMainWindow()->workspace() ); - //m_subWindow->hide(); + m_controllerDlg = getController()->createDialog( NULL ); + + m_subWindow = engine::getMainWindow()->workspace()->addSubWindow( + m_controllerDlg ); + + connect( m_controllerDlg, SIGNAL( closed() ), + this, SLOT( closeControls() ) ); + + m_subWindow->hide(); /* if( getEffect()->getControls()->getControlCount() > 0 ) @@ -98,7 +106,7 @@ controllerView::controllerView( controller * _model, QWidget * _parent ) : controllerView::~controllerView() { - //delete m_subWindow; + delete m_subWindow; } @@ -106,7 +114,7 @@ controllerView::~controllerView() void controllerView::editControls( void ) { - /*if( m_show ) + if( m_show ) { m_subWindow->show(); m_subWindow->raise(); @@ -116,7 +124,10 @@ void controllerView::editControls( void ) { m_subWindow->hide(); m_show = TRUE; - }*/ + } +} + +/* //engine::getMainWindow()->workspace()->addSubWindow( NULL ); controller * c = castModel(); @@ -130,7 +141,7 @@ void controllerView::editControls( void ) m_subWindow->raise(); } - +*/ /* void effectView::displayHelp( void ) @@ -139,15 +150,15 @@ void effectView::displayHelp( void ) whatsThis() ); } +*/ - -void effectView::closeEffects( void ) +void controllerView::closeControls( void ) { m_subWindow->hide(); m_show = TRUE; } -*/ + void controllerView::contextMenuEvent( QContextMenuEvent * )