~ubuntu-branches/ubuntu/lucid/kde4libs/lucid-updates

« back to all changes in this revision

Viewing changes to nepomuk/core/resourcedata.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2010-02-04 14:24:15 UTC
  • mfrom: (1.1.44 upstream)
  • Revision ID: james.westby@ubuntu.com-20100204142415-m9s99idmc0685wei
Tags: 4:4.4.0-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * This file is part of the Nepomuk KDE project.
3
 
 * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
 
3
 * Copyright (C) 2006-2010 Sebastian Trueg <trueg@kde.org>
4
4
 *
5
5
 * This library is free software; you can redistribute it and/or
6
6
 * modify it under the terms of the GNU Library General Public
28
28
#include "nfo.h"
29
29
#include "pimo.h"
30
30
#include "nepomukmainmodel.h"
 
31
#include "dbusconnectionpool.h"
31
32
 
32
33
#include <Soprano/Statement>
33
34
#include <Soprano/StatementIterator>
94
95
    if( m_rm->dataCacheFull() )
95
96
        m_rm->cleanupCache();
96
97
 
97
 
    ++m_rm->dataCnt;
 
98
    m_rm->dataCnt.ref();
98
99
}
99
100
 
100
101
 
101
102
Nepomuk::ResourceData::~ResourceData()
102
103
{
103
 
    delete m_pimoThing;
104
 
    --m_rm->dataCnt;
 
104
    resetAll(true);
 
105
    m_rm->dataCnt.deref();
105
106
}
106
107
 
107
108
 
166
167
 
167
168
 
168
169
 
169
 
void Nepomuk::ResourceData::resetAll()
 
170
void Nepomuk::ResourceData::resetAll( bool isDelete )
170
171
{
171
172
    // reset proxy
172
173
    bool hadProxy = false;
174
175
        hadProxy = true;
175
176
        if( !m_proxyData->deref() &&
176
177
            rm()->dataCacheFull() )
177
 
            m_proxyData->deleteData();
 
178
            delete m_proxyData;
178
179
        m_proxyData = 0;
179
180
    }
180
181
 
190
191
 
191
192
    // reset all variables
192
193
    m_uri = QUrl();
 
194
    m_fileUrl = KUrl();
193
195
    m_kickoffId.truncate(0);
194
196
    m_kickoffUri = QUrl();
195
197
    m_cache.clear();
196
198
    m_cacheDirty = false;
197
199
    m_types.clear();
198
 
    m_mainType = Soprano::Vocabulary::RDFS::Resource();
199
 
}
200
 
 
201
 
 
202
 
void Nepomuk::ResourceData::deleteData()
203
 
{
204
 
    resetAll();
205
 
    delete this;
 
200
    delete m_pimoThing;
 
201
    m_pimoThing = 0;
 
202
    m_groundingOccurence = 0;
 
203
 
 
204
    // when we are being deleted the value of m_mainType is not important
 
205
    // andmore. Also since ResourceManager is a global static it might be
 
206
    // deleted after the global static behind Soprano::Vocabulary::RDFS
 
207
    // which results in a crash.
 
208
    if( !isDelete )
 
209
        m_mainType = Soprano::Vocabulary::RDFS::Resource();
206
210
}
207
211
 
208
212
 
676
680
                    KUrl resourceUri = QDBusReply<QString>( QDBusInterface(QLatin1String("org.kde.nepomuk.services.nepomukremovablestorageservice"),
677
681
                                                                           QLatin1String("/nepomukremovablestorageservice"),
678
682
                                                                           QLatin1String("org.kde.nepomuk.RemovableStorage"),
679
 
                                                                           QDBusConnection::sessionBus())
 
683
                                                                           DBusConnectionPool::threadConnection())
680
684
                                                            .call( QLatin1String("resourceUriFromLocalFileUrl"),
681
685
                                                                   m_kickoffUri.url() ) ).value();
682
686
                    if( !resourceUri.isEmpty() ) {