1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #4651

anthony.bilinski (1):
      fix(init): register AV connects and call after AV is ready
This commit is contained in:
sudden6 2017-10-15 18:26:22 +02:00
commit 6479b2c0e8
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
3 changed files with 11 additions and 2 deletions

View File

@ -248,6 +248,10 @@ void Core::makeAv()
qCritical() << "Toxav core failed to start";
emit failedToStart();
}
for (const auto& callback : toCallWhenAvReady) {
callback(av);
}
toCallWhenAvReady.clear();
}
/**
@ -1371,6 +1375,10 @@ bool Core::isReady() const
return av && av->getToxAv() && tox && ready;
}
void Core::callWhenAvReady(std::function<void(CoreAV* av)>&& toCall)
{
toCallWhenAvReady.emplace_back(std::move(toCall));
}
/**
* @brief Sets the NoSpam value to prevent friend request spam

View File

@ -73,6 +73,7 @@ public:
QPair<QByteArray, QByteArray> getKeypair() const;
bool isReady() const;
void callWhenAvReady(std::function<void(CoreAV* av)>&& toCall);
void sendFile(uint32_t friendId, QString filename, QString filePath, long long filesize);
@ -226,6 +227,7 @@ private:
QMutex messageSendMutex;
bool ready;
const ICoreSettings* const s;
std::vector<std::function<void(CoreAV* av)>> toCallWhenAvReady;
static QThread* coreThread;

View File

@ -242,9 +242,8 @@ void Widget::init()
connect(profile, &Profile::selfAvatarChanged, profileForm, &ProfileForm::onSelfAvatarLoaded);
const Settings& s = Settings::getInstance();
CoreAV* av = core->getAv();
connect(av, &CoreAV::avEnd, this, &Widget::onCallEnd);
core->callWhenAvReady([this](CoreAV* av){connect(av, &CoreAV::avEnd, this, &Widget::onCallEnd);});
connect(core, &Core::fileDownloadFinished, filesForm, &FilesForm::onFileDownloadComplete);
connect(core, &Core::fileUploadFinished, filesForm, &FilesForm::onFileUploadComplete);
connect(ui->addButton, &QPushButton::clicked, this, &Widget::onAddClicked);