mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-17 22:08:27 +02:00
Make the file parsing threads run at lower priority
This commit is contained in:
parent
07759bb5db
commit
421160eeb6
3 changed files with 19 additions and 0 deletions
|
@ -47,6 +47,10 @@ AnimationReader::AnimationReader(const QUrl& url, const QByteArray& data) :
|
|||
}
|
||||
|
||||
void AnimationReader::run() {
|
||||
auto originalPriority = QThread::currentThread()->priority();
|
||||
if (originalPriority == QThread::InheritPriority) {
|
||||
originalPriority = QThread::NormalPriority;
|
||||
}
|
||||
try {
|
||||
if (_data.isEmpty()) {
|
||||
throw QString("Reply is NULL ?!");
|
||||
|
@ -73,6 +77,7 @@ void AnimationReader::run() {
|
|||
} catch (const QString& error) {
|
||||
emit onError(299, error);
|
||||
}
|
||||
QThread::currentThread()->setPriority(originalPriority);
|
||||
}
|
||||
|
||||
bool Animation::isLoaded() const {
|
||||
|
|
|
@ -50,6 +50,11 @@ GeometryReader::GeometryReader(const QUrl& url, const QByteArray& data, const QV
|
|||
}
|
||||
|
||||
void GeometryReader::run() {
|
||||
auto originalPriority = QThread::currentThread()->priority();
|
||||
if (originalPriority == QThread::InheritPriority) {
|
||||
originalPriority = QThread::NormalPriority;
|
||||
}
|
||||
QThread::currentThread()->setPriority(QThread::LowPriority);
|
||||
try {
|
||||
if (_data.isEmpty()) {
|
||||
throw QString("Reply is NULL ?!");
|
||||
|
@ -82,6 +87,8 @@ void GeometryReader::run() {
|
|||
qCDebug(modelnetworking) << "Error reading " << _url << ": " << error;
|
||||
emit onError(NetworkGeometry::ModelParseError, error);
|
||||
}
|
||||
|
||||
QThread::currentThread()->setPriority(originalPriority);
|
||||
}
|
||||
|
||||
NetworkGeometry::NetworkGeometry(const QUrl& url, bool delayLoad, const QVariantHash& mapping, const QUrl& textureBaseUrl) :
|
||||
|
|
|
@ -268,6 +268,12 @@ void ImageReader::listSupportedImageFormats() {
|
|||
}
|
||||
|
||||
void ImageReader::run() {
|
||||
auto originalPriority = QThread::currentThread()->priority();
|
||||
if (originalPriority == QThread::InheritPriority) {
|
||||
originalPriority = QThread::NormalPriority;
|
||||
}
|
||||
QThread::currentThread()->setPriority(QThread::LowPriority);
|
||||
|
||||
auto texture = _texture.toStrongRef();
|
||||
if (!texture) {
|
||||
qCWarning(modelnetworking) << "Could not get strong ref";
|
||||
|
@ -306,6 +312,7 @@ void ImageReader::run() {
|
|||
Q_ARG(const QImage&, image),
|
||||
Q_ARG(void*, theTexture),
|
||||
Q_ARG(int, originalWidth), Q_ARG(int, originalHeight));
|
||||
QThread::currentThread()->setPriority(originalPriority);
|
||||
}
|
||||
|
||||
void NetworkTexture::setImage(const QImage& image, void* voidTexture, int originalWidth,
|
||||
|
|
Loading…
Reference in a new issue