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

refactor(core): remove unused function

This function would always return true for any non destroyed Core
object.
This commit is contained in:
sudden6 2019-03-03 22:04:33 +01:00
parent 93a7fdfe03
commit 66f72ee863
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
5 changed files with 9 additions and 34 deletions

View File

@ -811,10 +811,6 @@ void Core::removeFriend(uint32_t friendId)
{
QMutexLocker ml{coreLoopLock.get()};
if (!isReady()) {
return;
}
if (!tox_friend_delete(tox.get(), friendId, nullptr)) {
emit failedToRemoveFriend(friendId);
return;
@ -828,10 +824,6 @@ void Core::removeGroup(int groupId)
{
QMutexLocker ml{coreLoopLock.get()};
if (!isReady()) {
return;
}
Tox_Err_Conference_Delete error;
bool success = tox_conference_delete(tox.get(), groupId, &error);
if (success && error == TOX_ERR_CONFERENCE_DELETE_OK) {
@ -1528,14 +1520,6 @@ QString Core::getPeerName(const ToxPk& id) const
return name;
}
/**
* @brief Most of the API shouldn't be used until Core is ready, call start() first
*/
bool Core::isReady() const
{
return av && tox;
}
/**
* @brief Sets the NoSpam value to prevent friend request spam
* @param nospam an arbitrary which becomes part of the Tox ID

View File

@ -99,8 +99,6 @@ public:
ToxPk getSelfPublicKey() const;
QPair<QByteArray, QByteArray> getKeypair() const;
bool isReady() const;
void sendFile(uint32_t friendId, QString filename, QString filePath, long long filesize);
public slots:

View File

@ -61,11 +61,6 @@ bool handleToxURI(const QString& toxURI)
QThread::msleep(10);
}
while (!core->isReady()) {
qApp->processEvents();
QThread::msleep(10);
}
QString toxaddr = toxURI.mid(4);
ToxId toxId(toxaddr);

View File

@ -233,17 +233,16 @@ Profile* Profile::createProfile(QString name, QString password)
Profile::~Profile()
{
if (!isRemoved && core->isReady()) {
onSaveToxSave();
if (isRemoved) {
return;
}
if (!isRemoved) {
Settings::getInstance().savePersonal(this);
Settings::getInstance().sync();
ProfileLocker::assertLock();
assert(ProfileLocker::getCurLockName() == name);
ProfileLocker::unlock();
}
onSaveToxSave();
Settings::getInstance().savePersonal(this);
Settings::getInstance().sync();
ProfileLocker::assertLock();
assert(ProfileLocker::getCurLockName() == name);
ProfileLocker::unlock();
}
/**
@ -324,7 +323,6 @@ void Profile::startCore()
*/
void Profile::onSaveToxSave()
{
assert(core->isReady());
QByteArray data = core->getToxSaveData();
assert(data.size());
saveToxSave(data);

View File

@ -307,7 +307,7 @@ void AddFriendForm::setIdFromClipboard()
const QString trimmedId = clipboard->text().trimmed();
const QString strippedId = getToxId(trimmedId);
const Core* core = Core::getInstance();
const bool isSelf = core->isReady() && ToxId(strippedId) != core->getSelfId();
const bool isSelf = ToxId(strippedId) != core->getSelfId();
if (!strippedId.isEmpty() && ToxId::isToxId(strippedId) && isSelf) {
toxId.setText(trimmedId);
}