From ab16c88473f40726cdf904cb0362d9aa6876e82d Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 28 May 2019 01:28:49 +0300 Subject: [PATCH] Fixed crash from touchbar after logout. --- Telegram/SourceFiles/platform/mac/main_window_mac.mm | 5 +++-- Telegram/SourceFiles/platform/mac/touchbar.mm | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index 16e7c76b9..8e3f13b81 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -113,7 +113,7 @@ public: bool clipboardHasText(); - TouchBar *_touchBar = nullptr; + TouchBar *_touchBar = nil; ~Private(); @@ -424,8 +424,9 @@ void MainWindow::initTouchBar() { } else { if (_private->_touchBar) { [_private->_touchBar setTouchBar:Platform::TouchBarType::None]; + [_private->_touchBar release]; } - _private->_touchBar = nullptr; + _private->_touchBar = nil; } }); } diff --git a/Telegram/SourceFiles/platform/mac/touchbar.mm b/Telegram/SourceFiles/platform/mac/touchbar.mm index 379ad9ba8..9bb0cec71 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar.mm +++ b/Telegram/SourceFiles/platform/mac/touchbar.mm @@ -448,7 +448,8 @@ void PaintUnreadBadge(Painter &p, PeerData *peer) { NSStackView *stackView = [[NSStackView alloc] init]; for (auto i = kArchiveId; i <= Global::PinnedDialogsCountMax(); i++) { - PinnedDialogButton *button = [[PinnedDialogButton alloc] init:i]; + PinnedDialogButton *button = + [[[PinnedDialogButton alloc] init:i] autorelease]; [_mainPinnedButtons addObject:button]; if (i == kArchiveId) { button.isDeletedFromView = true; @@ -686,4 +687,11 @@ void PaintUnreadBadge(Painter &p, PeerData *peer) { }); } +-(void)dealloc { + for (PinnedDialogButton *button in _mainPinnedButtons) { + [button release]; + } + [super dealloc]; +} + @end