const int getCurrentProgress(void) const { return m_progress; };
const UpdateCheckerInfo *getUpdateInfo(void) const { return m_updateInfo.data(); }
- void cancel(void) { m_cancelled = true; }
+ bool cancel(void) { return m_cancelled.ref(); }
public slots:
void start(Priority = InheritPriority);
const QString m_binaryKeys;
volatile bool m_success;
- volatile bool m_cancelled;
+ QAtomicInt m_cancelled;
int m_status;
int m_progress;
static const int VERSION_INFO_EXPIRES_MONTHS = 6;
static char *USER_AGENT_STR = "Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0"; /*use something innocuous*/
+#define IS_CANCELLED (!(!m_cancelled))
#define CHECK_CANCELLED() do \
{ \
- if(m_cancelled) \
+ if(IS_CANCELLED) \
{ \
m_success = false; \
log("", "Update check has been cancelled by user!"); \
m_testMode(testMode),
m_maxProgress(getMaxProgress())
{
- m_success = m_cancelled = false;
+ m_success = false;
m_status = UpdateStatus_NotStartedYet;
m_progress = 0;
void UpdateChecker::start(Priority priority)
{
- m_cancelled = m_success = false;
+ m_success = false;
+ m_cancelled.fetchAndStoreOrdered(0);
QThread::start(priority);
}
{
return true;
}
- if (m_cancelled)
+ if (IS_CANCELLED)
{
break; /*cancelled*/
}
const QString line = QString::fromLatin1(process.readLine()).simplified();
log(line);
}
- if (bTimeOut || m_cancelled)
+ if (bTimeOut || IS_CANCELLED)
{
qWarning("WGet process timed out <-- killing!");
process.kill();
QString line = QString::fromLatin1(process.readLine()).simplified();
log(line);
}
- if (bTimeOut || m_cancelled)
+ if (bTimeOut || IS_CANCELLED)
{
qWarning("MCat process timed out <-- killing!");
process.kill();