mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 20:33:09 +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() {
|
void AnimationReader::run() {
|
||||||
|
auto originalPriority = QThread::currentThread()->priority();
|
||||||
|
if (originalPriority == QThread::InheritPriority) {
|
||||||
|
originalPriority = QThread::NormalPriority;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (_data.isEmpty()) {
|
if (_data.isEmpty()) {
|
||||||
throw QString("Reply is NULL ?!");
|
throw QString("Reply is NULL ?!");
|
||||||
|
@ -73,6 +77,7 @@ void AnimationReader::run() {
|
||||||
} catch (const QString& error) {
|
} catch (const QString& error) {
|
||||||
emit onError(299, error);
|
emit onError(299, error);
|
||||||
}
|
}
|
||||||
|
QThread::currentThread()->setPriority(originalPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Animation::isLoaded() const {
|
bool Animation::isLoaded() const {
|
||||||
|
|
|
@ -50,6 +50,11 @@ GeometryReader::GeometryReader(const QUrl& url, const QByteArray& data, const QV
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryReader::run() {
|
void GeometryReader::run() {
|
||||||
|
auto originalPriority = QThread::currentThread()->priority();
|
||||||
|
if (originalPriority == QThread::InheritPriority) {
|
||||||
|
originalPriority = QThread::NormalPriority;
|
||||||
|
}
|
||||||
|
QThread::currentThread()->setPriority(QThread::LowPriority);
|
||||||
try {
|
try {
|
||||||
if (_data.isEmpty()) {
|
if (_data.isEmpty()) {
|
||||||
throw QString("Reply is NULL ?!");
|
throw QString("Reply is NULL ?!");
|
||||||
|
@ -82,6 +87,8 @@ void GeometryReader::run() {
|
||||||
qCDebug(modelnetworking) << "Error reading " << _url << ": " << error;
|
qCDebug(modelnetworking) << "Error reading " << _url << ": " << error;
|
||||||
emit onError(NetworkGeometry::ModelParseError, error);
|
emit onError(NetworkGeometry::ModelParseError, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QThread::currentThread()->setPriority(originalPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkGeometry::NetworkGeometry(const QUrl& url, bool delayLoad, const QVariantHash& mapping, const QUrl& textureBaseUrl) :
|
NetworkGeometry::NetworkGeometry(const QUrl& url, bool delayLoad, const QVariantHash& mapping, const QUrl& textureBaseUrl) :
|
||||||
|
|
|
@ -268,6 +268,12 @@ void ImageReader::listSupportedImageFormats() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageReader::run() {
|
void ImageReader::run() {
|
||||||
|
auto originalPriority = QThread::currentThread()->priority();
|
||||||
|
if (originalPriority == QThread::InheritPriority) {
|
||||||
|
originalPriority = QThread::NormalPriority;
|
||||||
|
}
|
||||||
|
QThread::currentThread()->setPriority(QThread::LowPriority);
|
||||||
|
|
||||||
auto texture = _texture.toStrongRef();
|
auto texture = _texture.toStrongRef();
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
qCWarning(modelnetworking) << "Could not get strong ref";
|
qCWarning(modelnetworking) << "Could not get strong ref";
|
||||||
|
@ -306,6 +312,7 @@ void ImageReader::run() {
|
||||||
Q_ARG(const QImage&, image),
|
Q_ARG(const QImage&, image),
|
||||||
Q_ARG(void*, theTexture),
|
Q_ARG(void*, theTexture),
|
||||||
Q_ARG(int, originalWidth), Q_ARG(int, originalHeight));
|
Q_ARG(int, originalWidth), Q_ARG(int, originalHeight));
|
||||||
|
QThread::currentThread()->setPriority(originalPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkTexture::setImage(const QImage& image, void* voidTexture, int originalWidth,
|
void NetworkTexture::setImage(const QImage& image, void* voidTexture, int originalWidth,
|
||||||
|
|
Loading…
Reference in a new issue