Improve stability.

This commit is contained in:
Black Hat 2018-11-06 09:36:17 +08:00
parent 64603b47c6
commit 6e44347efd
4 changed files with 16 additions and 8 deletions

View File

@ -40,7 +40,12 @@ Controller::Controller(QObject* parent)
QTimer::singleShot(0, this, SLOT(invokeLogin()));
}
Controller::~Controller() {}
Controller::~Controller() {
for (auto c : qAsConst(m_connections)) {
c->saveState();
c->stopSync();
}
}
inline QString accessTokenFileName(const AccountSettings& account) {
QString fileName = account.userId();
@ -104,10 +109,7 @@ void Controller::addConnection(Connection* c) {
m_connections.push_back(c);
connect(c, &Connection::syncDone, this, [=] {
c->saveState();
c->sync(30000);
});
connect(c, &Connection::syncDone, this, [=] { c->sync(30000); });
connect(c, &Connection::loggedOut, this, [=] { dropConnection(c); });
using namespace QMatrixClient;

View File

@ -8,6 +8,7 @@ class Paintable : public QObject {
Q_OBJECT
public:
Paintable(QObject* parent = nullptr);
virtual ~Paintable() = default;
virtual QImage image(int) = 0;
virtual QImage image(int, int) = 0;

View File

@ -18,11 +18,16 @@ class RoomPaintable : public Paintable {
}
QImage image(int dimension) override {
if (!m_room) return QImage();
if (!m_room) {
qDebug() << "Room is null";
return QImage();
}
return m_room->avatar(dimension);
}
QImage image(int width, int height) override {
if (!m_room) return QImage();
if (!m_room) {
return QImage();
}
return m_room->avatar(width, height);
}

View File

@ -18,7 +18,7 @@ void UserListModel::setRoom(QMatrixClient::Room* room) {
using namespace QMatrixClient;
beginResetModel();
if (m_currentRoom) {
if (m_currentRoom && m_currentRoom->connection()) {
m_currentRoom->connection()->disconnect(this);
m_currentRoom->disconnect(this);
for (User* user : m_users) user->disconnect(this);