[Kde-imaging] [Bug 221298] Digikam segfaults on Flickr export

Gilles Caulier caulier.gilles at gmail.com
Sun Jun 6 23:20:44 CEST 2010


https://bugs.kde.org/show_bug.cgi?id=221298





--- Comment #12 from Gilles Caulier <caulier gilles gmail com>  2010-06-06 23:20:37 ---
SVN commit 1135123 by eva:

This is a quickfix for  Bug 221298 -  Digikam segfaults on Flickr export
** Analysis:
- ImagesList::slotMoveUpItems() uses takeTopLevelItem(aboveIndex.row() and
then reinserts the item at new position
- FlickrListViewItem constructor creates a KLineEdit as a special widget
 and sets it using view->setItemWidget(...)
- Issue: view takes ownership of itemwidget. Thus KLineEdit widget is
 broken after calling takeTopLevelItem on the item
- same issue for slotMoveDownItems()
** QuickFix:
- add new virtual function updateItemWidgets to ImagesListViewItem and
implement it in FlickrListViewItem. Create a new KlineEdit in there and
call setItemWidget
- call updateItemWidget after having used takeTopLevelItem
** Remaining Issue:
we can't preserve the content of KLineEdit (extra tags in case of
flickr)
However, this feature has to be actively activated by the user, so it is
not being used by default. And at least we don't get crashes now
** Real fix ideas:
- implement a QItemDelegate (changing the model...)
- there might be a solution based on QLineEdit (needs to be
 investigated)



 M  +12 -0     common/libkipiplugins/widgets/imageslist.cpp
 M  +8 -0      common/libkipiplugins/widgets/imageslist.h
 M  +12 -2     flickrexport/flickrlist.cpp
 M  +2 -0      flickrexport/flickrlist.h


---
trunk/extragear/graphics/kipi-plugins/common/libkipiplugins/widgets/imageslist.cpp
#1135122:1135123
@@ -185,6 +185,12 @@
    setIcon(ImagesListView::Thumbnail, QIcon(m_thumb));
 }

+
+ImagesListView* ImagesListViewItem::view()
+{
+    return m_view;
+}
+
 // ---------------------------------------------------------------------------

 ImagesListView::ImagesListView(ImagesList *parent)
@@ -746,6 +752,7 @@

 void ImagesList::slotMoveUpItems()
 {
+    // move above item down, then we don't have to fix the focus
    QModelIndex curIndex = listView()->currentIndex();
    if (!curIndex.isValid())
        return;
@@ -756,12 +763,15 @@

    QTreeWidgetItem* temp = listView()->takeTopLevelItem(aboveIndex.row());
    listView()->insertTopLevelItem(curIndex.row(), temp);
+    // this is a quick fix. We loose the extra tags in flickr upload, but at
list we don't get a crash
+    dynamic_cast<KIPIPlugins::ImagesListViewItem*>(temp)->updateItemWidgets();

    emit signalImageListChanged();
 }

 void ImagesList::slotMoveDownItems()
 {
+    // move below item up, then we don't have to fix the focus
    QModelIndex curIndex = listView()->currentIndex();
    if (!curIndex.isValid())
        return;
@@ -772,6 +782,8 @@

    QTreeWidgetItem* temp = listView()->takeTopLevelItem(belowIndex.row());
    listView()->insertTopLevelItem(curIndex.row(), temp);
+    // this is a quick fix. We loose the extra tags in flickr upload, but at
list we don't get a crash
+    dynamic_cast<KIPIPlugins::ImagesListViewItem*>(temp)->updateItemWidgets();

    emit signalImageListChanged();
 }
---
trunk/extragear/graphics/kipi-plugins/common/libkipiplugins/widgets/imageslist.h
#1135122:1135123
@@ -88,6 +88,14 @@

    void updateInformation();

+    // implement this, if you have special item widgets, e.g. an edit line
+    // they will be set automatically when adding items, changing order, etc.
+    virtual void updateItemWidgets() {};
+
+protected:
+
+    ImagesListView* view();
+
 private:

    int             m_rating;         // Image Rating from Kipi host.
--- trunk/extragear/graphics/kipi-plugins/flickrexport/flickrlist.cpp
#1135122:1135123
@@ -421,12 +421,22 @@
               FlickrList::TAGS),
               i18n("Add extra tags per image or use Upload Options tab to "
                    "add tags for all images"));
-    m_tagLineEdit = new KLineEdit(view);
+    //m_tagLineEdit = new KLineEdit(view);
+    //m_tagLineEdit->setToolTip(i18n("Enter extra tags, separated by
commas."));
+    //view->setItemWidget(this,
static_cast<KIPIPlugins::ImagesListView::ColumnType>(
+    //                    FlickrList::TAGS), m_tagLineEdit);
+    updateItemWidgets();
+}
+
+void FlickrListViewItem::updateItemWidgets()
+{
+    m_tagLineEdit = new KLineEdit(view());
    m_tagLineEdit->setToolTip(i18n("Enter extra tags, separated by commas."));
-    view->setItemWidget(this,
static_cast<KIPIPlugins::ImagesListView::ColumnType>(
+    view()->setItemWidget(this,
static_cast<KIPIPlugins::ImagesListView::ColumnType>(
                        FlickrList::TAGS), m_tagLineEdit);
 }

+
 QStringList FlickrListViewItem::extraTags()
 {
    return m_tagLineEdit->text().split(',', QString::SkipEmptyParts);
--- trunk/extragear/graphics/kipi-plugins/flickrexport/flickrlist.h
#1135122:1135123
@@ -151,6 +151,8 @@
    /* This method should be called when one of the checkboxes is clicked. */
    void toggled();

+    virtual void updateItemWidgets();
+
 private:

    bool                    m_is23;

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Kde-imaging mailing list