[KPhotoAlbum] kf5-port: fix for crash when clicking on browse items

Matthias Füssel matthias.fuessel at gmx.net
Sun May 22 13:42:05 CEST 2016


Hello @all,

I've played a bit with the "kf5-port" branch under openSuSE Tumbleweed (KDE
5). It compiles fine but crashes whenever you click on some category icon or
tag icon in the browse view (crash happens during mouseRelease event, using
the keyboard works).

If you connect the "itemClicked" slot with the "activated" signal instead of
the "clicked" signal (see attached diff), clicking cateories and tags works
again. You also get the "selected item will be triggered when the return key
is pressed" behaviour for free (i.e. without the code in the event filter) if
you use "activated".

After this fix, at first glance most of KPhotoAlbum seems to work with KDE5/KF5.

Regards,
Matthias
-------------- next part --------------
diff --git a/Browser/BrowserWidget.cpp b/Browser/BrowserWidget.cpp
index e4967c7..5a673ee 100644
--- a/Browser/BrowserWidget.cpp
+++ b/Browser/BrowserWidget.cpp
@@ -289,7 +289,7 @@ void Browser::BrowserWidget::switchToViewType( DB::Category::ViewType type )
 {
     if ( m_curView ) {
         m_curView->setModel(0);
-        disconnect( m_curView, SIGNAL(clicked(QModelIndex)), this, SLOT(itemClicked(QModelIndex)) );
+        disconnect( m_curView, SIGNAL(activated(QModelIndex)), this, SLOT(itemClicked(QModelIndex)) );
     }
 
     if ( type == DB::Category::TreeView || type == DB::Category::ThumbedTreeView ) {
@@ -313,7 +313,7 @@ void Browser::BrowserWidget::switchToViewType( DB::Category::ViewType type )
 
     // Hook up the new view
     m_curView->setModel( m_filterProxy );
-    connect( m_curView, SIGNAL(clicked(QModelIndex)), this, SLOT(itemClicked(QModelIndex)) );
+    connect( m_curView, SIGNAL(activated(QModelIndex)), this, SLOT(itemClicked(QModelIndex)) );
 
 
     m_stack->setCurrentWidget( m_curView );
@@ -407,15 +407,7 @@ void Browser::BrowserWidget::createWidgets()
 
 bool Browser::BrowserWidget::eventFilter( QObject* obj, QEvent* event)
 {
-    if ( event->type() == QEvent::KeyPress ) {
-        QKeyEvent* ke = static_cast<QKeyEvent*>( event );
-        if ( ke->key() == Qt::Key_Return ) {
-            if ( m_curView == obj )
-                itemClicked( m_curView->currentIndex() );
-        }
-    }
-
-    else if (event->type() == QEvent::MouseButtonPress ||
+    if (event->type() == QEvent::MouseButtonPress ||
              event->type() == QEvent::MouseMove ||
              event->type() == QEvent::MouseButtonRelease ) {
         QMouseEvent* me = static_cast<QMouseEvent*>( event );
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 884 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kdab.com/pipermail/kphotoalbum/attachments/20160522/ea592a48/attachment.sig>


More information about the KPhotoAlbum mailing list