Skip to content

Commit

Permalink
Remove sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
issakomi committed May 18, 2024
1 parent 39acab9 commit 625e901
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions GUI/aliza.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
#include <QDir>
#include <QColorDialog>
#include <QDateTime>
#include <QEventLoop>
#include <string>
#include <array>
#ifdef ALIZA_PERF_COLLISION
#include <chrono>
#include <thread>
#endif
#include "iconutils.h"
#include "commonutils.h"
#include "contourutils.h"
Expand Down Expand Up @@ -67,6 +69,15 @@ static btCollisionWorld * g_collisionWorld = nullptr;
static btAlignedObjectArray<btCollisionShape*> g_collision_shapes;
static bool show_all_study_collisions = true;

inline void delay1(int ms) // milliseconds
{
QEventLoop loop;
QTimer t;
t.connect(&t, SIGNAL(timeout()), &loop, SLOT(quit()));
t.start(ms);
loop.exec();
}

struct ClosestRayResultCallback1 : public btCollisionWorld::ClosestRayResultCallback
{
ClosestRayResultCallback1 (const btVector3 & rayFrom,const btVector3 & rayTo)
Expand Down Expand Up @@ -761,8 +772,7 @@ QString Aliza::load_dicom_series(QProgressDialog * pb)
lt->start();
while (!lt->isFinished())
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
qApp->processEvents();
delay1(10);
}
const QString message_ = lt->message;
if (!message_.isEmpty())
Expand Down Expand Up @@ -890,8 +900,7 @@ void Aliza::add_histogram(ImageVariant * v, QProgressDialog * pb, bool check_set
t->start();
while (!t->isFinished())
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
qApp->processEvents();
delay1(10);
if (pb && pb->wasCanceled())
{
t->exit(0);
Expand Down Expand Up @@ -4156,8 +4165,7 @@ QString Aliza::load_dicom_file(
lt->start();
while (!lt->isFinished())
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
qApp->processEvents();
delay1(10);
}
const QString message_ = lt->message;
if (!message_.isEmpty())
Expand Down

0 comments on commit 625e901

Please sign in to comment.