From 57b771c879499f13eeac0b9f37d0ebe39782e382 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 17 Feb 2016 20:14:09 +0300 Subject: [PATCH] some possible crashes fixed, showing maps app on os x --- Telegram/SourceFiles/apiwrap.cpp | 4 +++- Telegram/SourceFiles/dialogswidget.cpp | 2 ++ Telegram/SourceFiles/history.cpp | 3 ++- Telegram/SourceFiles/historywidget.cpp | 2 +- Telegram/SourceFiles/pspecific_mac.cpp | 8 ++++---- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index ac9034059..e529b1f74 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -346,7 +346,9 @@ void ApiWrap::gotUserFull(PeerData *peer, const MTPUserFull &result, mtpRequestI App::feedUsers(MTP_vector(1, d.vuser), false); App::feedPhoto(d.vprofile_photo); App::feedUserLink(MTP_int(peerToUser(peer->id)), d.vlink.c_contacts_link().vmy_link, d.vlink.c_contacts_link().vforeign_link, false); - App::main()->gotNotifySetting(MTP_inputNotifyPeer(peer->input), d.vnotify_settings); + if (App::main()) { + App::main()->gotNotifySetting(MTP_inputNotifyPeer(peer->input), d.vnotify_settings); + } peer->asUser()->setBotInfo(d.vbot_info); peer->asUser()->blocked = mtpIsTrue(d.vblocked) ? UserIsBlocked : UserIsNotBlocked; diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index 889580af4..fca26a14b 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -1366,6 +1366,8 @@ void DialogsInner::selectSkipPage(int32 pixels, int32 direction) { } void DialogsInner::loadPeerPhotos(int32 yFrom) { + if (!parentWidget()) return; + int32 yTo = yFrom + parentWidget()->height() * 5; MTP::clearLoaderPriorities(); if (_state == DefaultState) { diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index eeda88bf7..66f360847 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -5982,7 +5982,8 @@ HistoryMessageVia::HistoryMessageVia(Interfaces *) } void HistoryMessageVia::create(int32 userId) { - if (bot = App::userLoaded(peerFromUser(userId))) { + bot = App::userLoaded(peerFromUser(userId)); + if (bot) { maxWidth = st::msgServiceNameFont->width(lng_inline_bot_via(lt_inline_bot, '@' + bot->username)); lnk.reset(new ViaInlineBotLink(bot)); } diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index d197e5459..24105a372 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -7159,7 +7159,7 @@ void HistoryWidget::drawRecording(Painter &p) { } void HistoryWidget::paintEvent(QPaintEvent *e) { - if (App::wnd() && App::wnd()->contentOverlapped(this, e)) return; + if (!App::main() || (App::wnd() && App::wnd()->contentOverlapped(this, e))) return; Painter p(this); QRect r(e->rect()); diff --git a/Telegram/SourceFiles/pspecific_mac.cpp b/Telegram/SourceFiles/pspecific_mac.cpp index edaaa92ab..c3bbde72b 100644 --- a/Telegram/SourceFiles/pspecific_mac.cpp +++ b/Telegram/SourceFiles/pspecific_mac.cpp @@ -902,6 +902,10 @@ QByteArray psPathBookmark(const QString &path) { return objc_pathBookmark(path); } +bool psLaunchMaps(const QString &lat, const QString &lon) { + return QDesktopServices::openUrl(qsl("https://maps.apple.com/?q=Point&z=16&ll=%1,%2").arg(lat).arg(lon)); +} + QString strNotificationAboutThemeChange() { const uint32 letters[] = { 0xE9005541, 0x5600DC70, 0x88001570, 0xF500D86C, 0x8100E165, 0xEE005949, 0x2900526E, 0xAE00FB74, 0x96000865, 0x7000CD72, 0x3B001566, 0x5F007361, 0xAE00B663, 0x74009A65, 0x29003054, 0xC6002668, 0x98003865, 0xFA00336D, 0xA3007A65, 0x93001443, 0xBB007868, 0xE100E561, 0x3500366E, 0xC0007A67, 0x200CA65, 0xBE00DF64, 0xE300BB4E, 0x2900D26F, 0xD500D374, 0xE900E269, 0x86008F66, 0xC4006669, 0x1C00A863, 0xE600A761, 0x8E00EE74, 0xB300B169, 0xCF00B36F, 0xE600D36E }; return strMakeFromLetters(letters, sizeof(letters) / sizeof(letters[0])); @@ -926,7 +930,3 @@ QString strNeedToRefresh2() { const uint32 letters[] = { 0x8F001546, 0xAF007A49, 0xB8002B5F, 0x1A000B54, 0xD003E49, 0xE0003663, 0x4900796F, 0x500836E, 0x9A00D156, 0x5E00FF69, 0x5900C765, 0x3D00D177 }; return strMakeFromLetters(letters, sizeof(letters) / sizeof(letters[0])); } - -bool psLaunchMaps(const QString &lat, const QString &lon) { - return false; -}