From b244069fb4a846c7494d7dc5cc15721bb0353442 Mon Sep 17 00:00:00 2001 From: elros34 Date: Tue, 28 Apr 2020 14:33:20 +0200 Subject: [PATCH 1/2] Fix crash if video thumbnail is not available --- depecher/qml/pages/items/delegates/VideoDelegate.qml | 6 +++--- tdlibjson_wrapper/tdlibQt/models/MessagingModel.cpp | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/depecher/qml/pages/items/delegates/VideoDelegate.qml b/depecher/qml/pages/items/delegates/VideoDelegate.qml index 3d340d54..4b496211 100644 --- a/depecher/qml/pages/items/delegates/VideoDelegate.qml +++ b/depecher/qml/pages/items/delegates/VideoDelegate.qml @@ -56,10 +56,10 @@ Column{ asynchronous: true property int maxWidth: JsUtils.getWidth() - Theme.itemSizeExtraSmall - Theme.paddingMedium - 2*Theme.horizontalPageMargin property int maxHeight: JsUtils.getHeight()/2 - width: photo_aspect >= 1 ? maxWidth : maxHeight * photo_aspect - height: photo_aspect >= 1 ? maxWidth/photo_aspect : maxHeight + width: media_preview ? (photo_aspect >= 1 ? maxWidth : maxHeight * photo_aspect) : Theme.itemSizeExtraLarge + height: media_preview ? (photo_aspect >= 1 ? maxWidth/photo_aspect : maxHeight) : Theme.itemSizeExtraLarge fillMode: Image.PreserveAspectFit - source: "image://depecherDb/" + media_preview + source: media_preview ? ("image://depecherDb/" + media_preview) : "" MouseArea{ anchors.fill: parent diff --git a/tdlibjson_wrapper/tdlibQt/models/MessagingModel.cpp b/tdlibjson_wrapper/tdlibQt/models/MessagingModel.cpp index ec0465bd..21bd07d1 100644 --- a/tdlibjson_wrapper/tdlibQt/models/MessagingModel.cpp +++ b/tdlibjson_wrapper/tdlibQt/models/MessagingModel.cpp @@ -312,8 +312,11 @@ QVariant MessagingModel::data(const QModelIndex &index, int role) const if (m_messages[rowIndex]->content_->get_id() == messageVideo::ID) { auto contentVideoPtr = static_cast (m_messages[rowIndex]->content_.data()); - return (float)contentVideoPtr->video_->thumbnail_->width_ / (float) - contentVideoPtr->video_->thumbnail_->height_; + auto thumbnail = contentVideoPtr->video_->thumbnail_; + if (thumbnail) + return (float)thumbnail->width_ / (float)thumbnail->height_; + else + return 0.1; } if (m_messages[rowIndex]->content_->get_id() == messageAnimation::ID) { auto contentAnimationPtr = static_cast @@ -479,6 +482,8 @@ QVariant MessagingModel::data(const QModelIndex &index, int role) const } if (m_messages[rowIndex]->content_->get_id() == messageVideo::ID) { auto contentVideoPtr = static_cast(m_messages[rowIndex]->content_.data()); + if (!contentVideoPtr->video_->thumbnail_) + return QVariant(); if (contentVideoPtr->video_->thumbnail_->photo_->local_->is_downloading_completed_) return QString::fromStdString(contentVideoPtr->video_->thumbnail_->photo_->local_->path_); else { From 9704e6dcaecd280342374e785de18abd2fccfd40 Mon Sep 17 00:00:00 2001 From: elros34 Date: Tue, 28 Apr 2020 14:31:29 +0200 Subject: [PATCH 2/2] rpm: Move dekstop-file-install to %install section --- depecher/rpm/depecher.spec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/depecher/rpm/depecher.spec b/depecher/rpm/depecher.spec index 88f0c64f..c363ff6d 100644 --- a/depecher/rpm/depecher.spec +++ b/depecher/rpm/depecher.spec @@ -64,6 +64,10 @@ rm -rf %{buildroot} # << install pre %qmake5_install +desktop-file-install --delete-original \ + --dir %{buildroot}%{_datadir}/applications \ + %{buildroot}%{_datadir}/applications/*.desktop + # >> install post %post systemctl-user stop org.blacksailer.depecher.service || true @@ -86,10 +90,6 @@ systemctl-user daemon-reload # << install post -desktop-file-install --delete-original \ - --dir %{buildroot}%{_datadir}/applications \ - %{buildroot}%{_datadir}/applications/*.desktop - %preun # >> preun systemctl-user stop org.blacksailer.depecher.service || true