Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/serialization/itemrepositoryregistry.cpp
Show First 20 Lines • Show All 226 Lines • ▼ Show 20 Line(s) | 225 | { | |||
---|---|---|---|---|---|
227 | //and that may lead to a deadlock when at the same time a storing is requested | 227 | //and that may lead to a deadlock when at the same time a storing is requested | ||
228 | return d->m_path; | 228 | return d->m_path; | ||
229 | } | 229 | } | ||
230 | 230 | | |||
231 | void ItemRepositoryRegistryPrivate::lockForWriting() | 231 | void ItemRepositoryRegistryPrivate::lockForWriting() | ||
232 | { | 232 | { | ||
233 | QMutexLocker lock(&m_mutex); | 233 | QMutexLocker lock(&m_mutex); | ||
234 | //Create is_writing | 234 | //Create is_writing | ||
235 | QFile f(m_path + "/is_writing"); | 235 | QFile f(m_path + QLatin1String("/is_writing")); | ||
236 | f.open(QIODevice::WriteOnly); | 236 | f.open(QIODevice::WriteOnly); | ||
237 | f.close(); | 237 | f.close(); | ||
238 | } | 238 | } | ||
239 | 239 | | |||
240 | void ItemRepositoryRegistry::lockForWriting() | 240 | void ItemRepositoryRegistry::lockForWriting() | ||
241 | { | 241 | { | ||
242 | d->lockForWriting(); | 242 | d->lockForWriting(); | ||
243 | } | 243 | } | ||
244 | 244 | | |||
245 | void ItemRepositoryRegistryPrivate::unlockForWriting() | 245 | void ItemRepositoryRegistryPrivate::unlockForWriting() | ||
246 | { | 246 | { | ||
247 | QMutexLocker lock(&m_mutex); | 247 | QMutexLocker lock(&m_mutex); | ||
248 | //Delete is_writing | 248 | //Delete is_writing | ||
249 | QFile::remove(m_path + "/is_writing"); | 249 | QFile::remove(m_path + QLatin1String("/is_writing")); | ||
250 | } | 250 | } | ||
251 | 251 | | |||
252 | void ItemRepositoryRegistry::unlockForWriting() | 252 | void ItemRepositoryRegistry::unlockForWriting() | ||
253 | { | 253 | { | ||
254 | d->unlockForWriting(); | 254 | d->unlockForWriting(); | ||
255 | } | 255 | } | ||
256 | 256 | | |||
257 | void ItemRepositoryRegistry::unRegisterRepository(AbstractItemRepository* repository) | 257 | void ItemRepositoryRegistry::unRegisterRepository(AbstractItemRepository* repository) | ||
Show All 40 Lines | 284 | { | |||
298 | foreach(AbstractItemRepository* repository, m_repositories.keys()) { | 298 | foreach(AbstractItemRepository* repository, m_repositories.keys()) { | ||
299 | if(!repository->open(path)) { | 299 | if(!repository->open(path)) { | ||
300 | deleteDataDirectory(path); | 300 | deleteDataDirectory(path); | ||
301 | qCritical() << "failed to open a repository"; | 301 | qCritical() << "failed to open a repository"; | ||
302 | abort(); | 302 | abort(); | ||
303 | } | 303 | } | ||
304 | } | 304 | } | ||
305 | 305 | | |||
306 | QFile f(path + "/Counters"); | 306 | QFile f(path + QLatin1String("/Counters")); | ||
307 | if(f.open(QIODevice::ReadOnly)) { | 307 | if(f.open(QIODevice::ReadOnly)) { | ||
308 | QDataStream stream(&f); | 308 | QDataStream stream(&f); | ||
309 | 309 | | |||
310 | while(!stream.atEnd()) { | 310 | while(!stream.atEnd()) { | ||
311 | //Read in all custom counter values | 311 | //Read in all custom counter values | ||
312 | QString counterName; | 312 | QString counterName; | ||
313 | stream >> counterName; | 313 | stream >> counterName; | ||
314 | int counterValue; | 314 | int counterValue; | ||
Show All 17 Lines | 326 | { | |||
332 | QFile versionFile(d->m_path + QStringLiteral("/version_%1").arg(staticItemRepositoryVersion())); | 332 | QFile versionFile(d->m_path + QStringLiteral("/version_%1").arg(staticItemRepositoryVersion())); | ||
333 | if(versionFile.open(QIODevice::WriteOnly)) { | 333 | if(versionFile.open(QIODevice::WriteOnly)) { | ||
334 | versionFile.close(); | 334 | versionFile.close(); | ||
335 | } else { | 335 | } else { | ||
336 | qCWarning(SERIALIZATION) << "Could not open version file for writing"; | 336 | qCWarning(SERIALIZATION) << "Could not open version file for writing"; | ||
337 | } | 337 | } | ||
338 | 338 | | |||
339 | //Store all custom counter values | 339 | //Store all custom counter values | ||
340 | QFile f(d->m_path + "/Counters"); | 340 | QFile f(d->m_path + QLatin1String("/Counters")); | ||
341 | if(f.open(QIODevice::WriteOnly)) { | 341 | if(f.open(QIODevice::WriteOnly)) { | ||
342 | f.resize(0); | 342 | f.resize(0); | ||
343 | QDataStream stream(&f); | 343 | QDataStream stream(&f); | ||
344 | for(QMap<QString, QAtomicInt*>::const_iterator it = d->m_customCounters.constBegin(); | 344 | for(QMap<QString, QAtomicInt*>::const_iterator it = d->m_customCounters.constBegin(); | ||
345 | it != d->m_customCounters.constEnd(); | 345 | it != d->m_customCounters.constEnd(); | ||
346 | ++it) { | 346 | ++it) { | ||
347 | stream << it.key(); | 347 | stream << it.key(); | ||
348 | stream << it.value()->fetchAndAddRelaxed(0); | 348 | stream << it.value()->fetchAndAddRelaxed(0); | ||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |