Commit fdcc05bf authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Explicitly set CppOwnership

Avoid that the QQmlEngine assumes ownership on backend objects
and eventually destroys them, even if the memory management logic
is completely in the backend.
parent aa81208b
......@@ -34,7 +34,8 @@ class EditableCourseStub : public IEditableCourse
{
public:
EditableCourseStub(Language *language, QVector<Unit *> units)
: m_language(language)
: IEditableCourse()
, m_language(language)
, m_units(units)
{
}
......@@ -228,5 +229,4 @@ void TestEditorSession::skeletonSwitchingBehavior()
QCOMPARE(session.language()->id(), languageGerman.id());
}
QTEST_GUILESS_MAIN(TestEditorSession)
......@@ -31,6 +31,10 @@ class Language;
class ARTIKULATECORE_EXPORT IEditableCourse : public ICourse
{
public:
IEditableCourse(QObject *parent = nullptr)
: ICourse(parent)
{
}
virtual ~IEditableCourse() = default;
virtual void setId(QString id) = 0;
virtual void setForeignId(QString foreignId) = 0;
......
......@@ -28,6 +28,7 @@
#include "core/language.h"
#include "core/iresourcerepository.h"
#include <QQmlEngine>
#include <QXmlSchema>
#include <QXmlStreamReader>
#include <QDomDocument>
......@@ -129,6 +130,7 @@ CourseResource::CourseResource(const QUrl &path, IResourceRepository *repository
: ICourse(repository)
, d(new CourseResourcePrivate())
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
d->m_file = path;
d->m_repository = repository;
......
......@@ -26,6 +26,7 @@
#include "core/phoneme.h"
#include <QObject>
#include <QQmlEngine>
#include <QDomDocument>
#include <QDir>
#include <QFile>
......@@ -35,8 +36,10 @@
#include <KLocalizedString>
EditableCourseResource::EditableCourseResource(const QUrl &path, IResourceRepository *repository)
: m_course(new CourseResource(path, repository))
: IEditableCourse()
, m_course(new CourseResource(path, repository))
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
connect(m_course.get(), &ICourse::unitAboutToBeAdded, this, &ICourse::unitAboutToBeAdded);
connect(m_course.get(), &ICourse::unitAdded, this, &ICourse::unitAdded);
connect(m_course.get(), &CourseResource::idChanged, this, &EditableCourseResource::idChanged);
......
......@@ -131,6 +131,7 @@ Q_SIGNALS:
void languageChanged();
private:
Q_DISABLE_COPY(EditableCourseResource)
bool m_modified{ false };
const std::unique_ptr<CourseResource> m_course;
};
......
......@@ -28,6 +28,7 @@
#include "core/resources/languageresource.h"
#include <QDir>
#include <QQmlEngine>
#include <QDomDocument>
#include <QIODevice>
#include <QXmlStreamReader>
......@@ -183,6 +184,7 @@ SkeletonResource::SkeletonResource(const QUrl &path, IResourceRepository *reposi
: IEditableCourse()
, d(new SkeletonResourcePrivate(path))
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
Q_UNUSED(repository);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment