~adamreichold/qpdfview/trunk

« back to all changes in this revision

Viewing changes to sources/searchtask.h

  • Committer: Adam Reichold
  • Date: 2020-07-29 07:15:12 UTC
  • Revision ID: adam.reichold@t-online.de-20200729071512-4ljoi4b4rhj3i2ya
Fix build of Fitz plug-in using MuPDF v1.17.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <QThread>
27
27
#include <QVector>
28
28
 
29
 
#include "model.h"
30
 
 
31
29
namespace qpdfview
32
30
{
33
31
 
 
32
namespace Model
 
33
{
 
34
class Page;
 
35
}
 
36
 
34
37
class SearchTask : public QThread
35
38
{
36
39
    Q_OBJECT
78
81
 
79
82
    void releaseProgress(int value);
80
83
    int acquireProgress() const;
 
84
    int loadProgress() const;
81
85
 
82
86
    template< typename Future >
83
87
    void processResults(Future future);
93
97
 
94
98
};
95
99
 
96
 
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
 
100
#if QT_VERSION > QT_VERSION_CHECK(5,0,0)
97
101
 
98
102
inline void SearchTask::setCancellation()
99
103
{
100
 
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
101
 
 
102
 
    m_wasCanceled.storeRelaxed(Canceled);
103
 
 
104
 
#else
105
 
 
106
 
    m_wasCanceled.store(Canceled);
107
 
 
108
 
#endif // QT_VERSION
 
104
    m_wasCanceled.storeRelease(Canceled);
109
105
}
110
106
 
111
107
inline void SearchTask::resetCancellation()
112
108
{
113
 
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
114
 
 
115
 
    m_wasCanceled.storeRelaxed(NotCanceled);
116
 
 
117
 
#else
118
 
 
119
 
    m_wasCanceled.store(NotCanceled);
120
 
 
121
 
#endif // QT_VERSION
 
109
    m_wasCanceled.storeRelease(NotCanceled);
122
110
}
123
111
 
124
112
inline bool SearchTask::testCancellation()
125
113
{
126
 
    return loadCancellation() != NotCanceled;
 
114
    return m_wasCanceled.load() != NotCanceled;
127
115
}
128
116
 
129
117
inline int SearchTask::loadCancellation() const
130
118
{
131
 
#if QT_VERSION > QT_VERSION_CHECK(5,14,0)
132
 
 
133
 
    return m_wasCanceled.loadRelaxed();
134
 
 
135
 
#else
136
 
 
137
119
    return m_wasCanceled.load();
138
 
 
139
 
#endif // QT_VERSION
140
120
}
141
121
 
142
122
inline void SearchTask::releaseProgress(int value)
149
129
    return m_progress.loadAcquire();
150
130
}
151
131
 
 
132
inline int SearchTask::loadProgress() const
 
133
{
 
134
    return m_progress.load();
 
135
}
 
136
 
152
137
#else
153
138
 
154
139
inline void SearchTask::setCancellation()
155
140
{
156
 
    m_wasCanceled.fetchAndStoreRelaxed(Canceled);
 
141
    m_wasCanceled.fetchAndStoreRelease(Canceled);
157
142
}
158
143
 
159
144
inline void SearchTask::resetCancellation()
160
145
{
161
 
    m_wasCanceled.fetchAndStoreRelaxed(NotCanceled);
 
146
    m_wasCanceled.fetchAndStoreRelease(NotCanceled);
162
147
}
163
148
 
164
149
inline bool SearchTask::testCancellation()
181
166
    return m_progress.fetchAndAddAcquire(0);
182
167
}
183
168
 
 
169
inline int SearchTask::loadProgress() const
 
170
{
 
171
    return m_progress;
 
172
}
 
173
 
184
174
#endif // QT_VERSION
185
175
 
186
176
} // qpdfview