Version 0.10.13.alpha: crash fix in custom notifications.

Not sending inline bot request drafts to server by timeout.
This commit is contained in:
John Preston 2016-10-07 19:45:45 +03:00
parent 3c84899edf
commit f1d52c12ae
35 changed files with 80 additions and 90 deletions

View File

@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,10,12,0
PRODUCTVERSION 0,10,12,0
FILEVERSION 0,10,13,0
PRODUCTVERSION 0,10,13,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "0.10.12.0"
VALUE "FileVersion", "0.10.13.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.10.12.0"
VALUE "ProductVersion", "0.10.13.0"
END
END
BLOCK "VarFileInfo"

View File

@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,10,12,0
PRODUCTVERSION 0,10,12,0
FILEVERSION 0,10,13,0
PRODUCTVERSION 0,10,13,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.12.0"
VALUE "FileVersion", "0.10.13.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.10.12.0"
VALUE "ProductVersion", "0.10.13.0"
END
END
BLOCK "VarFileInfo"

View File

@ -336,8 +336,7 @@ void Application::closeApplication() {
manager->clearAllFast();
}
delete AppObject;
AppObject = 0;
delete base::take(AppObject);
Sandbox::finish();
@ -1103,8 +1102,7 @@ void AppClass::checkMapVersion() {
AppClass::~AppClass() {
Shortcuts::finish();
auto window = createAndSwap(_window);
delete window;
delete base::take(_window);
Window::Notifications::finish();
@ -1117,8 +1115,8 @@ AppClass::~AppClass() {
MTP::finish();
AppObject = nullptr;
deleteAndMark(_uploader);
deleteAndMark(_translator);
delete base::take(_uploader);
delete base::take(_translator);
Window::chatBackground()->reset();

View File

@ -1405,7 +1405,7 @@ void RevokePublicLinkBox::mousePressEvent(QMouseEvent *e) {
}
void RevokePublicLinkBox::mouseReleaseEvent(QMouseEvent *e) {
auto pressed = createAndSwap(_pressed);
auto pressed = base::take(_pressed);
setCursor((_selected || _pressed) ? style::cur_pointer : style::cur_default);
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;

View File

@ -274,7 +274,7 @@ void NotificationsBox::prepareNotificationSampleLarge() {
auto rectForName = rtlrect(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyTextTop, itemWidth, st::msgNameFont->height, w);
auto notifyText = st::dialogsTextFont->elided(lang(lng_notification_preview), itemWidth);
auto notifyText = st::dialogsTextFont->elided(lang(lng_notification_sample), itemWidth);
p.setFont(st::dialogsTextFont);
p.setPen(st::dialogsTextFgService);
p.drawText(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyItemTop + st::msgNameFont->height + st::dialogsTextFont->ascent, notifyText);
@ -398,7 +398,7 @@ void NotificationsBox::mousePressEvent(QMouseEvent *e) {
}
void NotificationsBox::mouseReleaseEvent(QMouseEvent *e) {
auto isDownCorner = createAndSwap(_isDownCorner);
auto isDownCorner = base::take(_isDownCorner);
if (isDownCorner && _isOverCorner && _downCorner == _overCorner && _downCorner != _chosenCorner) {
_chosenCorner = _downCorner;
update();

View File

@ -212,7 +212,7 @@ Efzk2DWgkBluml8OREmvfraX3bkHZJTKX4EQSjBbbdJ2ZXIsRrYOXfaA+xayEGB+\n\
8hdlLmAjbCVfaigxX0CDqWeR1yFL9kwd9P0NsZRPsmoqVwMbMu7mStFai6aIhc3n\n\
Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB\n\
-----END RSA PUBLIC KEY-----"};
keysCount = arraysize(keys);
keysCount = base::array_size(keys);
return keys;
}

View File

@ -60,7 +60,7 @@ public:
Subscription() = default;
Subscription(const Subscription &) = delete;
Subscription &operator=(const Subscription &) = delete;
Subscription(Subscription &&other) : _node(createAndSwap(other._node)), _removeMethod(other._removeMethod) {
Subscription(Subscription &&other) : _node(base::take(other._node)), _removeMethod(other._removeMethod) {
}
Subscription &operator=(Subscription &&other) {
qSwap(_node, other._node);
@ -255,7 +255,7 @@ public:
private:
void callHandlers() {
_handling = true;
auto events = createAndSwap(_events);
auto events = base::take(_events);
for (auto &event : events) {
this->notifyEnumerate([this, &event]() {
this->_current->handler(event);
@ -302,7 +302,7 @@ public:
private:
void callHandlers() {
_handling = true;
auto eventsCount = createAndSwap(_eventsCount);
auto eventsCount = base::take(_eventsCount);
for (int i = 0; i != eventsCount; ++i) {
this->notifyEnumerate([this]() {
this->_current->handler();
@ -349,7 +349,7 @@ protected:
}
~Subscriber() {
auto subscriptions = createAndSwap(_subscriptions);
auto subscriptions = base::take(_subscriptions);
for (auto &subscription : subscriptions) {
subscription.destroy();
}

View File

@ -22,23 +22,21 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "core/basic_types.h"
namespace base {
template <typename T, size_t N>
inline constexpr size_t arraysize(T(&ArrahSizeHelper)[N]) {
inline constexpr size_t array_size(T(&)[N]) {
return N;
}
template <typename T>
void deleteAndMark(T *&link) {
delete link;
link = reinterpret_cast<T*>(0x00000BAD);
inline T take(T &source) {
T result = T();
std_::swap(result, source);
return std_::move(result);
}
template <typename T>
T *getPointerAndReset(T *&ptr) {
T *result = nullptr;
qSwap(result, ptr);
return result;
}
} // namespace base
template <typename Enum>
inline QFlags<Enum> qFlags(Enum v) {
@ -87,13 +85,6 @@ inline void accumulate_max(T &a, const T &b) { if (a < b) a = b; }
template <typename T>
inline void accumulate_min(T &a, const T &b) { if (a > b) a = b; }
template <typename T>
T createAndSwap(T &value) {
T result = T();
std_::swap(result, value);
return std_::move(result);
}
static volatile int *t_assert_nullptr = nullptr;
inline void t_noop() {}
inline void t_assert_fail(const char *message, const char *file, int32 line) {
@ -477,7 +468,7 @@ public:
return _p;
}
T *release() {
return getPointerAndReset(_p);
return base::take(_p);
}
void reset(T *p = nullptr) {
delete _p;
@ -520,7 +511,7 @@ public:
return _p;
}
T *release() {
return getPointerAndReset(_p);
return base::take(_p);
}
void reset(T *p = nullptr) {
delete _p;

View File

@ -34,9 +34,9 @@ public:
vector_of_moveable(const vector_of_moveable &other) = delete;
vector_of_moveable &operator=(const vector_of_moveable &other) = delete;
vector_of_moveable(vector_of_moveable &&other)
: _size(createAndSwap(other._size))
, _capacity(createAndSwap(other._capacity))
, _plaindata(createAndSwap(other._plaindata)) {
: _size(base::take(other._size))
, _capacity(base::take(other._capacity))
, _plaindata(base::take(other._plaindata)) {
}
vector_of_moveable &operator=(vector_of_moveable &&other) {
std_::swap(_size, other._size);

View File

@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#define BETA_VERSION_MACRO (0ULL)
constexpr int AppVersion = 10012;
constexpr str_const AppVersionStr = "0.10.12";
constexpr int AppVersion = 10013;
constexpr str_const AppVersionStr = "0.10.13";
constexpr bool AppAlphaVersion = true;
constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;

View File

@ -232,7 +232,7 @@ void HistoryFileMedia::checkAnimationFinished() {
}
HistoryFileMedia::~HistoryFileMedia() {
deleteAndMark(_animation);
delete base::take(_animation);
}
HistoryPhoto::HistoryPhoto(HistoryItem *parent, PhotoData *photo, const QString &caption) : HistoryFileMedia(parent)

View File

@ -309,7 +309,7 @@ struct HistoryDocumentVoice : public RuntimeComponent<HistoryDocumentVoice> {
return *this;
}
~HistoryDocumentVoice() {
deleteAndMark(_playback);
delete base::take(_playback);
}
void ensurePlayback(const HistoryDocument *interfaces) const;
void checkPlaybackFinished() const;

View File

@ -3372,7 +3372,7 @@ void HistoryWidget::writeDrafts(Data::Draft **localDraft, Data::Draft **editDraf
}
}
if (!_editMsgId) {
if (!_editMsgId && !_inlineBot) {
_saveCloudDraftTimer.start(SaveCloudDraftIdleTimeout);
}
}
@ -5985,7 +5985,6 @@ bool HistoryWidget::hasSilentToggle() const {
void HistoryWidget::inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result) {
_inlineBotResolveRequestId = 0;
// Notify::inlineBotRequesting(false);
_inlineBotUsername = QString();
UserData *resolvedBot = nullptr;
if (result.type() == mtpc_contacts_resolvedPeer) {
const auto &d(result.c_contacts_resolvedPeer());
@ -8863,6 +8862,6 @@ bool HistoryWidget::touchScroll(const QPoint &delta) {
}
HistoryWidget::~HistoryWidget() {
deleteAndMark(_pinnedBar);
deleteAndMark(_list);
delete base::take(_pinnedBar);
delete base::take(_list);
}

View File

@ -29,7 +29,7 @@ constexpr const str_const LanguageCodes[] = {
"pt_BR",
"ko",
};
constexpr const int languageTest = -1, languageDefault = 0, languageCount = arraysize(LanguageCodes);
constexpr const int languageTest = -1, languageDefault = 0, languageCount = base::array_size(LanguageCodes);
class LangString : public QString {
public:

View File

@ -2655,7 +2655,7 @@ public:
virtual void readFromStream(QDataStream &stream, quint64 &first, quint64 &second, quint32 &type, QByteArray &data) = 0;
virtual void clearInMap() = 0;
virtual ~AbstractCachedLoadTask() {
deleteAndMark(_result);
delete base::take(_result);
}
protected:
@ -2931,7 +2931,7 @@ public:
}
}
virtual ~WebFileLoadTask() {
deleteAndMark(_result);
delete base::take(_result);
}
protected:

View File

@ -1015,8 +1015,7 @@ namespace internal {
#if !defined Q_OS_MAC || defined MAC_USE_BREAKPAD
if (internal::BreakpadExceptionHandler) {
google_breakpad::ExceptionHandler *h = getPointerAndReset(internal::BreakpadExceptionHandler);
delete h;
delete base::take(internal::BreakpadExceptionHandler);
}
#endif // !Q_OS_MAC || MAC_USE_BREAKPAD

View File

@ -75,7 +75,7 @@ AudioPlayerLoaders::~AudioPlayerLoaders() {
}
void AudioPlayerLoaders::clearFromVideoQueue() {
auto queue = createAndSwap(_fromVideoQueue);
auto queue = base::take(_fromVideoQueue);
for (auto &packetData : queue) {
AVPacket packet;
FFMpeg::packetFromDataWrap(packet, packetData);

View File

@ -197,7 +197,7 @@ void ChildFFMpegLoader::enqueuePackets(QQueue<FFMpeg::AVPacketDataWrap> &packets
}
ChildFFMpegLoader::~ChildFFMpegLoader() {
auto queue = createAndSwap(_queue);
auto queue = base::take(_queue);
for (auto &packetData : queue) {
AVPacket packet;
FFMpeg::packetFromDataWrap(packet, packetData);

View File

@ -525,7 +525,7 @@ void FFMpegReaderImplementation::finishPacket() {
void FFMpegReaderImplementation::clearPacketQueue() {
finishPacket();
auto packets = createAndSwap(_packetQueue);
auto packets = base::take(_packetQueue);
for (auto &packetData : packets) {
AVPacket packet;
FFMpeg::packetFromDataWrap(packet, packetData);

View File

@ -106,7 +106,7 @@ bool QtGifReaderImplementation::start(Mode mode, int64 &positionMs) {
}
QtGifReaderImplementation::~QtGifReaderImplementation() {
deleteAndMark(_reader);
delete base::take(_reader);
}
bool QtGifReaderImplementation::jumpToStart() {

View File

@ -619,7 +619,7 @@ void MediaView::clearData() {
}
MediaView::~MediaView() {
deleteAndMark(_menu);
delete base::take(_menu);
}
void MediaView::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) {

View File

@ -298,7 +298,7 @@ void AbstractTCPConnection::tcpSend(mtpBuffer &buffer) {
// prepare decryption key/iv
char reversed[48];
memcpy(reversed, nonce + 8, sizeof(reversed));
std::reverse(reversed, reversed + arraysize(reversed));
std::reverse(reversed, reversed + base::array_size(reversed));
memcpy(_receiveKey, reversed, CTRState::KeySize);
memcpy(_receiveState.ivec, reversed + CTRState::KeySize, CTRState::IvecSize);

View File

@ -98,8 +98,8 @@ void peerUpdatedSendDelayed() {
if (!SmallUpdates || !AllUpdates || SmallUpdates->empty()) return;
auto smallList = createAndSwap(*SmallUpdates);
auto allList = createAndSwap(*AllUpdates);
auto smallList = base::take(*SmallUpdates);
auto allList = base::take(*AllUpdates);
for (auto &update : smallList) {
PeerUpdated().notify(std_::move(update), true);
}

View File

@ -105,7 +105,7 @@ void RadialProgressItem::checkRadialFinished() {
}
RadialProgressItem::~RadialProgressItem() {
deleteAndMark(_radial);
delete base::take(_radial);
}
void FileBase::setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const {

View File

@ -226,7 +226,7 @@ void start() {
}
Manager *manager() {
if (Global::NativeNotifications()) {
if (Global::started() && Global::NativeNotifications()) {
return ManagerInstance.data();
}
return nullptr;
@ -412,7 +412,7 @@ void Manager::Impl::showNextNotification() {
void Manager::Impl::clearAll() {
_queuedNotifications.clear();
auto temp = createAndSwap(_notifications);
auto temp = base::take(_notifications);
for_const (auto &notifications, temp) {
for_const (auto notification, notifications) {
notification->close();
@ -431,7 +431,7 @@ void Manager::Impl::clearFromHistory(History *history) {
auto i = _notifications.find(history->peer->id);
if (i != _notifications.cend()) {
auto temp = createAndSwap(i.value());
auto temp = base::take(i.value());
_notifications.erase(i);
for_const (auto notification, temp) {

View File

@ -321,7 +321,7 @@ void start() {
}
Manager *manager() {
if (Global::NativeNotifications()) {
if (Global::started() && Global::NativeNotifications()) {
return ManagerInstance.data();
}
return nullptr;
@ -361,7 +361,7 @@ Manager::Impl::~Impl() {
void Manager::Impl::clearAll() {
if (!_notifier) return;
auto temp = createAndSwap(_notifications);
auto temp = base::take(_notifications);
for_const (auto &notifications, temp) {
for_const (auto &notification, notifications) {
_notifier->Hide(notification.p.Get());
@ -374,7 +374,7 @@ void Manager::Impl::clearFromHistory(History *history) {
auto i = _notifications.find(history->peer->id);
if (i != _notifications.cend()) {
auto temp = createAndSwap(i.value());
auto temp = base::take(i.value());
_notifications.erase(i);
for_const (auto &notification, temp) {

View File

@ -115,7 +115,7 @@ void ActionsWidget::resizeButton(Ui::LeftOutlineButton *button, int newWidth, in
}
void ActionsWidget::refreshButtons() {
auto buttons = createAndSwap(_buttons);
auto buttons = base::take(_buttons);
for_const (auto &button, buttons) {
delete button;
}

View File

@ -444,7 +444,7 @@ void CoverWidget::setChannelButtons() {
}
void CoverWidget::clearButtons() {
auto buttons = createAndSwap(_buttons);
auto buttons = base::take(_buttons);
for_const (auto button, buttons) {
delete button.widget;
delete button.replacement;

View File

@ -593,7 +593,7 @@ void MembersWidget::onUpdateOnlineDisplay() {
}
MembersWidget::~MembersWidget() {
auto members = createAndSwap(_membersByUser);
auto members = base::take(_membersByUser);
for_const (auto member, members) {
delete member;
}

View File

@ -478,12 +478,12 @@ QString strNotificationAboutThemeChange() {
QString strNotificationAboutScreenLocked() {
const uint32 letters[] = { 0x22008263, 0x0800DB6F, 0x45004F6D, 0xCC00972E, 0x0E00A861, 0x9700D970, 0xA100D570, 0x8900686C, 0xB300B365, 0xFE00DE2E, 0x76009B73, 0xFA00BF63, 0xE000A772, 0x9C009F65, 0x4E006065, 0xD900426E, 0xB7007849, 0x64006473, 0x6700824C, 0xE300706F, 0x7C00A063, 0x8F00D76B, 0x04001C65, 0x1C00A664 };
return strMakeFromLetters(letters, arraysize(letters));
return strMakeFromLetters(letters, base::array_size(letters));
}
QString strNotificationAboutScreenUnlocked() {
const uint32 letters[] = { 0x9200D763, 0xC8003C6F, 0xD2003F6D, 0x6000012E, 0x36004061, 0x4400E570, 0xA500BF70, 0x2E00796C, 0x4A009E65, 0x2E00612E, 0xC8001D73, 0x57002263, 0xF0005872, 0x49000765, 0xE5008D65, 0xE600D76E, 0xE8007049, 0x19005C73, 0x34009455, 0xB800B36E, 0xF300CA6C, 0x4C00806F, 0x5300A763, 0xD1003B6B, 0x63003565, 0xF800F264 };
return strMakeFromLetters(letters, arraysize(letters));
return strMakeFromLetters(letters, base::array_size(letters));
}
QString strStyleOfInterface() {

View File

@ -766,7 +766,7 @@ ImagePtr PhotoData::makeReplyPreview() {
}
PhotoData::~PhotoData() {
deleteAndMark(uploadingData);
delete base::take(uploadingData);
}
void PhotoOpenClickHandler::onClickImpl() const {

View File

@ -246,7 +246,7 @@ protected:
public:
virtual ~PeerData() {
if (notify != UnknownNotifySettings && notify != EmptyNotifySettings) {
deleteAndMark(notify);
delete base::take(notify);
}
}

View File

@ -37,7 +37,7 @@ public:
}
ReaderPointer(const ReaderPointer &other) = delete;
ReaderPointer &operator=(const ReaderPointer &other) = delete;
ReaderPointer(ReaderPointer &&other) : _pointer(createAndSwap(other._pointer)) {
ReaderPointer(ReaderPointer &&other) : _pointer(base::take(other._pointer)) {
}
ReaderPointer &operator=(ReaderPointer &&other) {
swap(other);
@ -323,7 +323,7 @@ public:
void start() { _implementation->start(); }
void step(Animation *a, uint64 ms, bool timer) { _implementation->step(a, ms, timer); }
~AnimationCallbacks() { deleteAndMark(_implementation); }
~AnimationCallbacks() { delete base::take(_implementation); }
private:
AnimationImplementation *_implementation;

View File

@ -294,14 +294,11 @@ void Manager::doClearAll() {
void Manager::doClearAllFast() {
_queuedNotifications.clear();
auto notifications = createAndSwap(_notifications);
auto notifications = base::take(_notifications);
for_const (auto notification, notifications) {
delete notification;
}
if (_hideAll) {
auto hideAll = createAndSwap(_hideAll);
delete hideAll;
}
delete base::take(_hideAll);
}
void Manager::doClearFromHistory(History *history) {
@ -321,6 +318,12 @@ void Manager::doClearFromHistory(History *history) {
}
void Manager::doClearFromItem(HistoryItem *item) {
for (auto i = 0, queuedCount = _queuedNotifications.size(); i != queuedCount; ++i) {
if (_queuedNotifications[i].item == item) {
_queuedNotifications.removeAt(i);
break;
}
}
for_const (auto notification, _notifications) {
// Calls unlinkFromShown() -> showNextFromQueue()
notification->itemRemoved(item);
@ -866,7 +869,7 @@ void HideAllButton::mousePressEvent(QMouseEvent *e) {
}
void HideAllButton::mouseReleaseEvent(QMouseEvent *e) {
auto mouseDown = createAndSwap(_mouseDown);
auto mouseDown = base::take(_mouseDown);
if (mouseDown && _mouseOver) {
if (auto manager = ManagerInstance.data()) {
manager->clearAll();

View File

@ -1,6 +1,6 @@
AppVersion 10012
AppVersion 10013
AppVersionStrMajor 0.10
AppVersionStrSmall 0.10.12
AppVersionStr 0.10.12
AppVersionStrSmall 0.10.13
AppVersionStr 0.10.13
AlphaChannel 1
BetaVersion 0