<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>102238</bug_id>
          
          <creation_ts>2005-03-23 03:39:35 +0000</creation_ts>
          <short_desc>Random play is not random</short_desc>
          <delta_ts>2005-08-18 04:25:18 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>juk</product>
          <component>general</component>
          <version>2.2</version>
          <rep_platform>FreeBSD Ports</rep_platform>
          <op_sys>FreeBSD</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Johnson">david</reporter>
          <assigned_to name="Scott Wheeler">wheeler</assigned_to>
          <cc>Marcin.Kasperski</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>30</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>327066</commentid>
    <comment_count>0</comment_count>
    <who name="David Johnson">david</who>
    <bug_when>2005-03-23 03:39:36 +0000</bug_when>
    <thetext>Version:           2.2 (using KDE KDE 3.4.0)
Installed from:    FreeBSD Ports
Compiler:          gcc 3.4.2 
OS:                FreeBSD

When Player-&gt;Random Play-&gt;Use Random Play is selected, the results are not random. When I click on collection the same song is always selected. Subsequent songs are always in the same sequence. I get the exact same sequence of songs everytime JuK is run. The behavior is as if it uses the same seed everytime for a bad random number generator. There were no problems with the prior versions.

Partial contents of jukrc are:

[Player]
LoopPlaylist=true
RandomPlay=Normal
Volume=100

[Playlists]
CollectionListSortAscending=true
CollectionListSortColumn=1
DirectoryList=/alt/share/music
ImportPlaylists=false
showUpcoming=false

[Settings]
DockInSystemTray=true
DockOnClose=true
MediaSystem=1
ShowSplashScreen=true
StartDocked=false
TrackPopup=false</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>327424</commentid>
    <comment_count>1</comment_count>
    <who name="Kevin Dorne">sweetpea-kde</who>
    <bug_when>2005-03-23 22:38:13 +0000</bug_when>
    <thetext>This seems to happen with random by album as well.  not sure if it&apos;s just in the newest version, as I never used random by album before.  The random by track used to seem random, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>343310</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Pyne">mpyne</who>
    <bug_when>2005-05-18 21:58:50 +0000</bug_when>
    <thetext>*** Bug 105900 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>355251</commentid>
    <comment_count>3</comment_count>
      <attachid>11672</attachid>
    <who name="Kevin Dorne">sweetpea-kde</who>
    <bug_when>2005-07-04 06:00:41 +0000</bug_when>
    <thetext>Created attachment 11672
Patch to call srandomdev before random() functions

This will only work on *BSD systems, AFAIK</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>366452</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Pyne">mpyne</who>
    <bug_when>2005-08-18 04:23:31 +0000</bug_when>
    <thetext>SVN commit 450391 by mpyne:

Fix bug 102238 (Random play is not random between starts) in KDE 3.5, by
using KApplication::random() (which will always initialize a random seed)
instead of the C library (which may or may not initialize a random seed).

CCBUG:102238


 M  +4 -5      tracksequenceiterator.cpp  


--- branches/KDE/3.5/kdemultimedia/juk/tracksequenceiterator.cpp #450390:450391
@@ -14,10 +14,9 @@
  ***************************************************************************/
 
 #include &lt;kaction.h&gt;
+#include &lt;kapplication.h&gt;
 #include &lt;kdebug.h&gt;
 
-#include &lt;stdlib.h&gt;
-
 #include &quot;tracksequenceiterator.h&quot;
 #include &quot;playlist.h&quot;
 #include &quot;actioncollection.h&quot;
@@ -89,7 +88,7 @@
 
         if(albumRandom) {
             if(m_albumSearch.isNull() || m_albumSearch.matchedItems().isEmpty()) {
-                item = m_randomItems[::random() % m_randomItems.count()];
+                item = m_randomItems[KApplication::random() % m_randomItems.count()];
                 initAlbumSearch(item);
             }
 
@@ -115,7 +114,7 @@
             }
         }
         else
-            item = m_randomItems[::random() % m_randomItems.count()];
+            item = m_randomItems[KApplication::random() % m_randomItems.count()];
 
         setCurrent(item);
         m_randomItems.remove(item);
@@ -156,7 +155,7 @@
 
         PlaylistItem *newItem = 0;
         if(!items.isEmpty())
-            newItem = items[::random() % items.count()];
+            newItem = items[KApplication::random() % items.count()];
 
         setCurrent(newItem);
         refillRandomList();
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>366453</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Pyne">mpyne</who>
    <bug_when>2005-08-18 04:25:18 +0000</bug_when>
    <thetext>SVN commit 450395 by mpyne:

Backport fix for bug 102238 (Random play is not random between starts) to KDE
3.4.

BUG:102238


 M  +4 -5      tracksequenceiterator.cpp  


--- branches/KDE/3.4/kdemultimedia/juk/tracksequenceiterator.cpp #450394:450395
@@ -14,10 +14,9 @@
  ***************************************************************************/
 
 #include &lt;kaction.h&gt;
+#include &lt;kapplication.h&gt;
 #include &lt;kdebug.h&gt;
 
-#include &lt;stdlib.h&gt;
-
 #include &quot;tracksequenceiterator.h&quot;
 #include &quot;playlist.h&quot;
 #include &quot;actioncollection.h&quot;
@@ -81,7 +80,7 @@
 
         if(albumRandom) {
             if(m_albumSearch.isNull() || m_albumSearch.matchedItems().isEmpty()) {
-                item = m_randomItems[::random() % m_randomItems.count()];
+                item = m_randomItems[KApplication::random() % m_randomItems.count()];
                 initAlbumSearch(item);
             }
 
@@ -107,7 +106,7 @@
             }
         }
         else
-            item = m_randomItems[::random() % m_randomItems.count()];
+            item = m_randomItems[KApplication::random() % m_randomItems.count()];
 
         setCurrent(item);
         m_randomItems.remove(item);
@@ -148,7 +147,7 @@
 
         PlaylistItem *newItem = 0;
         if(!items.isEmpty())
-            newItem = items[::random() % items.count()];
+            newItem = items[KApplication::random() % items.count()];
 
         setCurrent(newItem);
         refillRandomList();
</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>11672</attachid>
            <date>2005-07-04 06:00:41 +0000</date>
            <delta_ts>2005-07-04 06:00:41 +0000</delta_ts>
            <desc>Patch to call srandomdev before random() functions</desc>
            <filename>srandomdev.patch</filename>
            <type>text/plain</type>
            <size>382</size>
            <attacher name="Kevin Dorne">sweetpea-kde</attacher>
            
              <data encoding="base64">LS0tIGp1ay90cmFja3NlcXVlbmNlaXRlcmF0b3IuY3BwCVR1ZSBNYXkgMjQgMDA6MDc6MDQgMjAw
NQorKysganVrL3RyYWNrc2VxdWVuY2VpdGVyYXRvci5jcHAJTW9uIEp1bCAgNCAxNDowNjoyMSAy
MDA1CkBAIC03OSw2ICs3OSw4IEBACiAKICAgICAgICAgUGxheWxpc3RJdGVtICppdGVtOwogCisg
ICAgICAgIDo6c3JhbmRvbWRldigpOworCiAgICAgICAgIGlmKGFsYnVtUmFuZG9tKSB7CiAgICAg
ICAgICAgICBpZihtX2FsYnVtU2VhcmNoLmlzTnVsbCgpIHx8IG1fYWxidW1TZWFyY2gubWF0Y2hl
ZEl0ZW1zKCkuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgaXRlbSA9IG1fcmFuZG9tSXRl
bXNbOjpyYW5kb20oKSAlIG1fcmFuZG9tSXRlbXMuY291bnQoKV07Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>