Fix possible crash in SendFilesBox.

This commit is contained in:
John Preston 2019-01-14 10:28:20 +04:00
parent 51b5b14dea
commit 09d85e25c1
1 changed files with 16 additions and 11 deletions

View File

@ -677,7 +677,7 @@ void SingleMediaPreview::preparePreview(
void SingleMediaPreview::prepareAnimatedPreview( void SingleMediaPreview::prepareAnimatedPreview(
const QString &animatedPreviewPath) { const QString &animatedPreviewPath) {
if (!animatedPreviewPath.isEmpty()) { if (!animatedPreviewPath.isEmpty()) {
auto callback = [this](Media::Clip::Notification notification) { auto callback = [=](Media::Clip::Notification notification) {
clipCallback(notification); clipCallback(notification);
}; };
_gifPreview = Media::Clip::MakeReader( _gifPreview = Media::Clip::MakeReader(
@ -1357,7 +1357,7 @@ void SendFilesBox::initPreview(rpl::producer<int> desiredPreviewHeight) {
std::move(desiredPreviewHeight), std::move(desiredPreviewHeight),
_footerHeight.value(), _footerHeight.value(),
_titleHeight + _1 + _2 _titleHeight + _1 + _2
) | rpl::start_with_next([this](int height) { ) | rpl::start_with_next([=](int height) {
setDimensions( setDimensions(
st::boxWideWidth, st::boxWideWidth,
std::min(st::sendMediaPreviewHeightMax, height)); std::min(st::sendMediaPreviewHeightMax, height));
@ -1435,8 +1435,8 @@ void SendFilesBox::setupShadows(
} }
void SendFilesBox::prepare() { void SendFilesBox::prepare() {
_send = addButton(langFactory(lng_send_button), [this] { send(); }); _send = addButton(langFactory(lng_send_button), [=] { send(); });
addButton(langFactory(lng_cancel), [this] { closeBox(); }); addButton(langFactory(lng_cancel), [=] { closeBox(); });
initSendWay(); initSendWay();
setupCaption(); setupCaption();
preparePreview(); preparePreview();
@ -1472,7 +1472,7 @@ void SendFilesBox::initSendWay() {
: SendFilesWay::Photos; : SendFilesWay::Photos;
}(); }();
_sendWay = std::make_shared<Ui::RadioenumGroup<SendFilesWay>>(value); _sendWay = std::make_shared<Ui::RadioenumGroup<SendFilesWay>>(value);
_sendWay->setChangedCallback([this](SendFilesWay value) { _sendWay->setChangedCallback([=](SendFilesWay value) {
updateCaptionPlaceholder(); updateCaptionPlaceholder();
applyAlbumOrder(); applyAlbumOrder();
if (_albumPreview) { if (_albumPreview) {
@ -1483,7 +1483,10 @@ void SendFilesBox::initSendWay() {
} }
void SendFilesBox::updateCaptionPlaceholder() { void SendFilesBox::updateCaptionPlaceholder() {
_caption->setPlaceholder(FieldPlaceholder(_list, _sendWay->value())); if (_caption) {
const auto sendWay = _sendWay->value();
_caption->setPlaceholder(FieldPlaceholder(_list, sendWay));
}
} }
void SendFilesBox::refreshAlbumMediaCount() { void SendFilesBox::refreshAlbumMediaCount() {
@ -1814,12 +1817,14 @@ void SendFilesBox::updateControlsGeometry() {
bottom - _caption->height()); bottom - _caption->height());
bottom -= st::boxPhotoCaptionSkip + _caption->height(); bottom -= st::boxPhotoCaptionSkip + _caption->height();
if (_emojiToggle) {
_emojiToggle->moveToLeft( _emojiToggle->moveToLeft(
(st::boxPhotoPadding.left() (st::boxPhotoPadding.left()
+ st::sendMediaPreviewSize + st::sendMediaPreviewSize
- _emojiToggle->width()), - _emojiToggle->width()),
_caption->y() + st::boxAttachEmojiTop); _caption->y() + st::boxAttachEmojiTop);
} }
}
const auto pointers = { const auto pointers = {
_sendAlbum.data(), _sendAlbum.data(),
_sendPhotos.data(), _sendPhotos.data(),