From 27a136fe03954ba00c153f8287527fae5a70d398 Mon Sep 17 00:00:00 2001 From: grindhold Date: Mon, 10 Nov 2014 10:35:07 +0100 Subject: [PATCH 1/7] added capability to collect multiple errormessages and display them at once --- include/MainWindow.h | 6 ++++++ include/Plugin.h | 5 +++++ plugins/VstEffect/VstEffect.cpp | 5 +---- src/core/Plugin.cpp | 13 ++++++++++++ src/core/song.cpp | 3 +++ src/gui/MainWindow.cpp | 36 +++++++++++++++++++++++++++++++++ src/tracks/InstrumentTrack.cpp | 3 +++ 7 files changed, 67 insertions(+), 4 deletions(-) diff --git a/include/MainWindow.h b/include/MainWindow.h index 8a92fa5f1..a6cd74623 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -84,6 +84,11 @@ public: static void saveWidgetState( QWidget * _w, QDomElement & _de ); static void restoreWidgetState( QWidget * _w, const QDomElement & _de ); + void collectErrors( const QList* errors ); + void collectError( const QString error ); + void clearErrors(); + void showErrors( const QString reason ); + public slots: void resetWindowTitle(); @@ -159,6 +164,7 @@ private: QBasicTimer m_updateTimer; QTimer m_autoSaveTimer; + QList* m_errors; friend class engine; diff --git a/include/Plugin.h b/include/Plugin.h index 7c937dc8c..41ccd8706 100644 --- a/include/Plugin.h +++ b/include/Plugin.h @@ -178,6 +178,8 @@ public: // create a view for the model PluginView * createView( QWidget* parent ); + QList * getErrorReport(); + protected: // create a view for the model @@ -185,6 +187,9 @@ protected: private: + QList * m_errorReport; + void logError( QString err_msg ); + const Descriptor* m_descriptor; // pointer to instantiation-function in plugin diff --git a/plugins/VstEffect/VstEffect.cpp b/plugins/VstEffect/VstEffect.cpp index 8817ffb95..d17ae07d2 100644 --- a/plugins/VstEffect/VstEffect.cpp +++ b/plugins/VstEffect/VstEffect.cpp @@ -135,10 +135,7 @@ void VstEffect::openPlugin( const QString & _plugin ) m_pluginMutex.unlock(); closePlugin(); delete tf; - QMessageBox::information( NULL, - VstPlugin::tr( "Failed loading VST plugin" ), - VstPlugin::tr( "The VST plugin %1 could not be loaded for some reason." ).arg( _plugin ), - QMessageBox::Ok ); + logError( VstPlugin::tr( "The VST plugin %1 could not be loaded." ) ); return; } diff --git a/src/core/Plugin.cpp b/src/core/Plugin.cpp index 02d725f03..491526449 100644 --- a/src/core/Plugin.cpp +++ b/src/core/Plugin.cpp @@ -62,6 +62,7 @@ Plugin::Plugin( const Descriptor * _descriptor, Model * parent ) : { m_descriptor = &dummy_plugin_descriptor; } + m_errorReport = NULL; } @@ -124,6 +125,18 @@ Plugin * Plugin::instantiate( const QString & pluginName, Model * parent, return inst; } +QList* Plugin::getErrorReport() +{ + return m_errorReport; +} + +void Plugin::logError( QString err_msg ) +{ + if ( m_errorReport == NULL ) { + m_errorReport = new QList(); + } + m_errorReport->append( err_msg ); +} diff --git a/src/core/song.cpp b/src/core/song.cpp index cfaecc285..a546c836b 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -885,6 +885,7 @@ void song::loadProject( const QString & _file_name ) clearProject(); engine::projectJournal()->setJournalling( false ); + engine::mainWindow()->clearErrors(); m_fileName = _file_name; m_oldFileName = _file_name; @@ -995,6 +996,8 @@ void song::loadProject( const QString & _file_name ) emit projectLoaded(); + engine::mainWindow()->showErrors( tr( "The following errors occured while loading: " ) ); + m_loadingProject = false; m_modified = false; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 3d1b707fc..b37820f20 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -189,6 +189,7 @@ MainWindow::MainWindow() : vbox->addWidget( w ); setCentralWidget( main_widget ); + m_errors = new QList(); m_updateTimer.start( 1000 / 20, this ); // 20 fps @@ -1158,4 +1159,39 @@ void MainWindow::autoSave() +void MainWindow::collectErrors(const QList* errors ) +{ + m_errors->append( *errors ); +} + + +void MainWindow::collectError( const QString error ) +{ + m_errors->append( error ); +} + + + +void MainWindow::clearErrors() +{ + m_errors->clear(); +} + + + +void MainWindow::showErrors( const QString message ) +{ if ( m_errors->length() != 0 ) + { QString* errors = new QString(); + for ( int i = 0 ; i < m_errors->length() ; i++ ) + { + errors->append( m_errors->value( i ) + "\n" ); + } + errors->prepend( "\n\n" ); + errors->prepend( message ); + QMessageBox::warning( NULL, + "LMMS Error report", + *errors, + QMessageBox::Ok ); + } +} diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 37479f9ca..6060ec0cf 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -821,6 +821,9 @@ Instrument * InstrumentTrack::loadInstrument( const QString & _plugin_name ) m_instrument = Instrument::instantiate( _plugin_name, this ); unlock(); + if ( m_instrument->getErrorReport() != NULL ) + engine::mainWindow()->collectErrors( m_instrument->getErrorReport() ); + setName( m_instrument->displayName() ); emit instrumentChanged(); From f746db27f09056b004692d3fafd6eb30c37a09f0 Mon Sep 17 00:00:00 2001 From: grindhold Date: Mon, 10 Nov 2014 10:35:36 +0100 Subject: [PATCH 2/7] unexpected codestyle fixes --- src/gui/MainWindow.cpp | 2 +- src/tracks/InstrumentTrack.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index b37820f20..1d6b40927 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -346,7 +346,7 @@ void MainWindow::finalize() help_menu->addSeparator(); help_menu->addAction( embed::getIconPixmap( "icon" ), tr( "About" ), - this, SLOT( aboutLMMS() ) ); + this, SLOT( aboutLMMS() ) ); // create tool-buttons toolButton * project_new = new toolButton( diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 6060ec0cf..f8a6ed1f8 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -121,7 +121,7 @@ InstrumentTrack::InstrumentTrack( TrackContainer* tc ) : connect( &m_pitchModel, SIGNAL( dataChanged() ), this, SLOT( updatePitch() ) ); connect( &m_pitchRangeModel, SIGNAL( dataChanged() ), this, SLOT( updatePitchRange() ) ); - m_effectChannelModel.setRange( 0, engine::fxMixer()->numChannels()-1, 1); + m_effectChannelModel.setRange( 0, engine::fxMixer()->numChannels()-1, 1); for( int i = 0; i < NumKeys; ++i ) { @@ -336,11 +336,11 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti } } if( event.controllerNumber() == MidiControllerAllSoundOff || - event.controllerNumber() == MidiControllerAllNotesOff || - event.controllerNumber() == MidiControllerOmniOn || - event.controllerNumber() == MidiControllerOmniOff || - event.controllerNumber() == MidiControllerMonoOn || - event.controllerNumber() == MidiControllerPolyOn ) + event.controllerNumber() == MidiControllerAllNotesOff || + event.controllerNumber() == MidiControllerOmniOn || + event.controllerNumber() == MidiControllerOmniOff || + event.controllerNumber() == MidiControllerMonoOn || + event.controllerNumber() == MidiControllerPolyOn ) { silenceAllNotes(); } From ec457ac69bfe91ec8430d1389fc88af0548b4449 Mon Sep 17 00:00:00 2001 From: grindhold Date: Mon, 10 Nov 2014 10:45:38 +0100 Subject: [PATCH 3/7] fixed argument being passed into errormessage of vsteffect --- plugins/VstEffect/VstEffect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/VstEffect/VstEffect.cpp b/plugins/VstEffect/VstEffect.cpp index d17ae07d2..614c44584 100644 --- a/plugins/VstEffect/VstEffect.cpp +++ b/plugins/VstEffect/VstEffect.cpp @@ -135,7 +135,7 @@ void VstEffect::openPlugin( const QString & _plugin ) m_pluginMutex.unlock(); closePlugin(); delete tf; - logError( VstPlugin::tr( "The VST plugin %1 could not be loaded." ) ); + logError( VstPlugin::tr( "The VST plugin %1 could not be loaded." ).arg( _plugin ) ); return; } From cf29c8b97fb812692cce675124bde6bad226239b Mon Sep 17 00:00:00 2001 From: grindhold Date: Mon, 10 Nov 2014 11:55:36 +0100 Subject: [PATCH 4/7] fixed wrong visibility of Plugin::logError --- include/Plugin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Plugin.h b/include/Plugin.h index 41ccd8706..af3783971 100644 --- a/include/Plugin.h +++ b/include/Plugin.h @@ -184,11 +184,11 @@ public: protected: // create a view for the model virtual PluginView* instantiateView( QWidget* ) = 0; + void logError( QString err_msg ); private: QList * m_errorReport; - void logError( QString err_msg ); const Descriptor* m_descriptor; From 69bf4b4a24f5345e328992d489f18954d7707c53 Mon Sep 17 00:00:00 2001 From: grindhold Date: Thu, 20 Nov 2014 01:47:13 +0100 Subject: [PATCH 5/7] implemented proper behaviour for VST plugins --- include/Plugin.h | 4 ---- plugins/vestige/vestige.cpp | 10 +--------- src/core/Plugin.cpp | 12 ++---------- src/gui/MainWindow.cpp | 3 ++- src/tracks/InstrumentTrack.cpp | 5 +---- 5 files changed, 6 insertions(+), 28 deletions(-) diff --git a/include/Plugin.h b/include/Plugin.h index af3783971..a07316c40 100644 --- a/include/Plugin.h +++ b/include/Plugin.h @@ -178,8 +178,6 @@ public: // create a view for the model PluginView * createView( QWidget* parent ); - QList * getErrorReport(); - protected: // create a view for the model @@ -188,8 +186,6 @@ protected: private: - QList * m_errorReport; - const Descriptor* m_descriptor; // pointer to instantiation-function in plugin diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index 7162333df..6a15af552 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -262,15 +262,7 @@ void vestigeInstrument::loadFile( const QString & _file ) m_pluginMutex.unlock(); closePlugin(); delete tf; - QMessageBox::information( 0, - tr( "Failed loading VST-plugin" ), - tr( "The VST-plugin %1 could not " - "be loaded for some reason.\n" - "If it runs with other VST-" - "software under Linux, please " - "contact an LMMS-developer!" - ).arg( m_pluginDLL ), - QMessageBox::Ok ); + logError( VstPlugin::tr( "The VST plugin %1 could not be loaded." ).arg( m_pluginDLL ) ); return; } diff --git a/src/core/Plugin.cpp b/src/core/Plugin.cpp index 491526449..24c988e3c 100644 --- a/src/core/Plugin.cpp +++ b/src/core/Plugin.cpp @@ -34,6 +34,7 @@ #include "config_mgr.h" #include "DummyPlugin.h" #include "AutomatableModel.h" +#include "MainWindow.h" static PixmapLoader __dummy_loader; @@ -62,7 +63,6 @@ Plugin::Plugin( const Descriptor * _descriptor, Model * parent ) : { m_descriptor = &dummy_plugin_descriptor; } - m_errorReport = NULL; } @@ -125,17 +125,9 @@ Plugin * Plugin::instantiate( const QString & pluginName, Model * parent, return inst; } -QList* Plugin::getErrorReport() -{ - return m_errorReport; -} - void Plugin::logError( QString err_msg ) { - if ( m_errorReport == NULL ) { - m_errorReport = new QList(); - } - m_errorReport->append( err_msg ); + engine::mainWindow()->collectError( err_msg ); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 1d6b40927..5fed6da1c 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1181,7 +1181,8 @@ void MainWindow::clearErrors() void MainWindow::showErrors( const QString message ) -{ if ( m_errors->length() != 0 ) +{ + if ( m_errors->length() != 0 ) { QString* errors = new QString(); for ( int i = 0 ; i < m_errors->length() ; i++ ) { diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index f8a6ed1f8..15ff0b143 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -820,11 +820,8 @@ Instrument * InstrumentTrack::loadInstrument( const QString & _plugin_name ) delete m_instrument; m_instrument = Instrument::instantiate( _plugin_name, this ); unlock(); - - if ( m_instrument->getErrorReport() != NULL ) - engine::mainWindow()->collectErrors( m_instrument->getErrorReport() ); - setName( m_instrument->displayName() ); + emit instrumentChanged(); return m_instrument; From f954b0795869d6f9bdeaa4523d2597dc8e654d81 Mon Sep 17 00:00:00 2001 From: grindhold Date: Thu, 20 Nov 2014 22:26:20 +0100 Subject: [PATCH 6/7] rudimentary errormessage for missing sf2-plugins --- plugins/sf2_player/sf2_player.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index 34be71575..774f6c893 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -335,7 +335,8 @@ void sf2Instrument::openFile( const QString & _sf2File, bool updateTrackName ) } else { - // TODO: Couldn't load file! + logError( sf2Instrument::tr( "A soundfont %1 could not be loaded." ).arg( QFileInfo( _sf2File ).baseName() ) ); + // TODO: Why is the filename missing when the file does not exist? } } @@ -357,7 +358,7 @@ void sf2Instrument::openFile( const QString & _sf2File, bool updateTrackName ) if( updateTrackName || instrumentTrack()->displayName() == displayName() ) { - instrumentTrack()->setName( QFileInfo( _sf2File ).baseName() ); + instrumentTrack()->setName( QFileInfo( _sf2File ).baseName() ); } } From 61a380a2d4dd0d6795b7973c81c020c0926b231e Mon Sep 17 00:00:00 2001 From: grindhold Date: Fri, 21 Nov 2014 19:02:27 +0100 Subject: [PATCH 7/7] renamed method logError to collectErrorForUI --- include/Plugin.h | 2 +- plugins/VstEffect/VstEffect.cpp | 2 +- plugins/sf2_player/sf2_player.cpp | 2 +- plugins/vestige/vestige.cpp | 2 +- src/core/Plugin.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/Plugin.h b/include/Plugin.h index a07316c40..d9d8bcc2d 100644 --- a/include/Plugin.h +++ b/include/Plugin.h @@ -182,7 +182,7 @@ public: protected: // create a view for the model virtual PluginView* instantiateView( QWidget* ) = 0; - void logError( QString err_msg ); + void collectErrorForUI( QString err_msg ); private: diff --git a/plugins/VstEffect/VstEffect.cpp b/plugins/VstEffect/VstEffect.cpp index 614c44584..f02b02cb1 100644 --- a/plugins/VstEffect/VstEffect.cpp +++ b/plugins/VstEffect/VstEffect.cpp @@ -135,7 +135,7 @@ void VstEffect::openPlugin( const QString & _plugin ) m_pluginMutex.unlock(); closePlugin(); delete tf; - logError( VstPlugin::tr( "The VST plugin %1 could not be loaded." ).arg( _plugin ) ); + collectErrorForUI( VstPlugin::tr( "The VST plugin %1 could not be loaded." ).arg( _plugin ) ); return; } diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index 774f6c893..76141a4b9 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -335,7 +335,7 @@ void sf2Instrument::openFile( const QString & _sf2File, bool updateTrackName ) } else { - logError( sf2Instrument::tr( "A soundfont %1 could not be loaded." ).arg( QFileInfo( _sf2File ).baseName() ) ); + collectErrorForUI( sf2Instrument::tr( "A soundfont %1 could not be loaded." ).arg( QFileInfo( _sf2File ).baseName() ) ); // TODO: Why is the filename missing when the file does not exist? } } diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index 6a15af552..0faae95c8 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -262,7 +262,7 @@ void vestigeInstrument::loadFile( const QString & _file ) m_pluginMutex.unlock(); closePlugin(); delete tf; - logError( VstPlugin::tr( "The VST plugin %1 could not be loaded." ).arg( m_pluginDLL ) ); + collectErrorForUI( VstPlugin::tr( "The VST plugin %1 could not be loaded." ).arg( m_pluginDLL ) ); return; } diff --git a/src/core/Plugin.cpp b/src/core/Plugin.cpp index 24c988e3c..253df8856 100644 --- a/src/core/Plugin.cpp +++ b/src/core/Plugin.cpp @@ -125,7 +125,7 @@ Plugin * Plugin::instantiate( const QString & pluginName, Model * parent, return inst; } -void Plugin::logError( QString err_msg ) +void Plugin::collectErrorForUI( QString err_msg ) { engine::mainWindow()->collectError( err_msg ); }