Commit 0a8e6315 authored by Alexander Akulich's avatar Alexander Akulich
Browse files

MainLogModel: Processing SQL query only on account manager ready

parent 06c5941e
......@@ -28,6 +28,7 @@
#include <TelepathyQt/AccountManager>
#include <TelepathyQt/PendingOperation>
#include <TelepathyQt/PendingChannel>
#include <TelepathyQt/PendingReady>
#include <TelepathyQt/TextChannel>
#include <TelepathyQt/Channel>
#include <TelepathyQt/ChannelClassSpecList>
......@@ -116,6 +117,15 @@ MainLogModel::~MainLogModel()
}
void MainLogModel::onAccountManagerReady()
{
if (!m_accountManager->isReady()) {
qWarning() << "Unable to initialize account manager";
return;
}
processQueryResults(m_query);
}
void MainLogModel::processQueryResults(QSqlQuery query)
{
while (query.next()) {
......@@ -304,7 +314,14 @@ void MainLogModel::setAccountManager(const Tp::AccountManagerPtr &accountManager
{
m_accountManager = accountManager;
processQueryResults(m_query);
if (m_accountManager) {
if (m_accountManager->isReady()) {
onAccountManagerReady();
} else {
Tp::PendingOperation *readyOp = m_accountManager->becomeReady();
connect(readyOp, &Tp::PendingOperation::finished, this, &MainLogModel::onAccountManagerReady);
}
}
}
QObject* MainLogModel::observerProxy() const
......
......@@ -125,6 +125,7 @@ public Q_SLOTS:
private Q_SLOTS:
void handleChannel(const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel);
void onConversationChanged();
void onAccountManagerReady();
private:
void setupSignals(Conversation *conversation) const;
......
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