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/application.cpp b/Telegram/SourceFiles/application.cpp index f9c77dfc0..b414fdb39 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -925,7 +925,9 @@ void AppClass::checkLocalTime() { void AppClass::onAppStateChanged(Qt::ApplicationState state) { checkLocalTime(); - _window->updateIsActive((state == Qt::ApplicationActive) ? cOnlineFocusTimeout() : cOfflineBlurTimeout()); + if (_window) { + _window->updateIsActive((state == Qt::ApplicationActive) ? cOnlineFocusTimeout() : cOfflineBlurTimeout()); + } if (state != Qt::ApplicationActive) { PopupTooltip::Hide(); } 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/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index a7e5a3595..35ca99daa 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -844,10 +844,10 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } else { uint16 symbol, selFrom = (_selected.cbegin().value() >> 16) & 0xFFFF, selTo = _selected.cbegin().value() & 0xFFFF; hasSelected = (selTo > selFrom) ? 1 : 0; - if (_dragItem && _dragItem == App::hoveredItem()) { - QPoint mousePos(mapMouseToItem(mapFromGlobal(_dragPos), _dragItem)); + if (App::mousedItem() && App::mousedItem() == App::hoveredItem()) { + QPoint mousePos(mapMouseToItem(mapFromGlobal(_dragPos), App::mousedItem())); bool afterDragSymbol, uponSymbol; - _dragItem->getSymbol(symbol, afterDragSymbol, uponSymbol, mousePos.x(), mousePos.y()); + App::mousedItem()->getSymbol(symbol, afterDragSymbol, uponSymbol, mousePos.x(), mousePos.y()); if (uponSymbol && symbol >= selFrom && symbol < selTo) { isUponSelected = 1; } @@ -7148,7 +7148,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/profilewidget.cpp b/Telegram/SourceFiles/profilewidget.cpp index 313709f18..665ed2b66 100644 --- a/Telegram/SourceFiles/profilewidget.cpp +++ b/Telegram/SourceFiles/profilewidget.cpp @@ -1077,6 +1077,15 @@ void ProfileInner::mouseReleaseEvent(QMouseEvent *e) { connect(box, SIGNAL(confirmed()), this, SLOT(onKickConfirm())); Ui::showLayer(box); } + + _kickDown = 0; + if (!_photoLink && (_peerUser || (_peerChat && !_peerChat->canEdit()) || (_peerChannel && !_amCreator))) { + setCursor((_kickOver || _kickDown || textlnkOver()) ? style::cur_pointer : style::cur_default); + } else { + setCursor((_kickOver || _kickDown || _photoOver || textlnkOver()) ? style::cur_pointer : style::cur_default); + } + update(); + if (textlnkDown()) { TextLinkPtr lnk = textlnkDown(); textlnkDown(TextLinkPtr()); @@ -1087,17 +1096,10 @@ void ProfileInner::mouseReleaseEvent(QMouseEvent *e) { if (reBotCommand().match(lnk->encoded()).hasMatch()) { Ui::showPeerHistory(_peer, ShowAtTheEndMsgId); } - lnk->onClick(e->button()); + App::activateTextLink(lnk, e->button()); } } } - _kickDown = 0; - if (!_photoLink && (_peerUser || (_peerChat && !_peerChat->canEdit()) || (_peerChannel && !_amCreator))) { - setCursor((_kickOver || _kickDown || textlnkOver()) ? style::cur_pointer : style::cur_default); - } else { - setCursor((_kickOver || _kickDown || _photoOver || textlnkOver()) ? style::cur_pointer : style::cur_default); - } - update(); } void ProfileInner::onKickConfirm() { diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index 380385068..1c05b266a 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -688,11 +688,12 @@ void PhotoCancelLink::onClick(Qt::MouseButton button) const { if (!data->date) return; if (data->uploading()) { - HistoryItem *item = App::hoveredLinkItem() ? App::hoveredLinkItem() : (App::contextItem() ? App::contextItem() : 0); - if (HistoryMessage *msg = item->toHistoryMessage()) { - if (msg->getMedia() && msg->getMedia()->type() == MediaTypePhoto && static_cast(msg->getMedia())->photo() == data) { - App::contextItem(item); - App::main()->deleteLayer(-2); + if (HistoryItem *item = App::hoveredLinkItem() ? App::hoveredLinkItem() : (App::contextItem() ? App::contextItem() : 0)) { + if (HistoryMessage *msg = item->toHistoryMessage()) { + if (msg->getMedia() && msg->getMedia()->type() == MediaTypePhoto && static_cast(msg->getMedia())->photo() == data) { + App::contextItem(item); + App::main()->deleteLayer(-2); + } } } } else { @@ -964,11 +965,12 @@ void DocumentCancelLink::onClick(Qt::MouseButton button) const { if (!data->date) return; if (data->uploading()) { - HistoryItem *item = App::hoveredLinkItem() ? App::hoveredLinkItem() : (App::contextItem() ? App::contextItem() : 0); - if (HistoryMessage *msg = item->toHistoryMessage()) { - if (msg->getMedia() && msg->getMedia()->getDocument() == data) { - App::contextItem(item); - App::main()->deleteLayer(-2); + if (HistoryItem *item = App::hoveredLinkItem() ? App::hoveredLinkItem() : (App::contextItem() ? App::contextItem() : 0)) { + if (HistoryMessage *msg = item->toHistoryMessage()) { + if (msg->getMedia() && msg->getMedia()->getDocument() == data) { + App::contextItem(item); + App::main()->deleteLayer(-2); + } } } } else { diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index 52f823b27..1209ffc3e 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -2730,7 +2730,7 @@ void LastCrashedWindow::onUpdateFailed() { void LastCrashedWindow::onContinue() { if (SignalHandlers::restart() == SignalHandlers::CantOpen) { new NotStartedWindow(); - } else { + } else if (!Global::started()) { Sandbox::launch(); } close();