Crash fix when setting a background image by URL. #3077

When we choose a file from URL we don't get the filename.
In background image apply method we test for a theme / palette
file extensions. Now we don't crash there, but we still can't set
a .tdesktop-theme or .tdesktop-palette file from URL. Who cares :)
This commit is contained in:
John Preston 2017-02-28 10:25:27 +03:00
parent d254058690
commit a5eb5a6ea2
1 changed files with 8 additions and 6 deletions

View File

@ -271,18 +271,20 @@ void BackgroundWidget::notifyFileQueryUpdated(const FileDialog::QueryUpdate &upd
return;
}
auto filePath = update.filePaths.front();
if (filePath.endsWith(qstr(".tdesktop-theme"), Qt::CaseInsensitive)
|| filePath.endsWith(qstr(".tdesktop-palette"), Qt::CaseInsensitive)) {
Window::Theme::Apply(filePath);
return;
if (!update.filePaths.isEmpty()) {
auto filePath = update.filePaths.front();
if (filePath.endsWith(qstr(".tdesktop-theme"), Qt::CaseInsensitive)
|| filePath.endsWith(qstr(".tdesktop-palette"), Qt::CaseInsensitive)) {
Window::Theme::Apply(filePath);
return;
}
}
QImage img;
if (!update.remoteContent.isEmpty()) {
img = App::readImage(update.remoteContent);
} else {
img = App::readImage(filePath);
img = App::readImage(update.filePaths.front());
}
if (img.isNull() || img.width() <= 0 || img.height() <= 0) return;