~ubuntu-branches/ubuntu/oneiric/phonon/oneiric-201108111512

« back to all changes in this revision

Viewing changes to xine/keepreference.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2011-01-24 10:12:11 UTC
  • mfrom: (0.5.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110124101211-w9rew7q0dmwbwhqx
Tags: 4:4.7.0really4.4.4-0ubuntu1
* New upstream release
* Xine and GStreamer backends now split out source, remove build-deps and
  binary packages from debian/control
* Remove 02_no_rpath.patch, now upstream
* Disable kubuntu04_no_va_mangle.patch, no longer applies
* Remove kubuntu_05_gst_codec_installer_window_id.diff, kubuntu_06_forward_events.diff,
  kubuntu_07_include_fix.diff, gstreamer now separate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  This file is part of the KDE project
2
 
    Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
3
 
 
4
 
    This library is free software; you can redistribute it and/or
5
 
    modify it under the terms of the GNU Library General Public
6
 
    License version 2 as published by the Free Software Foundation.
7
 
 
8
 
    This library is distributed in the hope that it will be useful,
9
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
 
    Library General Public License for more details.
12
 
 
13
 
    You should have received a copy of the GNU Library General Public License
14
 
    along with this library; see the file COPYING.LIB.  If not, write to
15
 
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
 
    Boston, MA 02110-1301, USA.
17
 
 
18
 
*/
19
 
 
20
 
#ifndef PHONON_KEEPREFERENCE_H
21
 
#define PHONON_KEEPREFERENCE_H
22
 
 
23
 
#include <QtCore/QExplicitlySharedDataPointer>
24
 
#include <QtCore/QObject>
25
 
#include <QtGui/QApplication>
26
 
#include "shareddata.h"
27
 
#include "xinethread.h"
28
 
 
29
 
namespace Phonon
30
 
{
31
 
namespace Xine
32
 
{
33
 
 
34
 
template<int TIME = 10000>
35
 
class KeepReference : public QObject
36
 
{
37
 
    public:
38
 
        inline KeepReference()
39
 
        {
40
 
            //moveToThread(QApplication::instance()->thread());
41
 
            moveToThread(XineThread::instance());
42
 
            Backend::addCleanupObject(this);
43
 
        }
44
 
 
45
 
        inline ~KeepReference() { Backend::removeCleanupObject(this); }
46
 
 
47
 
        inline void addObject(SharedData *o) { objects << QExplicitlySharedDataPointer<SharedData>(o); }
48
 
        inline void ready() {
49
 
            // do this so that startTimer is called from the correct thread
50
 
            QCoreApplication::postEvent(this, new QEvent(static_cast<QEvent::Type>(2345)));
51
 
        }
52
 
 
53
 
    protected:
54
 
        bool event(QEvent *e)
55
 
        {
56
 
            if (e->type() == 2345) {
57
 
                e->accept();
58
 
                startTimer(TIME);
59
 
                return true;
60
 
            }
61
 
            return QObject::event(e);
62
 
        }
63
 
 
64
 
        void timerEvent(QTimerEvent *e)
65
 
        {
66
 
            killTimer(e->timerId());
67
 
            deleteLater();
68
 
        }
69
 
 
70
 
    private:
71
 
        QList<QExplicitlySharedDataPointer<SharedData> > objects;
72
 
};
73
 
 
74
 
 
75
 
} // namespace Xine
76
 
} // namespace Phonon
77
 
#endif // PHONON_KEEPREFERENCE_H