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

Create on stack and avoid leak

parent 3927d343
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
using namespace LearnerProfile; using namespace LearnerProfile;
MainWindow::MainWindow() MainWindow::MainWindow()
: m_profileManager(new LearnerProfile::ProfileManager(this)) : m_profileManager(this)
, m_trainingSession(new TrainingSession(m_profileManager, this)) , m_trainingSession(&m_profileManager, this)
{ {
rootContext()->setContextObject(new KLocalizedContext(this)); rootContext()->setContextObject(new KLocalizedContext(this));
...@@ -40,16 +40,16 @@ MainWindow::MainWindow() ...@@ -40,16 +40,16 @@ MainWindow::MainWindow()
OutputDeviceController::self().setVolume(Settings::audioOutputVolume()); OutputDeviceController::self().setVolume(Settings::audioOutputVolume());
// set view // set view
rootContext()->setContextProperty(QStringLiteral("g_trainingSession"), m_trainingSession); rootContext()->setContextProperty(QStringLiteral("g_trainingSession"), &m_trainingSession);
rootContext()->setContextProperty(QStringLiteral("g_profileManager"), m_profileManager); rootContext()->setContextProperty(QStringLiteral("g_profileManager"), &m_profileManager);
rootContext()->setContextProperty(QStringLiteral("g_artikulateAboutData"), QVariant::fromValue(KAboutData::applicationData())); rootContext()->setContextProperty(QStringLiteral("g_artikulateAboutData"), QVariant::fromValue(KAboutData::applicationData()));
// set starting screen // set starting screen
load(QUrl(QStringLiteral("qrc:/artikulate/qml/Main.qml"))); load(QUrl(QStringLiteral("qrc:/artikulate/qml/Main.qml")));
// create training profile if none exists: // create training profile if none exists:
if (!m_profileManager->activeProfile()) { if (!m_profileManager.activeProfile()) {
m_profileManager->addProfile(i18n("Unnamed Identity")); m_profileManager.addProfile(i18n("Unnamed Identity"));
} }
// connect to QML signals; // connect to QML signals;
...@@ -60,7 +60,7 @@ MainWindow::~MainWindow() ...@@ -60,7 +60,7 @@ MainWindow::~MainWindow()
{ {
// save current settings for case of closing // save current settings for case of closing
Settings::self()->save(); Settings::self()->save();
m_profileManager->sync(); m_profileManager.sync();
} }
void MainWindow::updateCourseResources() void MainWindow::updateCourseResources()
......
...@@ -8,17 +8,10 @@ ...@@ -8,17 +8,10 @@
#define MAINWINDOW_H #define MAINWINDOW_H
#include "core/resourcerepository.h" #include "core/resourcerepository.h"
#include <KActionCollection> #include "core/trainingsession.h"
#include "liblearnerprofile/src/profilemanager.h"
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
class TrainingSession;
class KHelpMenu;
namespace LearnerProfile
{
class ProfileManager;
}
class MainWindow : public QQmlApplicationEngine class MainWindow : public QQmlApplicationEngine
{ {
Q_OBJECT Q_OBJECT
...@@ -45,8 +38,8 @@ public Q_SLOTS: ...@@ -45,8 +38,8 @@ public Q_SLOTS:
void configLearnerProfile(); void configLearnerProfile();
private: private:
LearnerProfile::ProfileManager *m_profileManager; LearnerProfile::ProfileManager m_profileManager;
TrainingSession *m_trainingSession; TrainingSession m_trainingSession;
}; };
#endif #endif
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