summaryrefslogtreecommitdiffstats
path: root/src/core/jobs
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2014-11-02 20:39:03 +0000
committerSean Harmer <sean.harmer@kdab.com>2014-11-03 17:42:51 +0100
commitea3f99ebe1c846f46fa73d86aa65c4d660a848c4 (patch)
tree4d97dd34a99cec4e7ed56a872fb9d64dbb19d68a /src/core/jobs
parent46c7d625c0ffe6ec609efdb28a0ea5e065e48bb3 (diff)
More work towards a clean shutdown
The QAspectJobManager doesn't really need to be public now I think but as it still is let's make the base class have it's own private class that inherits from QObjectPrivate. The ThreadWeaver threads all get cleaned up cleanly upon shutdown. When trying with cylinder-cpp with all the rendering stuff in main() commented out, we consistently get the crash in QFontCache. With the rendering stuff enabled there is also an assert inside the swapbuffers() call. This is because the render thread is not cleanly shutdown yet. The QFontCache crash is something to do with freeing thread-local storage. I will continue to investigate. Change-Id: Ib3ad3ea04ae4859d27f0dd4604b00bc5a38859a1 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/core/jobs')
-rw-r--r--src/core/jobs/jobs.pri8
-rw-r--r--src/core/jobs/qabstractaspectjobmanager.cpp61
-rw-r--r--src/core/jobs/qabstractaspectjobmanager.h (renamed from src/core/jobs/qaspectjobmanagerinterface.h)18
-rw-r--r--src/core/jobs/qabstractaspectjobmanager_p.h65
-rw-r--r--src/core/jobs/qaspectjobmanager.cpp12
-rw-r--r--src/core/jobs/qaspectjobmanager.h5
-rw-r--r--src/core/jobs/qaspectjobmanager_p.h6
7 files changed, 153 insertions, 22 deletions
diff --git a/src/core/jobs/jobs.pri b/src/core/jobs/jobs.pri
index 591508523..8c286bfe3 100644
--- a/src/core/jobs/jobs.pri
+++ b/src/core/jobs/jobs.pri
@@ -2,15 +2,17 @@
SOURCES += \
$$PWD/weaverjob.cpp \
$$PWD/qaspectjob.cpp \
- $$PWD/qaspectjobmanager.cpp
+ $$PWD/qaspectjobmanager.cpp \
+ $$PWD/qabstractaspectjobmanager.cpp
HEADERS += \
$$PWD/weaverjob_p.h \
$$PWD/qaspectjob.h \
$$PWD/qaspectjob_p.h \
- $$PWD/qaspectjobmanagerinterface.h \
+ $$PWD/qabstractaspectjobmanager.h \
$$PWD/qaspectjobproviderinterface.h \
$$PWD/qaspectjobmanager.h \
- $$PWD/qaspectjobmanager_p.h
+ $$PWD/qaspectjobmanager_p.h \
+ $$PWD/qabstractaspectjobmanager_p.h
INCLUDEPATH += $$PWD
diff --git a/src/core/jobs/qabstractaspectjobmanager.cpp b/src/core/jobs/qabstractaspectjobmanager.cpp
new file mode 100644
index 000000000..b276280fb
--- /dev/null
+++ b/src/core/jobs/qabstractaspectjobmanager.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qabstractaspectjobmanager.h"
+#include "qabstractaspectjobmanager_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+QAbstractAspectJobManager::QAbstractAspectJobManager(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QAbstractAspectJobManager::QAbstractAspectJobManager(QAbstractAspectJobManagerPrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/core/jobs/qaspectjobmanagerinterface.h b/src/core/jobs/qabstractaspectjobmanager.h
index 108a8c2bb..707b69e00 100644
--- a/src/core/jobs/qaspectjobmanagerinterface.h
+++ b/src/core/jobs/qabstractaspectjobmanager.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QT3D_QASPECTJOBMANAGERINTERFACE_H
-#define QT3D_QASPECTJOBMANAGERINTERFACE_H
+#ifndef QT3D_QABSTRACTASPECTJOBMANAGER_H
+#define QT3D_QABSTRACTASPECTJOBMANAGER_H
#include <QObject>
@@ -50,13 +50,13 @@ QT_BEGIN_NAMESPACE
namespace Qt3D {
-class QAspectJobManagerInterface : public QObject
+class QAbstractAspectJobManagerPrivate;
+
+class QAbstractAspectJobManager : public QObject
{
Q_OBJECT
public:
- explicit QAspectJobManagerInterface(QObject *p = 0)
- : QObject(p)
- {}
+ explicit QAbstractAspectJobManager(QObject *p = 0);
virtual void initialize() {}
virtual void enqueueJobs(const QVector<QAspectJobPtr> &jobQueue) = 0;
@@ -65,10 +65,14 @@ public:
// Callback signature for running SynchronizedJobs
typedef void (*JobFunction)(void *);
virtual void waitForPerThreadFunction(JobFunction func, void *arg) = 0;
+
+protected:
+ QAbstractAspectJobManager(QAbstractAspectJobManagerPrivate &dd, QObject *parent);
+ Q_DECLARE_PRIVATE(QAbstractAspectJobManager)
};
} // namespace Qt3D
QT_END_NAMESPACE
-#endif // QT3D_QASPECTJOBMANAGERINTERFACE_H
+#endif // QT3D_QABSTRACTASPECTJOBMANAGER_H
diff --git a/src/core/jobs/qabstractaspectjobmanager_p.h b/src/core/jobs/qabstractaspectjobmanager_p.h
new file mode 100644
index 000000000..f5ac5d0c3
--- /dev/null
+++ b/src/core/jobs/qabstractaspectjobmanager_p.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTASPECTJOBMANAGER_P_H
+#define QABSTRACTASPECTJOBMANAGER_P_H
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QAbstractAspectJobManager;
+
+class QAbstractAspectJobManagerPrivate : public QObjectPrivate
+{
+public:
+ QAbstractAspectJobManagerPrivate()
+ : QObjectPrivate()
+ {}
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QABSTRACTASPECTJOBMANAGER_P_H
diff --git a/src/core/jobs/qaspectjobmanager.cpp b/src/core/jobs/qaspectjobmanager.cpp
index b8b8da83d..8c4e8c921 100644
--- a/src/core/jobs/qaspectjobmanager.cpp
+++ b/src/core/jobs/qaspectjobmanager.cpp
@@ -62,7 +62,7 @@ namespace {
class SynchronizedJob : public ThreadWeaver::Job
{
public:
- SynchronizedJob(QAspectJobManagerInterface::JobFunction func, void *arg, QAtomicInt *atomicCount)
+ SynchronizedJob(QAbstractAspectJobManager::JobFunction func, void *arg, QAtomicInt *atomicCount)
: m_func(func)
, m_arg(arg)
, m_atomicCount(atomicCount)
@@ -72,7 +72,7 @@ protected:
void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread *thread) Q_DECL_OVERRIDE;
private:
- QAspectJobManagerInterface::JobFunction m_func;
+ QAbstractAspectJobManager::JobFunction m_func;
void *m_arg;
QAtomicInt *m_atomicCount;
};
@@ -99,15 +99,14 @@ void SynchronizedJob::run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread *t
} // anonymous
QAspectJobManagerPrivate::QAspectJobManagerPrivate(QAspectJobManager *qq)
- : QObjectPrivate()
+ : QAbstractAspectJobManagerPrivate()
, q_ptr(qq)
, m_weaver(Q_NULLPTR)
{
}
QAspectJobManager::QAspectJobManager(QObject *parent)
- : QAspectJobManagerInterface(parent)
- , d_ptr(new QAspectJobManagerPrivate(this))
+ : QAbstractAspectJobManager(*new QAspectJobManagerPrivate(this), parent)
{
Q_D(QAspectJobManager);
d->m_weaver = new ThreadWeaver::Queue(this);
@@ -115,8 +114,7 @@ QAspectJobManager::QAspectJobManager(QObject *parent)
}
QAspectJobManager::QAspectJobManager(QAspectJobManagerPrivate &dd, QObject *parent)
- : QAspectJobManagerInterface(parent)
- , d_ptr(&dd)
+ : QAbstractAspectJobManager(dd, parent)
{
Q_D(QAspectJobManager);
d->m_weaver = new ThreadWeaver::Queue(this);
diff --git a/src/core/jobs/qaspectjobmanager.h b/src/core/jobs/qaspectjobmanager.h
index c4c6d4aef..08ae6b7e9 100644
--- a/src/core/jobs/qaspectjobmanager.h
+++ b/src/core/jobs/qaspectjobmanager.h
@@ -42,7 +42,7 @@
#ifndef QT3D_QASPECTJOBMANAGER_H
#define QT3D_QASPECTJOBMANAGER_H
-#include <Qt3DCore/qaspectjobmanagerinterface.h>
+#include <Qt3DCore/qabstractaspectjobmanager.h>
#include <Qt3DCore/qt3dcore_global.h>
#include <Qt3DCore/qaspectjob.h>
@@ -55,7 +55,7 @@ namespace Qt3D {
class QAspectJobManagerPrivate;
-class QAspectJobManager : public QAspectJobManagerInterface
+class QAspectJobManager : public QAbstractAspectJobManager
{
Q_OBJECT
public:
@@ -72,7 +72,6 @@ public:
protected:
QAspectJobManager(QAspectJobManagerPrivate &dd, QObject *parent);
Q_DECLARE_PRIVATE(QAspectJobManager)
- QAspectJobManagerPrivate *d_ptr;
};
} // namespace Qt3D
diff --git a/src/core/jobs/qaspectjobmanager_p.h b/src/core/jobs/qaspectjobmanager_p.h
index 241a19579..789e52b9d 100644
--- a/src/core/jobs/qaspectjobmanager_p.h
+++ b/src/core/jobs/qaspectjobmanager_p.h
@@ -42,7 +42,7 @@
#ifndef QT3D_QASPECTJOBMANAGER_P_H
#define QT3D_QASPECTJOBMANAGER_P_H
-#include <private/qobject_p.h>
+#include <private/qabstractaspectjobmanager_p.h>
namespace ThreadWeaver {
class Queue;
@@ -54,13 +54,15 @@ namespace Qt3D {
class QAspectJobManager;
-class QAspectJobManagerPrivate : public QObjectPrivate
+class QAspectJobManagerPrivate : public QAbstractAspectJobManagerPrivate
{
public:
QAspectJobManagerPrivate(QAspectJobManager *qq);
Q_DECLARE_PUBLIC(QAspectJobManager)
QAspectJobManager *q_ptr;
+
+ // Owned by QAspectJobManager via QObject parent-child
ThreadWeaver::Queue *m_weaver;
};