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:
commit
6479b2c0e8
|
@ -248,6 +248,10 @@ void Core::makeAv()
|
||||||
qCritical() << "Toxav core failed to start";
|
qCritical() << "Toxav core failed to start";
|
||||||
emit failedToStart();
|
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;
|
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
|
* @brief Sets the NoSpam value to prevent friend request spam
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
QPair<QByteArray, QByteArray> getKeypair() const;
|
QPair<QByteArray, QByteArray> getKeypair() const;
|
||||||
|
|
||||||
bool isReady() const;
|
bool isReady() const;
|
||||||
|
void callWhenAvReady(std::function<void(CoreAV* av)>&& toCall);
|
||||||
|
|
||||||
void sendFile(uint32_t friendId, QString filename, QString filePath, long long filesize);
|
void sendFile(uint32_t friendId, QString filename, QString filePath, long long filesize);
|
||||||
|
|
||||||
|
@ -226,6 +227,7 @@ private:
|
||||||
QMutex messageSendMutex;
|
QMutex messageSendMutex;
|
||||||
bool ready;
|
bool ready;
|
||||||
const ICoreSettings* const s;
|
const ICoreSettings* const s;
|
||||||
|
std::vector<std::function<void(CoreAV* av)>> toCallWhenAvReady;
|
||||||
|
|
||||||
static QThread* coreThread;
|
static QThread* coreThread;
|
||||||
|
|
||||||
|
|
|
@ -242,9 +242,8 @@ void Widget::init()
|
||||||
connect(profile, &Profile::selfAvatarChanged, profileForm, &ProfileForm::onSelfAvatarLoaded);
|
connect(profile, &Profile::selfAvatarChanged, profileForm, &ProfileForm::onSelfAvatarLoaded);
|
||||||
|
|
||||||
const Settings& s = Settings::getInstance();
|
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::fileDownloadFinished, filesForm, &FilesForm::onFileDownloadComplete);
|
||||||
connect(core, &Core::fileUploadFinished, filesForm, &FilesForm::onFileUploadComplete);
|
connect(core, &Core::fileUploadFinished, filesForm, &FilesForm::onFileUploadComplete);
|
||||||
connect(ui->addButton, &QPushButton::clicked, this, &Widget::onAddClicked);
|
connect(ui->addButton, &QPushButton::clicked, this, &Widget::onAddClicked);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user