Fix touchbar destruction with Window.

This commit is contained in:
John Preston 2020-06-29 22:12:40 +04:00
parent a8d0b80baa
commit eff340deaf
3 changed files with 23 additions and 8 deletions

View File

@ -454,6 +454,7 @@ void AppendEmojiPacks(
@interface PinnedDialogsPanel : NSImageView
- (id)init:(not_null<Main::Session*>)session;
- (void)dealloc;
@end // @interface PinnedDialogsPanel
@implementation PinnedDialogsPanel {
@ -770,6 +771,9 @@ void AppendEmojiPacks(
const auto updatePanelSize = [=] {
const auto size = lastDialogsCount->current();
if (self.image) {
[self.image release];
}
self.image = [[NSImage alloc] initWithSize:NSMakeSize(
size * (kCircleDiameter + kPinnedButtonsSpace)
+ kPinnedButtonsLeftSkip
@ -990,6 +994,13 @@ void AppendEmojiPacks(
return self;
}
- (void)dealloc {
if (self.image) {
[self.image release];
}
[super dealloc];
}
- (int)shift {
return (_hasArchive ? 1 : 0) + (_selfUnpinned ? 1 : 0);
}
@ -1890,6 +1901,8 @@ void AppendEmojiPacks(
}
-(void)dealloc {
[_touchBarMain release];
[_touchBarAudioPlayer release];
[super dealloc];
}

View File

@ -96,6 +96,7 @@ private:
void hideAndDeactivate();
void updateTitleCounter();
void updateIconCounters();
void destroyCurrentTouchBar();
std::unique_ptr<Private> _private;

View File

@ -491,14 +491,6 @@ void MainWindow::initTouchBar() {
}
};
const auto destroyCurrentTouchBar = [=] {
if (_private->_touchBar) {
[_private->_touchBar setTouchBar:Platform::TouchBarType::None];
[_private->_touchBar release];
}
_private->_touchBar = nil;
};
Core::App().domain().activeSessionChanges(
) | rpl::start_with_next([=](Main::Session *session) {
if (session) {
@ -512,6 +504,14 @@ void MainWindow::initTouchBar() {
}, lifetime());
}
void MainWindow::destroyCurrentTouchBar() {
if (_private->_touchBar) {
[_private->_touchBar setTouchBar:Platform::TouchBarType::None];
[_private->_touchBar release];
}
_private->_touchBar = nil;
}
void MainWindow::closeWithoutDestroy() {
NSWindow *nsWindow = [reinterpret_cast<NSView*>(winId()) window];
@ -875,6 +875,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *evt) {
}
MainWindow::~MainWindow() {
destroyCurrentTouchBar();
}
} // namespace