Bug 127683

Summary: CUE sheet remains activated
Product: [Applications] amarok Reporter: Jan Sokoly <cruster>
Component: generalAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: normal CC: ted, wolverine
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Slackware   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Seems to fix this bug
Same patch; no indentation changes

Description Jan Sokoly 2006-05-19 21:49:11 UTC
Version:           1.4.0a (using KDE KDE 3.5.2)
Installed from:    Slackware Packages
OS:                Linux

Try to play a file, where a CUE sheet is being used. Everything works fine. Now, load some radio station. The CUE sheet from previously played file remained activated and is showing incorrect data of course.
Comment 1 Christie 2006-05-19 23:41:55 UTC
I can confirm this - playing a radio stream after playing a track with a cue sheet shows the wrong metadata for the stream, with both xine and helix engines, using svn revision 542344.
Comment 2 Louis Nichols 2006-10-04 11:24:32 UTC
I observed the same situation - It's pretty annoying
Comment 3 simon 2006-11-13 18:30:09 UTC
jepp , made a comment on this issue in #112477, so here once again... *confirm*
Comment 4 Daniel Faust 2006-11-18 14:35:18 UTC
I can confirm this, too. I noticed it while playing a last.fm stream.
Comment 5 Daniel Faust 2006-11-18 14:37:00 UTC
*** This bug has been confirmed by popular vote. ***
Comment 6 Ted Percival 2006-12-09 14:48:47 UTC
Created attachment 18867 [details]
Seems to fix this bug

The diff looks like it changes a lot, but it's mostly an artifact of changed
indentation. I added a call to m_cuefile->clear() if trackChanged (regardless
of isLocalFile) and put the rest of the code in a nested if statement that then
is only run if isLocalFile() returns true.
Comment 7 Ted Percival 2006-12-09 15:10:30 UTC
Created attachment 18868 [details]
Same patch; no indentation changes

This is the same patch as above but without changing the indentation of the
inner block. For people whose brains have frozen and would prefer to see a
simpler patch and fix the indentation themselves :)
Comment 8 Dawid Wróbel 2007-01-07 18:30:17 UTC
Tested and works. Some things have changed in svn recently in the contextbrowser.cpp file recently so apply it with care.
Comment 9 Martin Aumueller 2007-01-07 18:39:19 UTC
SVN commit 620896 by aumuell:

disable cue sheet when switching to streams
- thanks to Ted Percival <ted@midg3t.net> for the patch!
BUG: 127683


 M  +2 -0      ChangeLog  
 M  +54 -50    src/contextbrowser.cpp  


--- trunk/extragear/multimedia/amarok/ChangeLog #620895:620896
@@ -94,6 +94,8 @@
     * Amarok now saves playlists with relative paths by default.
 
   BUGFIXES:
+    * Cue sheet would remain enabled when switching to a stream. Patch
+      by Ted Percival <ted@midg3t.net>. (BR 127683)
     * Length of tracks wouldn't be shown correctly for some cue files.
       Patch by Dawid Wróbel <dawid@klej.net> (BR 139707)
     * Assume that all dots but the last in script executable files belong to
--- trunk/extragear/multimedia/amarok/src/contextbrowser.cpp #620895:620896
@@ -646,76 +646,80 @@
     else if ( CollectionDB::instance()->isEmpty() || !CollectionDB::instance()->isValid() )
         showCurrentTrack();
 
-
-    if (trackChanged && bundle.url().isLocalFile())
+    if (trackChanged)
     {
+        m_cuefile->clear();
 
-        /** The cue file that is provided with the media might have different name than the
-           * media file itself, hence simply cutting the media extension and adding ".cue"
-           * is not always enough to find the matching cue file. In such cases we have
-           * to search for all the cue files in the directory and have a look inside them for
-           * the matching FILE="" stanza. However the FILE="" stanza does not always
-           * point at the coresponding media file (e.g. it is quite often set to the misleading
-           * FILE="audio.wav" WAV). Therfore we also have to check blindly if there is a cue
-           * file having the same name as the media file played, as described above.
-           */
+        if (bundle.url().isLocalFile())
+        {
 
-        // look for the cue file that matches the media file played first
-        QString path    = bundle.url().path();
-        QString cueFile = path.left( path.findRev('.') ) + ".cue";
+            /** The cue file that is provided with the media might have different name than the
+             * media file itself, hence simply cutting the media extension and adding ".cue"
+             * is not always enough to find the matching cue file. In such cases we have
+             * to search for all the cue files in the directory and have a look inside them for
+             * the matching FILE="" stanza. However the FILE="" stanza does not always
+             * point at the coresponding media file (e.g. it is quite often set to the misleading
+             * FILE="audio.wav" WAV). Therfore we also have to check blindly if there is a cue
+             * file having the same name as the media file played, as described above.
+             */
 
-        m_cuefile->setCueFileName( cueFile );
+            // look for the cue file that matches the media file played first
+            QString path    = bundle.url().path();
+            QString cueFile = path.left( path.findRev('.') ) + ".cue";
 
-        if( m_cuefile->load( bundle.length() ) )
-            debug() << "[CUEFILE]: " << cueFile << " - Shoot blindly, found and loaded. " << endl;
+            m_cuefile->setCueFileName( cueFile );
 
-        // if unlucky, let's have a look inside cue files, if any
-        else
-        {
-            debug() << "[CUEFILE]: " << cueFile << " - Shoot blindly and missed, searching for other cue files." << endl;
+            if( m_cuefile->load( bundle.length() ) )
+                debug() << "[CUEFILE]: " << cueFile << " - Shoot blindly, found and loaded. " << endl;
 
-            bool foundCueFile = false;
-            QDir dir ( bundle.directory() );    
-            dir.setFilter( QDir::Files ) ;
-            dir.setNameFilter( "*.cue *.CUE" ) ;
+            // if unlucky, let's have a look inside cue files, if any
+            else
+            {
+                debug() << "[CUEFILE]: " << cueFile << " - Shoot blindly and missed, searching for other cue files." << endl;
 
-            QStringList cueFilesList = dir.entryList();
+                bool foundCueFile = false;
+                QDir dir ( bundle.directory() );    
+                dir.setFilter( QDir::Files ) ;
+                dir.setNameFilter( "*.cue *.CUE" ) ;
 
-            if ( !cueFilesList.empty() )
-                for ( QStringList::Iterator it = cueFilesList.begin(); it != cueFilesList.end() && !foundCueFile; ++it ) 
-                {
-                    QFile file ( dir.filePath(*it) );
-                    if( file.open( IO_ReadOnly ) )
+                QStringList cueFilesList = dir.entryList();
+
+                if ( !cueFilesList.empty() )
+                    for ( QStringList::Iterator it = cueFilesList.begin(); it != cueFilesList.end() && !foundCueFile; ++it ) 
                     {
-                        debug() << "[CUEFILE]: " << *it << " - Opened, looking for the matching FILE stanza." << endl;
-                        QTextStream stream( &file );
-                        QString line;
-
-                        while ( !stream.atEnd() && !foundCueFile)
+                        QFile file ( dir.filePath(*it) );
+                        if( file.open( IO_ReadOnly ) )
                         {
-                            line = stream.readLine().simplifyWhiteSpace();
+                            debug() << "[CUEFILE]: " << *it << " - Opened, looking for the matching FILE stanza." << endl;
+                            QTextStream stream( &file );
+                            QString line;
 
-                            if( line.startsWith( "file", false ) )
+                            while ( !stream.atEnd() && !foundCueFile)
                             {
-                                line = line.mid( 5 ).remove( '"' );
+                                line = stream.readLine().simplifyWhiteSpace();
 
-                                if ( line.contains( bundle.filename(), false ) )
+                                if( line.startsWith( "file", false ) )
                                 {
-                                    cueFile = dir.filePath(*it);
-                                    foundCueFile = true;
-                                    m_cuefile->setCueFileName( cueFile );
-                                    if( m_cuefile->load( bundle.length() ) )
-                                        debug() << "[CUEFILE]: " << cueFile << " - Looked inside cue files, found and loaded proper one" << endl;
+                                    line = line.mid( 5 ).remove( '"' );
+
+                                    if ( line.contains( bundle.filename(), false ) )
+                                    {
+                                        cueFile = dir.filePath(*it);
+                                        foundCueFile = true;
+                                        m_cuefile->setCueFileName( cueFile );
+                                        if( m_cuefile->load( bundle.length() ) )
+                                            debug() << "[CUEFILE]: " << cueFile << " - Looked inside cue files, found and loaded proper one" << endl;
+                                    }
                                 }
                             }
+
+                            file.close();
                         }
-
-                        file.close();
                     }
-                }
 
-            if ( !foundCueFile )
-                debug() << "[CUEFILE]: - Didn't find any matching cue file." << endl;
+                if ( !foundCueFile )
+                    debug() << "[CUEFILE]: - Didn't find any matching cue file." << endl;
+            }
         }
     }
 }
Comment 10 Maximilian Kossick 2007-01-07 20:12:38 UTC
*** Bug 128769 has been marked as a duplicate of this bug. ***