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()}; QMutexLocker ml{coreLoopLock.get()};
if (!isReady()) {
return;
}
if (!tox_friend_delete(tox.get(), friendId, nullptr)) { if (!tox_friend_delete(tox.get(), friendId, nullptr)) {
emit failedToRemoveFriend(friendId); emit failedToRemoveFriend(friendId);
return; return;
@ -828,10 +824,6 @@ void Core::removeGroup(int groupId)
{ {
QMutexLocker ml{coreLoopLock.get()}; QMutexLocker ml{coreLoopLock.get()};
if (!isReady()) {
return;
}
Tox_Err_Conference_Delete error; Tox_Err_Conference_Delete error;
bool success = tox_conference_delete(tox.get(), groupId, &error); bool success = tox_conference_delete(tox.get(), groupId, &error);
if (success && error == TOX_ERR_CONFERENCE_DELETE_OK) { if (success && error == TOX_ERR_CONFERENCE_DELETE_OK) {
@ -1528,14 +1520,6 @@ QString Core::getPeerName(const ToxPk& id) const
return name; 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 * @brief Sets the NoSpam value to prevent friend request spam
* @param nospam an arbitrary which becomes part of the Tox ID * @param nospam an arbitrary which becomes part of the Tox ID

View File

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

View File

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

View File

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

View File

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