Bug 59250

Summary: Crash when using file search and trying to copy all files found afterwards
Product: [Applications] konqueror Reporter: Oliver Weber <almoeli>
Component: generalAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Oliver Weber 2003-06-02 13:34:50 UTC
Version:            (using KDE KDE 3.1.1a)
Installed from:    Compiled From Sources
Compiler:          gcc 2.95.3 
OS:          Linux

Konqueror crashes, when you do the following steps:

- Open 'Search files' from the 'Extras' menu
- Search files for example '*.txt' all other patterns work also. Include subfolders.
- Several files are found in several subfolders
- Choose 'Select All' from the 'Edit' menu
- Choose 'Copy' from the edit menu

The error was reproducable under kde 3.0.0 and under kde 3.1.1a
Comment 1 Waldo Bastian 2003-06-02 20:57:35 UTC
Subject: kdebase/libkonq

CVS commit by waba: 

CCMAIL: 59250-done@bugs.kde.org
Don't crash on copy without a currentItem() (BR59250)


  M +12 -4     konq_iconviewwidget.cc   1.240


--- kdebase/libkonq/konq_iconviewwidget.cc  #1.239:1.240
@@ -1087,11 +1087,10 @@ KonqIconDrag * KonqIconViewWidget::konqD
 
     KonqIconDrag * drag = new KonqIconDrag( dragSource );
-    // Position of the item clicked in the view
-    QPoint itempos = currentItem()->pixmapRect( FALSE ).topLeft();
-    // Set pixmap, with the correct offset
-    drag->setPixmap( *currentItem()->pixmap(), m_mousePos - itempos );
+    QIconViewItem *primaryItem = currentItem();
     // Append all items to the drag object
     for ( QIconViewItem *it = firstItem(); it; it = it->nextItem() ) {
         if ( it->isSelected() ) {
+          if (!primaryItem)
+             primaryItem = it;
           KURL url = (static_cast<KFileIVI *>(it))->item()->url();
           QString itemURL = KURLDrag::urlToString(url);
@@ -1107,4 +1106,13 @@ KonqIconDrag * KonqIconViewWidget::konqD
         }
     }
+
+    if (primaryItem)
+    {
+       // Position of the item clicked in the view
+       QPoint itempos = primaryItem->pixmapRect( FALSE ).topLeft();
+       // Set pixmap, with the correct offset
+       drag->setPixmap( *primaryItem->pixmap(), m_mousePos - itempos );
+    }
+
     return drag;
 }