[Kde-pim] Re: Bug? CollectionFetchJob doesn't always work after AgentInstanceCreateJob

David Jarvie djarvie at kde.org
Sun May 15 20:44:42 BST 2011


On Sunday 15 May 2011 20:29:34 Stephen Kelly wrote:
> David Jarvie wrote:
> 
> > When CollectionFetchJob is called to fetch the collection created by an
> > AgentInstanceCreateJob, it doesn't always return any collection even
> > though the result status is ok. I suspect that some sort of timing issue
> > may be responsible for no collection being returned - perhaps the
> > collection isn't created quite soon enough?
> > 
> > In AgentInstanceCreateJob result slot, some configuration of the agent is
> > done, followed by calling agent.reconfigure(), and then a
> > CollectionFetchJob is created, with the resource to use in it being
> > specified by fetchScope().setResource(agent.identifier()). There are slots
> > connected to both the job's collectionsReceived() signal and its result()
> > signal. Sometimes the collectionsReceived() slot is called, and sometimes
> > not. The result() slot always indicates success.
> > 
> > Looking at the resources in akonadiconsole always shows them to have been
> > created successfully.
> > 
> > So my conclusion is that there needs to be some delay before calling
> > CollectionFetchJob if it is to work properly and reliably. This seems like
> > a bug.
> > 
> 
> What does your result slot look like? Something like
> 
> void MyClass::slotResult(KJob *job)
> {
> 
>   if (job->error())
>     return;
> 
>   CollectionFetchJob *colFetch = qobject_cast<CollectionFetchJob *>(job);
>   kDebug() << colFetch->collections().size();
> 
> }
> 
> 
> What is the output of the debug?


The essential bits of code are:

void CalendarCreator::agentCreated(KJob* j)
{
    if (j->error())
    {
        kError() << "AgentInstanceCreateJob error";
        return;
    }

    // Configure the Akonadi Agent
    kDebug() << mName;
    AgentInstanceCreateJob* job = static_cast<AgentInstanceCreateJob*>(j);
    mAgent = job->instance();
    ...
    mAgent.setName(mName);
    mAgent.reconfigure();   // notify the agent that its configuration has been changed

    // Find the collection which this agent manages
    CollectionFetchJob* fjob = new CollectionFetchJob(Collection::root(), CollectionFetchJob::FirstLevel);
    fjob->fetchScope().setResource(mAgent.identifier());
    connect(fjob, SIGNAL(collectionsReceived(const Akonadi::Collection::List&)),
                  SLOT(collectionsReceived(const Akonadi::Collection::List&)));
    connect(fjob, SIGNAL(result(KJob*)), SLOT(collectionFetchResult(KJob*)));
}

void CalendarCreator::collectionsReceived(const Akonadi::Collection::List& collections)
{
    kDebug() << mName;
    ...
}

void CalendarCreator::collectionFetchResult(KJob* j)
{
kDebug() << mName;
    if (j->error())
    {
        kError() << "CollectionFetchJob error";
    }
}

The debug output in one instance was:

kalarm(11781) CalendarCreator::agentCreated: "Active Alarms"
kalarm(11781) CalendarCreator::agentCreated: "Alarm Templates"
kalarm(11781) CalendarCreator::collectionsReceived: "Active Alarms"
kalarm(11781) CalendarCreator::collectionFetchResult: "Active Alarms"
kalarm(11781) CalendarCreator::collectionFetchResult: "Alarm Templates"
kalarm(11781) CalendarCreator::modifyCollectionJobDone: Completed: "Active Alarms"
kalarm(11781) CalendarCreator::agentCreated: "Archived Alarms"
kalarm(11781) CalendarCreator::collectionFetchResult: "Archived Alarms"

In this example, "Active Alarms" is processed successfully, but the other two collections are not fetched, without any error messages appearing in the log. (All levels of debug are output to the same location, so there are no missing kWarning messages.)

-- 
David Jarvie.
KDE developer.
KAlarm author -- http://www.astrojar.org.uk/kalarm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20110515/f61ca04c/attachment.sig>
-------------- next part --------------
_______________________________________________
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