[Kde-pim] SEGV reading Akonadi::Attribute from retrieveItem

Jesús Pérez kdelists at chuso.net
Thu May 29 18:03:49 BST 2014


> > bool testResource::retrieveItem( const Akonadi::Item &item, const
> > QSet<QByteArray> &parts )
> > {
> >   TestAttribute *attr =
> >   item.parentCollection().attribute<TestAttribute>(); // NULL pointer
> >   QByteArray attr_value = attr->serialized(); // SEGV
>
> If you need to have access to item's parent collection attributes, you need to
> retrieve the collection manually.

So I need to use a CollectionFetchJob?

> For performance
> reasons, it's possible to specify what all parts of Item (or Collection) you
> want to fetch from Akonadi server, I think attributes for items are disabled
> by default.

And how can I specify that?
I though that changeRecorder()->fetchCollection(true) or
changeRecorder()->setCollectionFetchScope() may help, but they don't.
Also, according to documentation
<http://api.kde.org/4.x-api/kdepimlibs-apidocs/akonadi/html/classAkonadi_1_1CollectionFetchScope.html#details>:

"Note that CollectionFetchScope always includes fetching collection attributes".

I've been researching this for hours and found no solution yet. So,
unless someone can help me with this, I think I'm gonna store a
collection id <-> attribute pair value in KConfig so I can read it
from retrieveItem. Any alternative?
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list