1
/* This file is part of the KDE project
2
Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
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.
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.
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.
20
#ifndef PHONON_KEEPREFERENCE_H
21
#define PHONON_KEEPREFERENCE_H
23
#include <QtCore/QExplicitlySharedDataPointer>
24
#include <QtCore/QObject>
25
#include <QtGui/QApplication>
26
#include "shareddata.h"
27
#include "xinethread.h"
34
template<int TIME = 10000>
35
class KeepReference : public QObject
38
inline KeepReference()
40
//moveToThread(QApplication::instance()->thread());
41
moveToThread(XineThread::instance());
42
Backend::addCleanupObject(this);
45
inline ~KeepReference() { Backend::removeCleanupObject(this); }
47
inline void addObject(SharedData *o) { objects << QExplicitlySharedDataPointer<SharedData>(o); }
49
// do this so that startTimer is called from the correct thread
50
QCoreApplication::postEvent(this, new QEvent(static_cast<QEvent::Type>(2345)));
56
if (e->type() == 2345) {
61
return QObject::event(e);
64
void timerEvent(QTimerEvent *e)
66
killTimer(e->timerId());
71
QList<QExplicitlySharedDataPointer<SharedData> > objects;
77
#endif // PHONON_KEEPREFERENCE_H