From a5eb5a6ea2de89682fc6974f9bb77084032df2f4 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 28 Feb 2017 10:25:27 +0300 Subject: [PATCH] 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 :) --- .../settings/settings_background_widget.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/settings/settings_background_widget.cpp b/Telegram/SourceFiles/settings/settings_background_widget.cpp index fa1005476..31d42830a 100644 --- a/Telegram/SourceFiles/settings/settings_background_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_background_widget.cpp @@ -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;