On Tue, Dec 7, 2010 at 23:04, Tomasz Bątor <tom...@gmail.com> wrote: > On Tue, Dec 7, 2010 at 10:18 PM, Teo Mrnjavac <t...@kde.org> wrote: >> >> > Doesn't compile on Windows using VS2008: >> > >> > C:\dev\src\amarok-2.3.90\src\core\transcoding\TranscodingController.cpp(30) >> > : error C2491: 'The::transcodingController' : definition of dllimport >> > function not allowed >> Since I don't run Windows, I would greatly appreciate if you could >> please check if the attached patch fixes the build issue. > > Not so good, lots of warnings and errors now: http://pastebin.com/7ESDrMqD > regards, > Tomasz
Interesting. Thank you for testing. I have prepared another change which might fix your issue, would you please apply the attached patch on top of the already patched instance you have and see if it builds? Cheers -- Teo
From 885ac8ac7b8a3e8ebb4b991b9e7bbfdfa14f8e3b Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac <t...@kde.org> Date: Wed, 8 Dec 2010 00:36:34 +0100 Subject: [PATCH 2/2] Removed singleton pattern from Transcoding::Controller in favor of using Amarok::Components as Maximilian suggested. Also fixed an enum-unchecked-by-switch warning. --- src/App.cpp | 2 +- src/browsers/CollectionTreeView.cpp | 2 +- src/browsers/filebrowser/FileView.cpp | 2 +- src/core-impl/collections/db/sql/SqlCollection.cpp | 2 +- .../collections/db/sql/SqlCollectionLocation.cpp | 2 +- src/core/support/Components.cpp | 5 +++- src/core/support/Components.h | 8 +++++ src/core/transcoding/TranscodingController.cpp | 28 -------------------- src/core/transcoding/TranscodingController.h | 20 +------------ src/transcoding/TranscodingAssistantDialog.cpp | 8 +++-- src/transcoding/TranscodingJob.cpp | 4 +- .../TranscodingOptionsStackedWidget.cpp | 2 +- 12 files changed, 27 insertions(+), 58 deletions(-) diff --git a/src/App.cpp b/src/App.cpp index d903811..6232eea 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -668,7 +668,7 @@ App::continueInit() //Instantiate the Transcoding::Controller, this fires up an asynchronous KProcess with //FFmpeg which should not take more than ~200msec. - The::transcodingController(); + Amarok::Components::setTranscodingController( new Transcoding::Controller( this ) ); if( splash ) // close splash correctly { diff --git a/src/browsers/CollectionTreeView.cpp b/src/browsers/CollectionTreeView.cpp index c5b826c..74f46da 100644 --- a/src/browsers/CollectionTreeView.cpp +++ b/src/browsers/CollectionTreeView.cpp @@ -1150,7 +1150,7 @@ void CollectionTreeView::slotCopyTracks() { Transcoding::Configuration configuration = Transcoding::Configuration(); - if( !The::transcodingController()->availableFormats().isEmpty() ) + if( !Amarok::Components::transcodingController()->availableFormats().isEmpty() ) { Transcoding::AssistantDialog dialog( this ); if( dialog.exec() ) diff --git a/src/browsers/filebrowser/FileView.cpp b/src/browsers/filebrowser/FileView.cpp index 6d9d1ef..df44f98 100644 --- a/src/browsers/filebrowser/FileView.cpp +++ b/src/browsers/filebrowser/FileView.cpp @@ -250,7 +250,7 @@ FileView::slotPrepareTranscodeTracks() debug()<<" SRC URL IS " << list.urlList().first(); debug()<<" SRC URL IS " << list.urlList().first(); - if( !The::transcodingController()->availableFormats().isEmpty() ) + if( !Amarok::Components::transcodingController()->availableFormats().isEmpty() ) { Transcoding::AssistantDialog *d = new Transcoding::AssistantDialog( this ); debug() << "About to show Transcoding::AssistantDialog"; diff --git a/src/core-impl/collections/db/sql/SqlCollection.cpp b/src/core-impl/collections/db/sql/SqlCollection.cpp index a851dcc..fda199c 100644 --- a/src/core-impl/collections/db/sql/SqlCollection.cpp +++ b/src/core-impl/collections/db/sql/SqlCollection.cpp @@ -69,7 +69,7 @@ public: virtual void setTranscodingConfiguration( const Transcoding::Configuration &configuration = Transcoding::Configuration() ) { m_targetFileExtension = - The::transcodingController()->format( configuration.encoder() )->fileExtension(); } + Amarok::Components::transcodingController()->format( configuration.encoder() )->fileExtension(); } virtual void show() { diff --git a/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp b/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp index 4c6e566..f729c31 100644 --- a/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp +++ b/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp @@ -569,7 +569,7 @@ bool SqlCollectionLocation::startNextJob( const Transcoding::Configuration confi { QString destPath = dest.path(); destPath.truncate( dest.path().lastIndexOf( '.' ) + 1 ); - destPath.append( The::transcodingController()-> + destPath.append( Amarok::Components::transcodingController()-> format( configuration.encoder() )->fileExtension() ); dest.setPath( destPath ); job = new Transcoding::Job( src, dest, configuration, this ); diff --git a/src/core/support/Components.cpp b/src/core/support/Components.cpp index fd6c9a2..add22f8 100644 --- a/src/core/support/Components.cpp +++ b/src/core/support/Components.cpp @@ -27,7 +27,7 @@ public: , sqlStorage( 0 ) , applicationController( 0 ) , collectionLocationDelegate( 0 ) - + , transcodingController( 0 ) {} CollectionManager *collectionManager; @@ -36,6 +36,7 @@ public: Amarok::Logger *logger; Amarok::ApplicationController *applicationController; Collections::CollectionLocationDelegate *collectionLocationDelegate; + Transcoding::Controller *transcodingController; }; //using a static variable is ok in this case as ComponentsPrivate does nothing on destruction @@ -71,3 +72,5 @@ COMPONENT_ACCESSORS( Amarok::ApplicationController*, applicationController, setA COMPONENT_ACCESSORS( Collections::CollectionLocationDelegate*, collectionLocationDelegate, setCollectionLocationDelegate ) +COMPONENT_ACCESSORS( Transcoding::Controller*, transcodingController, setTranscodingController ) + diff --git a/src/core/support/Components.h b/src/core/support/Components.h index a75bb9e..93eaf45 100644 --- a/src/core/support/Components.h +++ b/src/core/support/Components.h @@ -30,6 +30,11 @@ namespace Collections class CollectionLocationDelegate; } +namespace Transcoding +{ + class Controller; +} + class CollectionManager; class EngineController; class SqlStorage; @@ -55,6 +60,9 @@ namespace Amarok AMAROK_CORE_EXPORT Collections::CollectionLocationDelegate* collectionLocationDelegate(); AMAROK_CORE_EXPORT Collections::CollectionLocationDelegate* setCollectionLocationDelegate( Collections::CollectionLocationDelegate *delegate ); + + AMAROK_CORE_EXPORT Transcoding::Controller* transcodingController(); + AMAROK_CORE_EXPORT Transcoding::Controller* setTranscodingController( Transcoding::Controller *controller ); } } diff --git a/src/core/transcoding/TranscodingController.cpp b/src/core/transcoding/TranscodingController.cpp index 9f25c7f..b0b92a4 100644 --- a/src/core/transcoding/TranscodingController.cpp +++ b/src/core/transcoding/TranscodingController.cpp @@ -24,37 +24,9 @@ #include "formats/TranscodingVorbisFormat.h" #include "formats/TranscodingWmaFormat.h" -namespace The -{ -Transcoding::Controller *transcodingController() -{ - return Transcoding::Controller::instance(); -} -} - namespace Transcoding { -Controller *Controller::s_instance = 0; - -Controller * -Controller::instance() -{ - if( s_instance == 0 ) - s_instance = new Controller(); - return s_instance; -} - -void -Controller::destroy() -{ - if( s_instance ) - { - delete s_instance; - s_instance = 0; - } -} - Controller::Controller( QObject *parent ) : QObject( parent ) , m_formats( QList< Format * >() diff --git a/src/core/transcoding/TranscodingController.h b/src/core/transcoding/TranscodingController.h index 54848c0..9c3e2858 100644 --- a/src/core/transcoding/TranscodingController.h +++ b/src/core/transcoding/TranscodingController.h @@ -20,6 +20,7 @@ #include "shared/amarok_export.h" #include "TranscodingDefines.h" #include "TranscodingFormat.h" +#include "core/support/Components.h" #include <KProcess> @@ -32,23 +33,13 @@ namespace Transcoding /** * Singleton class that handles and wraps around the Transcoding architecture. - * To talk to the transcoding controller, use The::transcodingController(). * @author Téo Mrnjavac <t...@kde.org> */ class AMAROK_CORE_EXPORT Controller : public QObject { Q_OBJECT public: - /** - * Accessor for the singleton pattern. - * @return a pointer to the only instance of Transcoding::Controller. - */ - static Controller *instance(); - - /** - * Singleton destructor. - */ - static void destroy(); + Controller( QObject *parent = 0 ); const QList< Format * > & availableFormats() const { return m_availableFormats; } const QList< Format * > & allFormats() const { return m_formats; } @@ -58,8 +49,6 @@ private slots: void onAvailabilityVerified( int exitCode, QProcess::ExitStatus exitStatus ); private: - Controller( QObject *parent = 0 ); - static Controller *s_instance; const QList< Format * > m_formats; QList< Format * > m_availableFormats; /* Unfortunately here I can't use QList< Format > instead of QList< Format * > because apparently @@ -70,9 +59,4 @@ private: } //namespace Transcoding -namespace The -{ - AMAROK_CORE_EXPORT Transcoding::Controller *transcodingController(); -} - #endif //TRANSCODING_CONTROLLER_H diff --git a/src/transcoding/TranscodingAssistantDialog.cpp b/src/transcoding/TranscodingAssistantDialog.cpp index d28645b..b64e74b 100644 --- a/src/transcoding/TranscodingAssistantDialog.cpp +++ b/src/transcoding/TranscodingAssistantDialog.cpp @@ -92,7 +92,7 @@ AssistantDialog::AssistantDialog( QWidget *parent ) void AssistantDialog::populateFormatList() { - foreach( Format *format, The::transcodingController()->availableFormats() ) + foreach( Format *format, Amarok::Components::transcodingController()->availableFormats() ) { QListWidgetItem *item = new QListWidgetItem( format->icon(), format->prettyName() ); item->setToolTip( format->description() ); @@ -112,7 +112,7 @@ AssistantDialog::onTranscodeWithDefaultsClicked() //SLOT { //REMOVE THIS BUTTON! m_configuration = Configuration( VORBIS ); - foreach( Property property, The::transcodingController()->format( VORBIS )->propertyList() ) + foreach( Property property, Amarok::Components::transcodingController()->format( VORBIS )->propertyList() ) { switch( property.type() ) { @@ -122,6 +122,8 @@ AssistantDialog::onTranscodeWithDefaultsClicked() //SLOT m_configuration.addProperty( property.name(), property.defaultText() ); case Property::LIST: m_configuration.addProperty( property.name(), property.defaultIndex() ); + case Property::TRADEOFF: + m_configuration.addProperty( property.name(), property.defaultValue() ); } } KDialog::done( KDialog::Accepted ); @@ -162,7 +164,7 @@ AssistantDialog::onFormatSelect( QListWidgetItem *item ) //SLOT ui.formatIconLabel->show(); ui.formatNameLabel->show(); Encoder encoder = static_cast< Encoder >( item->data( Qt::UserRole ).toInt() ); - const Format *format = The::transcodingController()->format( encoder ); + const Format *format = Amarok::Components::transcodingController()->format( encoder ); ui.formatIconLabel->setPixmap( format->icon().pixmap( 32, 32 ) ); ui.formatNameLabel->setText( format->prettyName() ); ui.formatIconLabel->setToolTip( format->description() ); diff --git a/src/transcoding/TranscodingJob.cpp b/src/transcoding/TranscodingJob.cpp index b715bd1..5b30c44 100644 --- a/src/transcoding/TranscodingJob.cpp +++ b/src/transcoding/TranscodingJob.cpp @@ -51,7 +51,7 @@ Job::Job( KUrl &src, debug() << "Transcoding::Job ctor!!"; debug()<< src; debug()<< src.path(); - QString fileExtension = The::transcodingController()->format( configuration.encoder() )->fileExtension(); + QString fileExtension = Amarok::Components::transcodingController()->format( configuration.encoder() )->fileExtension(); if( !( fileExtension.isEmpty() ) ) { QString destPath = src.path(); @@ -76,7 +76,7 @@ Job::init() *m_transcoder << QString( "-i" ) << m_src.path(); //... and finally, outfile configuration followed by the outfile path. - const Transcoding::Format *format = The::transcodingController()->format( m_configuration.encoder() ); + const Transcoding::Format *format = Amarok::Components::transcodingController()->format( m_configuration.encoder() ); *m_transcoder << format->ffmpegParameters( m_configuration ) << QString( "-map_meta_data" ) << QString( m_dest.path() + ":" + m_src.path() ) diff --git a/src/transcoding/TranscodingOptionsStackedWidget.cpp b/src/transcoding/TranscodingOptionsStackedWidget.cpp index daf1791..54c936d 100644 --- a/src/transcoding/TranscodingOptionsStackedWidget.cpp +++ b/src/transcoding/TranscodingOptionsStackedWidget.cpp @@ -34,7 +34,7 @@ OptionsStackedWidget::OptionsStackedWidget( QWidget *parent ) : QStackedWidget( parent ) { initWelcomePage(); - foreach( Format *format, The::transcodingController()->availableFormats() ) + foreach( Format *format, Amarok::Components::transcodingController()->availableFormats() ) { m_pagesMap.insert( format->encoder(), initCodecPage( format ) ); } -- 1.7.3.2
_______________________________________________ Amarok mailing list Amarok@kde.org https://mail.kde.org/mailman/listinfo/amarok