[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/graphics/kphotoalbum
From:       Jan Kundrát <jkt () gentoo ! org>
Date:       2007-10-01 15:54:06
Message-ID: 1191254046.709363.11964.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 719661 by jkt:

merged r719659 from kde3 branch (prevent segfault in ThumbnailBuilder with zero images in the DB)


 M  +8 -1      MainWindow/Window.cpp  
 M  +6 -0      ThumbnailView/ThumbnailBuilder.cpp  


--- trunk/extragear/graphics/kphotoalbum/MainWindow/Window.cpp #719660:719661
@@ -120,6 +120,7 @@
 #include <KHBox>
 #include <K3URLDrag>
 #include <qclipboard.h>
+#include <stdexcept>
 
 MainWindow::Window* MainWindow::Window::_instance = 0;
 
@@ -1561,7 +1562,13 @@
 
 void MainWindow::Window::slotBuildThumbnails()
 {
-    new ThumbnailView::ThumbnailBuilder( this ); // It will delete itself
+    try {
+        new ThumbnailView::ThumbnailBuilder( this ); // It will delete itself
+    }
+    catch (std::out_of_range&) {
+        // This is thrown if there are no images to show, see ThumbnailBuilder's
+        // documentation.We can safely ignore it here.
+    }
 }
 
 void MainWindow::Window::slotOrderIncr()
--- trunk/extragear/graphics/kphotoalbum/ThumbnailView/ThumbnailBuilder.cpp #719660:719661
@@ -21,11 +21,17 @@
 #include "DB/ImageDB.h"
 #include <klocale.h>
 #include "DB/ImageInfo.h"
+#include <stdexcept>
 
 ThumbnailView::ThumbnailBuilder::ThumbnailBuilder( QWidget* parent, const char* name )
     :Q3ProgressDialog( parent, name )
 {
     _images = DB::ImageDB::instance()->images();
+    if ( _images.count() == 0 )
+        // we have to use exceptions because this won't get deleted if we just
+        // skipped generateNext()
+        throw std::out_of_range("ThumbnailView::ThumbnailBuilder with no images in the database");
+
     setTotalSteps( _images.count() );
     setProgress( 0 );
     setLabelText( i18n("Generating thumbnails") );
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic