From b772e42ca19dee752844af39bbea62c76056a32c Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 3 Sep 2016 10:18:46 -0400 Subject: [PATCH 1/2] Fixed crash in RevokePublicLinkBox. --- Telegram/SourceFiles/boxes/addcontactbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index ee742defd1..beccb92b26 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -1406,7 +1406,7 @@ void RevokePublicLinkBox::mousePressEvent(QMouseEvent *e) { void RevokePublicLinkBox::mouseReleaseEvent(QMouseEvent *e) { auto pressed = createAndSwap(_pressed); setCursor((_selected || _pressed) ? style::cur_pointer : style::cur_default); - if (pressed == _selected) { + if (pressed && pressed == _selected) { auto text_method = pressed->isMegagroup() ? lng_channels_too_much_public_revoke_confirm_group : lng_channels_too_much_public_revoke_confirm_channel; auto text = text_method(lt_link, qsl("telegram.me/") + pressed->userName(), lt_group, pressed->name); weakRevokeConfirmBox = new ConfirmBox(text, lang(lng_channels_too_much_public_revoke)); From ab18fc647828100e71f00368b5f8932ac0319672 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 3 Sep 2016 12:35:12 -0400 Subject: [PATCH 2/2] 0.10.4: Same chat msg links fixed. Crash fix attempt in ScrollArea. If the message link is opened in the same chat the ShowWay::Forward should be ignored. There was a possible crash in ~ScrollArea() when one of the bars was already destroyed and the second called ScrollArea::leaveEvent. Now both bars are ChildWidget<>s and will be destroyed in ~QWidget(). --- Telegram/Resources/winrc/Telegram.rc | 8 +-- Telegram/Resources/winrc/Updater.rc | 8 +-- Telegram/SourceFiles/core/version.h | 4 +- Telegram/SourceFiles/mainwidget.cpp | 5 ++ Telegram/SourceFiles/ui/scrollarea.cpp | 78 +++++++++++++------------- Telegram/SourceFiles/ui/scrollarea.h | 25 +++++---- Telegram/build/version | 6 +- 7 files changed, 73 insertions(+), 61 deletions(-) diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 54fad8712d..b3f0fdcd22 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,10,3,0 - PRODUCTVERSION 0,10,3,0 + FILEVERSION 0,10,4,0 + PRODUCTVERSION 0,10,4,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -51,10 +51,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Telegram Messenger LLP" - VALUE "FileVersion", "0.10.3.0" + VALUE "FileVersion", "0.10.4.0" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.10.3.0" + VALUE "ProductVersion", "0.10.4.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 1442622ea2..31d3566c30 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,10,3,0 - PRODUCTVERSION 0,10,3,0 + FILEVERSION 0,10,4,0 + PRODUCTVERSION 0,10,4,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -43,10 +43,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram Messenger LLP" VALUE "FileDescription", "Telegram Updater" - VALUE "FileVersion", "0.10.3.0" + VALUE "FileVersion", "0.10.4.0" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.10.3.0" + VALUE "ProductVersion", "0.10.4.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index d31991856d..c3aff1e853 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #define BETA_VERSION_MACRO (0ULL) -constexpr int AppVersion = 10003; -constexpr str_const AppVersionStr = "0.10.3"; +constexpr int AppVersion = 10004; +constexpr str_const AppVersionStr = "0.10.4"; constexpr bool AppAlphaVersion = true; constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO; diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 8ff04dd03c..53fdc26b79 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2038,6 +2038,11 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, Ui::Show break; } } + if (auto historyPeer = _history->peer()) { + if (way == Ui::ShowWay::Forward && historyPeer->id == peerId) { + way = Ui::ShowWay::ClearStack; + } + } } if (back || (way == Ui::ShowWay::ClearStack)) { diff --git a/Telegram/SourceFiles/ui/scrollarea.cpp b/Telegram/SourceFiles/ui/scrollarea.cpp index 9ebd5d32be..6176f850fe 100644 --- a/Telegram/SourceFiles/ui/scrollarea.cpp +++ b/Telegram/SourceFiles/ui/scrollarea.cpp @@ -320,17 +320,18 @@ void SplittedWidgetOther::paintEvent(QPaintEvent *e) { } } -ScrollArea::ScrollArea(QWidget *parent, const style::flatScroll &st, bool handleTouch) : QScrollArea(parent), -_disabled(false), _st(st), -hor(this, false, &_st), vert(this, true, &_st), topSh(this, &_st), bottomSh(this, &_st), -_touchEnabled(handleTouch), _touchScroll(false), _touchPress(false), _touchRightButton(false), -_touchScrollState(TouchScrollManual), _touchPrevPosValid(false), _touchWaitingAcceleration(false), -_touchSpeedTime(0), _touchAccelerationTime(0), _touchTime(0), _widgetAcceptsTouch(false), _other(0) { +ScrollArea::ScrollArea(QWidget *parent, const style::flatScroll &st, bool handleTouch) : QScrollArea(parent) +, _st(st) +, _horizontalBar(this, false, &_st) +, _verticalBar(this, true, &_st) +, _topShadow(this, &_st) +, _bottomShadow(this, &_st) +, _touchEnabled(handleTouch) { setLayoutDirection(cLangDir()); - connect(&vert, SIGNAL(topShadowVisibility(bool)), &topSh, SLOT(changeVisibility(bool))); - connect(&vert, SIGNAL(bottomShadowVisibility(bool)), &bottomSh, SLOT(changeVisibility(bool))); - vert.updateBar(true); + connect(_verticalBar, SIGNAL(topShadowVisibility(bool)), _topShadow, SLOT(changeVisibility(bool))); + connect(_verticalBar, SIGNAL(bottomShadowVisibility(bool)), _bottomShadow, SLOT(changeVisibility(bool))); + _verticalBar->updateBar(true); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -338,8 +339,8 @@ _touchSpeedTime(0), _touchAccelerationTime(0), _touchTime(0), _widgetAcceptsTouc setFrameStyle(QFrame::NoFrame | QFrame::Plain); viewport()->setAutoFillBackground(false); - _horValue = horizontalScrollBar()->value(); - _vertValue = verticalScrollBar()->value(); + _horizontalValue = horizontalScrollBar()->value(); + _verticalValue = verticalScrollBar()->value(); if (_touchEnabled) { viewport()->setAttribute(Qt::WA_AcceptTouchEvents); @@ -360,25 +361,26 @@ void ScrollArea::onScrolled() { myEnsureResized(widget()); bool em = false; - int32 horValue = horizontalScrollBar()->value(), vertValue = verticalScrollBar()->value(); - if (_horValue != horValue) { + int horizontalValue = horizontalScrollBar()->value(); + int verticalValue = verticalScrollBar()->value(); + if (_horizontalValue != horizontalValue) { if (_disabled) { - horizontalScrollBar()->setValue(_horValue); + horizontalScrollBar()->setValue(_horizontalValue); } else { - _horValue = horValue; + _horizontalValue = horizontalValue; if (_st.hiding) { - hor.hideTimeout(_st.hiding); + _horizontalBar->hideTimeout(_st.hiding); } em = true; } } - if (_vertValue != vertValue) { + if (_verticalValue != verticalValue) { if (_disabled) { - verticalScrollBar()->setValue(_vertValue); + verticalScrollBar()->setValue(_verticalValue); } else { - _vertValue = vertValue; + _verticalValue = verticalValue; if (_st.hiding) { - vert.hideTimeout(_st.hiding); + _verticalBar->hideTimeout(_st.hiding); } em = true; } @@ -410,11 +412,11 @@ int ScrollArea::scrollTopMax() const { } int ScrollArea::scrollLeft() const { - return _horValue; + return _horizontalValue; } int ScrollArea::scrollTop() const { - return _vertValue; + return _verticalValue; } void ScrollArea::onTouchTimer() { @@ -610,8 +612,8 @@ void ScrollArea::touchScrollUpdated(const QPoint &screenPos) { void ScrollArea::disableScroll(bool dis) { _disabled = dis; if (_disabled && _st.hiding) { - hor.hideTimeout(0); - vert.hideTimeout(0); + _horizontalBar->hideTimeout(0); + _verticalBar->hideTimeout(0); } } @@ -632,10 +634,10 @@ bool ScrollArea::touchScroll(const QPoint &delta) { void ScrollArea::resizeEvent(QResizeEvent *e) { QScrollArea::resizeEvent(e); - hor.recountSize(); - vert.recountSize(); - topSh.setGeometry(QRect(0, 0, width(), qAbs(_st.topsh))); - bottomSh.setGeometry(QRect(0, height() - qAbs(_st.bottomsh), width(), qAbs(_st.bottomsh))); + _horizontalBar->recountSize(); + _verticalBar->recountSize(); + _topShadow->setGeometry(QRect(0, 0, width(), qAbs(_st.topsh))); + _bottomShadow->setGeometry(QRect(0, height() - qAbs(_st.bottomsh), width(), qAbs(_st.bottomsh))); if (SplittedWidget *w = qobject_cast(widget())) { w->resize(width() - w->otherWidth(), w->height()); if (!rtl()) { @@ -663,16 +665,16 @@ void ScrollArea::keyPressEvent(QKeyEvent *e) { void ScrollArea::enterEventHook(QEvent *e) { if (_disabled) return; if (_st.hiding) { - hor.hideTimeout(_st.hiding); - vert.hideTimeout(_st.hiding); + _horizontalBar->hideTimeout(_st.hiding); + _verticalBar->hideTimeout(_st.hiding); } return QScrollArea::enterEvent(e); } void ScrollArea::leaveEventHook(QEvent *e) { if (_st.hiding) { - hor.hideTimeout(0); - vert.hideTimeout(0); + _horizontalBar->hideTimeout(0); + _verticalBar->hideTimeout(0); } return QScrollArea::leaveEvent(e); } @@ -716,10 +718,10 @@ void ScrollArea::setWidget(QWidget *w) { } else if (!_other && splitted) { _other = new SplittedWidgetOther(this); _other->setAttribute(Qt::WA_OpaquePaintEvent); - _other->resize(vert.width(), _other->height()); + _other->resize(_verticalBar->width(), _other->height()); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onVerticalScroll())); - hor.raise(); - vert.raise(); + _horizontalBar->raise(); + _verticalBar->raise(); } if (_ownsWidget) { _ownsWidget = false; @@ -734,7 +736,7 @@ void ScrollArea::setWidget(QWidget *w) { w->setAttribute(Qt::WA_AcceptTouchEvents); } if (splitted) { - splitted->setOtherWidth(vert.width()); + splitted->setOtherWidth(_verticalBar->width()); w->setGeometry(rtl() ? splitted->otherWidth() : 0, 0, width() - splitted->otherWidth(), w->height()); connect(splitted, SIGNAL(resizeOther()), this, SLOT(onResizeOther())); connect(splitted, SIGNAL(updateOther(const QRect&)), this, SLOT(onUpdateOther(const QRect&))); @@ -783,8 +785,8 @@ void ScrollArea::updateColors(const style::color &bar, const style::color &bg, c _st.bgColor = bg; _st.barOverColor = barOver; _st.bgOverColor = bgOver; - hor.update(); - vert.update(); + _horizontalBar->update(); + _verticalBar->update(); } bool ScrollArea::focusNextPrevChild(bool next) { diff --git a/Telegram/SourceFiles/ui/scrollarea.h b/Telegram/SourceFiles/ui/scrollarea.h index 7ea0bd0acb..98a79881cb 100644 --- a/Telegram/SourceFiles/ui/scrollarea.h +++ b/Telegram/SourceFiles/ui/scrollarea.h @@ -235,30 +235,35 @@ private: void touchUpdateSpeed(); void touchDeaccelerate(int32 elapsed); - bool _disabled; + bool _disabled = false; bool _ownsWidget = false; // if true, the widget is deleted in destructor. bool _movingByScrollBar = false; style::flatScroll _st; - ScrollBar hor, vert; - ScrollShadow topSh, bottomSh; - int32 _horValue, _vertValue; + ChildWidget _horizontalBar, _verticalBar; + ChildWidget _topShadow, _bottomShadow; + int _horizontalValue, _verticalValue; bool _touchEnabled; QTimer _touchTimer; - bool _touchScroll, _touchPress, _touchRightButton; + bool _touchScroll = false; + bool _touchPress = false; + bool _touchRightButton = false; QPoint _touchStart, _touchPrevPos, _touchPos; - TouchScrollState _touchScrollState; - bool _touchPrevPosValid, _touchWaitingAcceleration; + TouchScrollState _touchScrollState = TouchScrollManual; + bool _touchPrevPosValid = false; + bool _touchWaitingAcceleration = false; QPoint _touchSpeed; - uint64 _touchSpeedTime, _touchAccelerationTime, _touchTime; + uint64 _touchSpeedTime = 0; + uint64 _touchAccelerationTime = 0; + uint64 _touchTime = 0; QTimer _touchScrollTimer; - bool _widgetAcceptsTouch; + bool _widgetAcceptsTouch = false; friend class SplittedWidgetOther; - SplittedWidgetOther *_other; + SplittedWidgetOther *_other = nullptr; }; diff --git a/Telegram/build/version b/Telegram/build/version index 635442f270..7dc4be18be 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,6 +1,6 @@ -AppVersion 10003 +AppVersion 10004 AppVersionStrMajor 0.10 -AppVersionStrSmall 0.10.3 -AppVersionStr 0.10.3 +AppVersionStrSmall 0.10.4 +AppVersionStr 0.10.4 AlphaChannel 1 BetaVersion 0