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

refactor: remove unneeded busy waiting code

This commit is contained in:
sudden6 2018-10-31 01:47:45 +01:00
parent bc3d3b3b13
commit a3344a127f
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
4 changed files with 2 additions and 35 deletions

View File

@ -56,18 +56,12 @@ bool handleToxURI(const QString& toxURI)
Core* core = nexus.getCore();
while (!core) {
if (!nexus.isRunning())
return false;
core = nexus.getCore();
qApp->processEvents();
QThread::msleep(10);
}
while (!core->isReady()) {
if (!nexus.isRunning())
return false;
qApp->processEvents();
QThread::msleep(10);
}

View File

@ -60,7 +60,6 @@ Nexus::Nexus(QObject* parent)
: QObject(parent)
, profile{nullptr}
, widget{nullptr}
, running{true}
{}
Nexus::~Nexus()
@ -231,21 +230,9 @@ void Nexus::showMainGUI()
*/
void Nexus::quit()
{
running = false;
qApp->quit();
}
/**
* @brief Returns true until Nexus::quit is called.
*
* Any blocking processEvents() loop should check this as a return condition,
* since the application can not quit until control is returned to the event loop.
*/
bool Nexus::isRunning()
{
return running;
}
/**
* @brief Returns the singleton instance.
*/

View File

@ -43,7 +43,6 @@ public:
void start();
void showMainGUI();
void quit();
bool isRunning();
static Nexus& getInstance();
static void destroyInstance();
@ -91,7 +90,6 @@ private:
private:
Profile* profile;
Widget* widget;
bool running;
};
#endif // NEXUS_H

View File

@ -18,17 +18,15 @@
*/
#include "toxsave.h"
#include "src/core/core.h"
#include "src/persistence/settings.h"
#include "src/widget/gui.h"
#include "src/widget/tool/profileimporter.h"
#include <QCoreApplication>
#include <QFileInfo>
bool toxSaveEventHandler(const QByteArray& eventData)
{
if (!eventData.endsWith(".tox"))
if (!eventData.endsWith(".tox")) {
return false;
}
handleToxSave(eventData);
return true;
@ -42,16 +40,6 @@ bool toxSaveEventHandler(const QByteArray& eventData)
*/
bool handleToxSave(const QString& path)
{
Core* core = Core::getInstance();
while (!core) {
core = Core::getInstance();
qApp->processEvents();
}
while (!core->isReady())
qApp->processEvents();
ProfileImporter importer(GUI::getMainWidget());
return importer.importProfile(path);
}