Bug 57930 - kslideshow says "No images found" after awhile when "Random Order" is selected
Summary: kslideshow says "No images found" after awhile when "Random Order" is selected
Status: RESOLVED FIXED
Alias: None
Product: kscreensaver
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kscreensaver bugs tracking
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-01 05:13 UTC by Mark
Modified: 2008-05-19 17:59 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark 2003-05-01 05:13:27 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
OS:          Linux

the following diff fixed my problem. but i'm not sure if that was the correct way to fix it

Index: slideshow.cpp
===================================================================
RCS file: /home/kde/kdeartwork/kscreensaver/kdesavers/slideshow.cpp,v
retrieving revision 1.13
diff -u -3 -p -r1.13 slideshow.cpp
--- slideshow.cpp       24 Apr 2003 15:16:38 -0000      1.13
+++ slideshow.cpp       1 May 2003 02:53:29 -0000
@@ -783,7 +783,7 @@ void kSlideShowSaver::loadNextImage()
     if (num <= 0) return;
     mFileIdx = rand() % num;
     fname = mFileList[mFileIdx];
-    mFileList.remove(fname);
+//    mFileList.remove(fname);
   }
   else
   {
Comment 1 Mark 2003-05-01 11:01:43 UTC
looks like Chris Howells didn't or couldn't test his latest cvs commit to kslideshow
Comment 2 Chris Howells 2003-05-01 12:15:44 UTC
Subject: Re:  New: kslideshow says "No images found" after awhile when "Random Order" is selected

Hi,

On Thursday 01 May 2003 04:13, Mark wrote:
> the following diff fixed my problem. but i'm not sure if that was the
> correct way to fix it

Not quite; that will potentially allow the screensaver to show the same image 
more than once. I have another fix in mind but it's a bit hacky. Hopefully 
I'll be able to work on it within the next few days.

Comment 3 Chris Howells 2003-05-01 12:18:38 UTC
Subject: Re:  kslideshow says "No images found" after awhile when "Random Order" is selected

Hi,

On Thursday 01 May 2003 10:01, Mark wrote:
> looks like Chris Howells didn't or couldn't test his latest cvs commit to
> kslideshow

I did test, unfortunately fixing issues usually breaks other things :)

Comment 4 Mark 2003-05-01 19:51:44 UTC
Subject: Re:  kslideshow says "No images found" after awhile when
 "Random Order" is selected         

Revision 1.13 / (download) - annotate - [select for diffs], Thu Apr 24
15:16:38 2003 UTC (7 days, 2 hours ago) by howells
Branch: MAIN
CVS Tags: HEAD
Changes since 1.12: +4 -7 lines
Diff to previous 1.12 (colored)

Get rid of one of the QStringLists, I see absolutely no need why one is
needed for random mode and one for "normal" mode.

can't you just reverse that commit?

On Thu, 1 May 2003, Chris Howells wrote:

> On Thursday 01 May 2003 04:13, Mark wrote:
> > the following diff fixed my problem. but i'm not sure if that was the
> > correct way to fix it
>
> Not quite; that will potentially allow the screensaver to show the same image
> more than once. I have another fix in mind but it's a bit hacky. Hopefully
> I'll be able to work on it within the next few days.
>

Comment 5 Chris Howells 2003-05-01 21:32:17 UTC
Subject: kdeartwork/kscreensaver/kdesavers

CVS commit by howells: 

Don't run out of images in random mode.

CCMAIL: 57930-done@bugs.kde.org


  M +12 -5     slideshow.cpp   1.14
  M +1 -0      slideshow.h   1.7


--- kdeartwork/kscreensaver/kdesavers/slideshow.cpp  #1.13:1.14
@@ -772,17 +772,21 @@ void kSlideShowSaver::loadNextImage()
 {
   QString fname;
-  int num, i, j;
+  int num;
 
   if (mShowRandom)
   {
     num = mFileList.count();
-    if (num <= 0)
+    if (num <= 0) //no files in the directory
     {
-      num = mFileList.count();
+      return;
     }
-    if (num <= 0) return;
     mFileIdx = rand() % num;
     fname = mFileList[mFileIdx];
     mFileList.remove(fname);
+    if (num == 1) //we're about to run out of images
+    {
+      mFileList = mRandomList;
+      num = mFileList.count();
+    }
   }
   else
@@ -797,9 +801,11 @@ void kSlideShowSaver::loadNextImage()
     kdDebug() << "Failed to load image " << fname << endl;
     mFileList.remove(fname);
-    if (!mFileList.isEmpty()) loadNextImage();
+    if (!mFileList.isEmpty())
+        loadNextImage();
     return;
   }
   mFileIdx++;
 
+  int i, j;
   i = fname.findRev('.');
   if (i < 0) i = 32767;
@@ -816,4 +822,5 @@ void kSlideShowSaver::loadDirectory()
   mFileList.clear();
   traverseDirectory(mDirectory);
+  mRandomList = mFileList;
 }
 

--- kdeartwork/kscreensaver/kdesavers/slideshow.h  #1.6:1.7
@@ -90,4 +90,5 @@ protected:
   int mColorContext;
   QStringList mFileList;
+  QStringList mRandomList;
   int mFileIdx;
   QImage mImage;