1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : thread safe debugging.
9
* See B.K.O #133026: because kdDebug() is not thread-safe
10
* we need to use a dedicaced debug statements in threaded
11
* implementation to prevent crash.
13
* Copyright (C) 2006-2007 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
15
* This program is free software; you can redistribute it
16
* and/or modify it under the terms of the GNU General
17
* Public License as published by the Free Software Foundation;
18
* either version 2, or (at your option)
21
* This program is distributed in the hope that it will be useful,
22
* but WITHOUT ANY WARRANTY; without even the implied warranty of
23
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
* GNU General Public License for more details.
26
* ============================================================ */
42
//static KStaticDeleter<QMutex> deleter;
43
static QMutex *_ddebug_mutex_ = 0;
45
Ddbgstream::Ddbgstream(kdbgstream stream)
48
// using a static variable here - we can safely assume that kdDebug
49
// is called at least once from the main thread before threads start.
52
// leak the mutex object for simplicity
53
_ddebug_mutex_ = new QMutex;
54
//deleter.setObject(mutex, new QMutex);
55
//KGlobal::unregisterStaticDeleter(&deleter);
57
_ddebug_mutex_->lock();
60
Ddbgstream::~Ddbgstream()
62
_ddebug_mutex_->unlock();
65
Dndbgstream::Dndbgstream(kndbgstream stream)
68
// using a static variable here - we can safely assume that kdDebug
69
// is called at least once from the main thread before threads start.
72
// leak the mutex object for simplicity
73
_ddebug_mutex_ = new QMutex;
74
//deleter.setObject(mutex, new QMutex);
75
//KGlobal::unregisterStaticDeleter(&deleter);
77
_ddebug_mutex_->lock();
80
Dndbgstream::~Dndbgstream()
82
_ddebug_mutex_->unlock();
85
} // namespace Digikam
87
Digikam::Ddbgstream DDebug(int area) { return Digikam::Ddbgstream(kdDebug(area)); }
88
Digikam::Ddbgstream DError(int area) { return Digikam::Ddbgstream(kdError(area)); }
89
Digikam::Ddbgstream DWarning(int area) { return Digikam::Ddbgstream(kdWarning(area)); }
91
Digikam::Dndbgstream DnDebug(int area) { return Digikam::Dndbgstream(kndDebug(area)); }