From 002021aac528a04f2132b1cf8aaa93f16bf1de71 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 18 May 2009 14:27:02 +0200 Subject: [PATCH 1/7] ResourcesDB: save type and basedir property as string rather than number So far the type and basedir properties were saved as numbers (as they are defined in internal enumeration). This is bad style so these properties are now translated into a human-readable string when saving and back to internal enumeration type when loading. --- include/resources_db.h | 43 +++++++++++++++++++++++++++++++++++++++ src/core/resources_db.cpp | 37 ++++++++++++++++++++++++++++----- 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/include/resources_db.h b/include/resources_db.h index cfb94797a..5c25daeea 100644 --- a/include/resources_db.h +++ b/include/resources_db.h @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -81,6 +82,48 @@ private: QDomElement & _de ); void loadTreeItem( ResourcesTreeItem * _i, QDomElement & _de ); + static inline QString typeName( ResourcesItem::Type _t ) + { + return s_typeNames[_t]; + } + + static inline QString baseDirName( ResourcesItem::BaseDirectory _bd ) + { + return s_baseDirNames[_bd]; + } + + static inline ResourcesItem::Type typeFromName( const QString & _n ) + { + for( TypeStringMap::ConstIterator it = s_typeNames.begin(); + it != s_typeNames.end(); ++it ) + { + if( it.value() == _n ) + { + return it.key(); + } + } + return ResourcesItem::TypeUnknown; + } + + static inline ResourcesItem::BaseDirectory baseDirFromName( + const QString & _n ) + { + for( BaseDirStringMap::ConstIterator it = + s_baseDirNames.begin(); + it != s_baseDirNames.end(); ++it ) + { + if( it.value() == _n ) + { + return it.key(); + } + } + return ResourcesItem::BaseRoot; + } + + typedef QMap TypeStringMap; + typedef QMap BaseDirStringMap; + static TypeStringMap s_typeNames; + static BaseDirStringMap s_baseDirNames; ResourcesProvider * m_provider; ItemList m_items; diff --git a/src/core/resources_db.cpp b/src/core/resources_db.cpp index ea83d8b2f..aa4cab6c6 100644 --- a/src/core/resources_db.cpp +++ b/src/core/resources_db.cpp @@ -30,6 +30,10 @@ #include "mmp.h" +QMap ResourcesDB::s_typeNames; +QMap ResourcesDB::s_baseDirNames; + + ResourcesDB::ResourcesDB( ResourcesProvider * _provider ) : m_provider( _provider ) @@ -37,6 +41,30 @@ ResourcesDB::ResourcesDB( ResourcesProvider * _provider ) : connect( m_provider, SIGNAL( itemsChanged() ), this, SIGNAL( itemsChanged() ) ); + if( s_typeNames.isEmpty() ) + { + s_typeNames[ResourcesItem::TypeUnknown] = "Unknown"; + s_typeNames[ResourcesItem::TypeDirectory] = "Directory"; + s_typeNames[ResourcesItem::TypeSample] = "Sample"; + s_typeNames[ResourcesItem::TypeSoundFont] = "SoundFont"; + s_typeNames[ResourcesItem::TypePreset] = "Preset"; + s_typeNames[ResourcesItem::TypeProject] = "Project"; + s_typeNames[ResourcesItem::TypeMidiFile] = "MidiFile"; + s_typeNames[ResourcesItem::TypeForeignProject] = "ForeignProject"; + s_typeNames[ResourcesItem::TypePlugin] = "Plugin"; + s_typeNames[ResourcesItem::TypeImage] = "Image"; + } + + if( s_baseDirNames.isEmpty() ) + { + s_baseDirNames[ResourcesItem::BaseRoot] = "Root"; + s_baseDirNames[ResourcesItem::BaseWorkingDir] = "WorkingDir"; + s_baseDirNames[ResourcesItem::BaseDataDir] = "DataDir"; + s_baseDirNames[ResourcesItem::BaseHome] = "Home"; + s_baseDirNames[ResourcesItem::BaseURL] = "URL"; + } + + } @@ -107,8 +135,8 @@ void ResourcesDB::saveTreeItem( const ResourcesTreeItem * _i, { const ResourcesItem * it = _i->item(); e.setAttribute( "name", it->name() ); - e.setAttribute( "type", it->type() ); - e.setAttribute( "basedir", it->baseDir() ); + e.setAttribute( "type", typeName( it->type() ) ); + e.setAttribute( "basedir", baseDirName( it->baseDir() ) ); e.setAttribute( "path", it->path() ); e.setAttribute( "hash", it->hash() ); e.setAttribute( "size", it->size() ); @@ -135,9 +163,8 @@ void ResourcesDB::loadTreeItem( ResourcesTreeItem * _i, QDomElement & _de ) { ResourcesItem * item = new ResourcesItem( m_provider, e.attribute( "name" ), - static_cast( e.attribute( "type" ).toInt() ), - static_cast( - e.attribute( "basedir" ).toInt() ), + typeFromName( e.attribute( "type" ) ), + baseDirFromName( e.attribute( "basedir" ) ), e.attribute( "path" ), h, e.attribute( "tags" ), From 34e607f5bb98e94e632df9bc19a14b2383172df7 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 18 May 2009 14:33:54 +0200 Subject: [PATCH 2/7] lmms.rc.in: advanced copyright notice Advanced copyright notice in lmms.rc.in which is used as resource file when building win32 executable. --- lmms.rc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lmms.rc.in b/lmms.rc.in index cff42ec8e..c8065017a 100644 --- a/lmms.rc.in +++ b/lmms.rc.in @@ -17,7 +17,7 @@ BEGIN VALUE "CompanyName", "LMMS Developers\0" VALUE "FileDescription", "Linux MultiMedia Studio\0" VALUE "FileVersion", "@VERSION@\0" - VALUE "LegalCopyright", "Copyright (c) 2004-2008 LMMS Developers\0" + VALUE "LegalCopyright", "Copyright (c) 2004-2009 LMMS Developers\0" VALUE "OriginalFilename", "lmms.exe\0" VALUE "ProductName", "LMMS\0" VALUE "ProductVersion", "@VERSION@\0" From 6d77f83ae9ad1a17ccc59989353aac4b1c0801d8 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Tue, 19 May 2009 18:32:24 +0200 Subject: [PATCH 3/7] ControllerConnection: fixed segfault when finalizing invalid controller In ControllerConnection::finalizeConnections() we did not check whether the current controller ID really exists in Song's controller array. Fixes segfault when loading projects with screwed controller settings. --- src/core/controller_connection.cpp | 44 ++++++++++++++++-------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/core/controller_connection.cpp b/src/core/controller_connection.cpp index dc6a2c781..3a0683157 100644 --- a/src/core/controller_connection.cpp +++ b/src/core/controller_connection.cpp @@ -41,17 +41,18 @@ controllerConnectionVector controllerConnection::s_connections; controllerConnection::controllerConnection( controller * _controller ) : - m_controllerId( -1 ), + m_controllerId( -1 ), m_ownsController( FALSE ) { - if( _controller != NULL ) - { - setController( _controller ); - } - else - { - m_controller = controller::create( controller::DummyController, NULL ); - } + if( _controller != NULL ) + { + setController( _controller ); + } + else + { + m_controller = controller::create( controller::DummyController, + NULL ); + } s_connections.append( this ); } @@ -60,7 +61,7 @@ controllerConnection::controllerConnection( controller * _controller ) : controllerConnection::controllerConnection( int _controllerId ) : m_controller( controller::create( controller::DummyController, NULL ) ), - m_controllerId( _controllerId ), + m_controllerId( _controllerId ), m_ownsController( FALSE ) { s_connections.append( this ); @@ -145,13 +146,15 @@ inline void controllerConnection::setTargetName( const QString & _name ) void controllerConnection::finalizeConnections( void ) { for( int i = 0; i < s_connections.size(); ++i ) - { - controllerConnection * c = s_connections[i]; - if ( !c->isFinalized() ) - { - c->setController( engine::getSong()->controllers().at( c->m_controllerId ) ); - } - } + { + controllerConnection * c = s_connections[i]; + if ( !c->isFinalized() && c->m_controllerId < + engine::getSong()->controllers().size() ) + { + c->setController( engine::getSong()-> + controllers().at( c->m_controllerId ) ); + } + } } @@ -159,7 +162,8 @@ void controllerConnection::finalizeConnections( void ) void controllerConnection::saveSettings( QDomDocument & _doc, QDomElement & _this ) { - if( engine::getSong() ) { + if( engine::getSong() ) + { if( m_ownsController ) { m_controller->saveState( _doc, _this ); @@ -167,12 +171,12 @@ void controllerConnection::saveSettings( QDomDocument & _doc, QDomElement & _thi else { int id = engine::getSong()->controllers().indexOf( m_controller ); - if(id >= 0 ) + if( id >= 0 ) { _this.setAttribute( "id", id ); } } - } + } } From 41c939f5aa76c5422e416be8cb1c9914bd2525ac Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 20 May 2009 18:18:30 +0200 Subject: [PATCH 4/7] AutomationRecorder: delete after Song object Delete the AutomationRecorder after Song object. Otherwise LMMS crashes at exit (closes #2793356). --- src/core/engine.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/engine.cpp b/src/core/engine.cpp index 30bdef596..0ac6108bf 100644 --- a/src/core/engine.cpp +++ b/src/core/engine.cpp @@ -160,8 +160,6 @@ void engine::destroy( void ) s_pianoRoll = NULL; delete s_automationEditor; s_automationEditor = NULL; - delete s_automationRecorder; - s_automationRecorder = NULL; delete s_fxMixerView; s_fxMixerView = NULL; @@ -190,6 +188,9 @@ void engine::destroy( void ) delete s_song; s_song = NULL; + delete s_automationRecorder; + s_automationRecorder = NULL; + delete s_resourcesProvider; s_resourcesProvider = NULL; From 031e87b3074e4d201e1b054420d8516add10fc89 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 24 May 2009 01:28:16 +0200 Subject: [PATCH 5/7] LV2: moved conditional include into lv2_manager.h Moved conditional #include from lv2_manager.cpp into lv2_manager.h so we only have to have this compat code in one place. --- include/lv2_manager.h | 6 ++++++ src/core/lv2_manager.cpp | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/lv2_manager.h b/include/lv2_manager.h index f6b879fd0..ae7271f8e 100644 --- a/include/lv2_manager.h +++ b/include/lv2_manager.h @@ -26,12 +26,18 @@ #ifndef _LV2_MANAGER_H #define _LV2_MANAGER_H +#include "lmmsconfig.h" + #ifdef LMMS_HAVE_LV2 #include #include #include +#ifdef LMMS_HAVE_SLV2_SCALEPOINTS_H +#include +#endif + #include #include #include diff --git a/src/core/lv2_manager.cpp b/src/core/lv2_manager.cpp index b80af46ff..5cfc9fcdb 100644 --- a/src/core/lv2_manager.cpp +++ b/src/core/lv2_manager.cpp @@ -36,10 +36,6 @@ #ifdef LMMS_HAVE_LV2 -#ifdef LMMS_HAVE_SLV2_SCALEPOINTS_H -#include "slv2/scalepoints.h" -#endif - lv2Manager * static_lv2_manager=(lv2Manager *)NULL; // There is only one of these... From aaf45467b225aec7ba2e8f382664448068cbeea3 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 25 May 2009 13:27:26 +0200 Subject: [PATCH 6/7] Track UI: coding style fixes Fixed indentation issues and the like. --- src/core/track.cpp | 16 ++++++++-------- src/gui/track_container_view.cpp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/track.cpp b/src/core/track.cpp index ed6503adb..fc65dba65 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -1175,16 +1175,16 @@ void trackContentWidget::updateBackground( void ) // Assume even-pixels-per-tact. Makes sense, should be like this anyways int ppt = static_cast( tcv->pixelsPerTact() ); - int width = ppt * tactsPerBar; + int width = ppt * tactsPerBar; - m_background = QPixmap( width * 2, height() ); - QPainter pmp; - pmp.begin( &m_background ); + m_background = QPixmap( width * 2, height() ); + QPainter pmp; + pmp.begin( &m_background ); - engine::getLmmsStyle()->drawTrackContentBackground( &pmp, - QSize( width, height() ), ppt ); + engine::getLmmsStyle()->drawTrackContentBackground( &pmp, + QSize( width, height() ), ppt ); - pmp.end(); + pmp.end(); } @@ -1425,7 +1425,7 @@ void trackOperationsWidget::mousePressEvent( QMouseEvent * _me ) void trackOperationsWidget::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); - p.fillRect( rect(), palette().brush(QPalette::Background) ); + p.fillRect( rect(), palette().brush( QPalette::Background ) ); if( m_trackView->isMovingTrack() == false ) { diff --git a/src/gui/track_container_view.cpp b/src/gui/track_container_view.cpp index 43bf73fcf..c2e1e2c75 100644 --- a/src/gui/track_container_view.cpp +++ b/src/gui/track_container_view.cpp @@ -223,7 +223,7 @@ void trackContainerView::realignTracks( void ) { ( *it )->show(); ( *it )->update(); - ( *it )->getTrackContentWidget()->updateBackground(); + ( *it )->getTrackContentWidget()->updateBackground(); } } From cdcc158c03a42d23148ef6e5b8ad756740952d34 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 25 May 2009 13:28:42 +0200 Subject: [PATCH 7/7] TrackView: do not set Qt::WA_OpaquePaintEvent attribute Due to optimizations in Qt 4.5 setting Qt::WA_OpaquePaintEvent attribute for TrackView widgets caused a line of distorted pixels at the bottom of the left part so do not set this attribute anymore (closes #2795861). --- src/core/track.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/track.cpp b/src/core/track.cpp index fc65dba65..aa14b7de3 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -2085,7 +2085,6 @@ trackView::trackView( track * _track, trackContainerView * _tcv ) : setAcceptDrops( true ); setAttribute( Qt::WA_DeleteOnClose, true ); - setAttribute( Qt::WA_OpaquePaintEvent, true ); connect( m_track, SIGNAL( destroyedTrack() ), this, SLOT( close() ) );