diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-09-12 17:19:35 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-09-14 09:57:14 +0900 |
commit | c0ddd658bb3e9035eb701c60ea1c82eb6b53114c (patch) | |
tree | 398b30998eb97eb3b41450ea89a69869125504ea | |
parent | 97fe7a952236f56ed128f4356c21b599c4f3a9e4 (diff) | |
download | libquotient-c0ddd658bb3e9035eb701c60ea1c82eb6b53114c.tar.gz libquotient-c0ddd658bb3e9035eb701c60ea1c82eb6b53114c.zip |
Initialize Room::Private more carefully
See https://marcmutz.wordpress.com/translated-articles/pimp-my-pimpl-
%E2%80%94-reloaded
-rw-r--r-- | room.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -47,7 +47,10 @@ class Room::Private /** Map of user names to users. User names potentially duplicate, hence a multi-hashmap. */ typedef QMultiHash<QString, User*> members_map_t; - Private(Room* parent): q(parent) {} + Private(Connection* c, const QString& id_) + : q(nullptr), connection(c), id(id_), joinState(JoinState::Join) + , roomMessagesJob(nullptr) + { } Room* q; @@ -96,12 +99,11 @@ class Room::Private }; Room::Room(Connection* connection, QString id) - : QObject(connection), d(new Private(this)) + : QObject(connection), d(new Private(connection, id)) { - d->id = id; - d->connection = connection; - d->joinState = JoinState::Join; - d->roomMessagesJob = nullptr; + // See "Accessing the Public Class" section in + // https://marcmutz.wordpress.com/translated-articles/pimp-my-pimpl-%E2%80%94-reloaded/ + d->q = this; qDebug() << "New Room:" << id; //connection->getMembers(this); // I don't think we need this anymore in r0.0.1 |