~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/libs/dimg/ddebug.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.3.2 upstream) (37 hardy)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20080717202539-1bw3w3nrsso7yj4z
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2006-06-11
 
7
 * Description : thread safe debugging.
 
8
 *
 
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.
 
12
 *
 
13
 * Copyright (C) 2006-2007 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 
14
 *
 
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)
 
19
 * any later version.
 
20
 *
 
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.
 
25
 *
 
26
 * ============================================================ */
 
27
 
 
28
// Qt includes.
 
29
 
 
30
#include <qmutex.h>
 
31
 
 
32
// Local includes.
 
33
 
 
34
#include "ddebug.h"
 
35
 
 
36
#undef DDebug
 
37
#undef kdDebug
 
38
 
 
39
namespace Digikam
 
40
{
 
41
 
 
42
//static KStaticDeleter<QMutex> deleter;
 
43
static QMutex *_ddebug_mutex_ = 0;
 
44
 
 
45
Ddbgstream::Ddbgstream(kdbgstream stream)
 
46
          : kdbgstream(stream)
 
47
{
 
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.
 
50
    if (!_ddebug_mutex_)
 
51
    {
 
52
        // leak the mutex object for simplicity
 
53
        _ddebug_mutex_ = new QMutex;
 
54
        //deleter.setObject(mutex, new QMutex);
 
55
        //KGlobal::unregisterStaticDeleter(&deleter);
 
56
    }
 
57
    _ddebug_mutex_->lock();
 
58
}
 
59
 
 
60
Ddbgstream::~Ddbgstream()
 
61
{
 
62
    _ddebug_mutex_->unlock();
 
63
}
 
64
 
 
65
Dndbgstream::Dndbgstream(kndbgstream stream)
 
66
           : kndbgstream(stream)
 
67
{
 
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.
 
70
    if (!_ddebug_mutex_)
 
71
    {
 
72
        // leak the mutex object for simplicity
 
73
        _ddebug_mutex_ = new QMutex;
 
74
        //deleter.setObject(mutex, new QMutex);
 
75
        //KGlobal::unregisterStaticDeleter(&deleter);
 
76
    }
 
77
    _ddebug_mutex_->lock();
 
78
}
 
79
 
 
80
Dndbgstream::~Dndbgstream()
 
81
{
 
82
    _ddebug_mutex_->unlock();
 
83
}
 
84
 
 
85
} // namespace Digikam
 
86
 
 
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)); }
 
90
 
 
91
Digikam::Dndbgstream DnDebug(int area) { return Digikam::Dndbgstream(kndDebug(area)); }
 
92