diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 2915f02ac..d196f3249 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -1410,7 +1410,7 @@ namespace App { QString uname(username.trimmed()); for (PeersData::const_iterator i = peersData.cbegin(), e = peersData.cend(); i != e; ++i) { if (!i.value()->userName().compare(uname, Qt::CaseInsensitive)) { - return i.value()->asUser(); + return i.value(); } } return 0; diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 1750f0250..fda6a00a2 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -63,11 +63,26 @@ namespace App { } void removeDialog(History *history) { - if (MainWidget *m = main()) m->removeDialog(history); + if (MainWidget *m = main()) { + m->removeDialog(history); + } } void showSettings() { - if (Window *win = wnd()) win->showSettings(); + if (Window *w = wnd()) { + w->showSettings(); + } + } + + Q_DECLARE_METATYPE(TextLinkPtr); + Q_DECLARE_METATYPE(Qt::MouseButton); + + void activateTextLink(TextLinkPtr link, Qt::MouseButton button) { + if (Window *w = wnd()) { + qRegisterMetaType(); + qRegisterMetaType(); + QMetaObject::invokeMethod(w, "app_activateTextLink", Qt::QueuedConnection, Q_ARG(TextLinkPtr, link), Q_ARG(Qt::MouseButton, button)); + } } } diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 43da4a026..074e0ab24 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -35,6 +35,8 @@ namespace App { void removeDialog(History *history); void showSettings(); + void activateTextLink(TextLinkPtr link, Qt::MouseButton button); + }; namespace Ui { diff --git a/Telegram/SourceFiles/gui/popupmenu.cpp b/Telegram/SourceFiles/gui/popupmenu.cpp index f116dce00..8fb99d7d5 100644 --- a/Telegram/SourceFiles/gui/popupmenu.cpp +++ b/Telegram/SourceFiles/gui/popupmenu.cpp @@ -81,7 +81,7 @@ void PopupMenu::init() { QAction *PopupMenu::addAction(const QString &text, const QObject *receiver, const char* member) { QAction *a = new QAction(text, this); - connect(a, SIGNAL(triggered(bool)), receiver, member); + connect(a, SIGNAL(triggered(bool)), receiver, member, Qt::QueuedConnection); return addAction(a); } diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index b27b6aac0..6ad8a9bca 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -681,8 +681,9 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) { int32 addToH = 0, skip = 0; if (!blocks.isEmpty()) { // remove date block if (width) addToH = -blocks.front()->height; - delete blocks.front(); + HistoryBlock *dateblock = blocks.front(); blocks.pop_front(); + delete dateblock; } HistoryItem *till = blocks.isEmpty() ? 0 : blocks.front()->items.front(); diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index e8b353966..a7e5a3595 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -684,11 +684,12 @@ void HistoryInner::itemRemoved(HistoryItem *item) { dragActionCancel(); } + if (_dragSelFrom == item || _dragSelTo == item) { + _dragSelFrom = 0; + _dragSelTo = 0; + update(); + } onUpdateSelected(); - - if (_dragSelFrom == item) _dragSelFrom = 0; - if (_dragSelTo == item) _dragSelTo = 0; - updateDragSelection(_dragSelFrom, _dragSelTo, _dragSelecting, true); } void HistoryInner::dragActionFinish(const QPoint &screenPos, Qt::MouseButton button) { @@ -730,10 +731,9 @@ void HistoryInner::dragActionFinish(const QPoint &screenPos, Qt::MouseButton but _wasSelectedText = false; if (needClick) { - DEBUG_LOG(("Clicked link: %1 (%2) %3").arg(needClick->text()).arg(needClick->readable()).arg(needClick->encoded())); + DEBUG_LOG(("Will click link: %1 (%2) %3").arg(needClick->text()).arg(needClick->readable()).arg(needClick->encoded())); dragActionCancel(); - - needClick->onClick(button); // this possibly can delete this object + App::activateTextLink(needClick, button); return; } if (_dragAction == PrepareSelect && !_dragWasInactive && !_selected.isEmpty() && _selected.cbegin().value() == FullSelection) { diff --git a/Telegram/SourceFiles/mtproto/mtpConnection.cpp b/Telegram/SourceFiles/mtproto/mtpConnection.cpp index e9c8502db..5f42edecd 100644 --- a/Telegram/SourceFiles/mtproto/mtpConnection.cpp +++ b/Telegram/SourceFiles/mtproto/mtpConnection.cpp @@ -606,7 +606,7 @@ void MTPabstractTcpConnection::socketRead() { longBuffer.clear(); } else if (!readingToShort && packetRead < MTPShortBufferSize * sizeof(mtpPrime)) { memcpy(shortBuffer, currentPos - packetRead, packetRead); - currentPos = (char*)shortBuffer; + currentPos = (char*)shortBuffer + packetRead; readingToShort = true; longBuffer.clear(); } diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index 90757d14e..380385068 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -199,15 +199,15 @@ void PeerData::fillNames() { names.clear(); chars.clear(); QString toIndex = textAccentFold(name); + if (cRussianLetters().match(toIndex).hasMatch()) { + toIndex += ' ' + translitRusEng(toIndex); + } if (isUser()) { if (!asUser()->nameOrPhone.isEmpty() && asUser()->nameOrPhone != name) toIndex += ' ' + textAccentFold(asUser()->nameOrPhone); if (!asUser()->username.isEmpty()) toIndex += ' ' + textAccentFold(asUser()->username); } else if (isChannel()) { if (!asChannel()->username.isEmpty()) toIndex += ' ' + textAccentFold(asChannel()->username); } - if (cRussianLetters().match(toIndex).hasMatch()) { - toIndex += ' ' + translitRusEng(toIndex); - } toIndex += ' ' + rusKeyboardLayoutSwitch(toIndex); QStringList namesList = toIndex.toLower().split(cWordSplit(), QString::SkipEmptyParts); diff --git a/Telegram/SourceFiles/types.cpp b/Telegram/SourceFiles/types.cpp index 67adc1560..706cae9c4 100644 --- a/Telegram/SourceFiles/types.cpp +++ b/Telegram/SourceFiles/types.cpp @@ -811,8 +811,7 @@ QString translitRusEng(const QString &rus) { result.reserve(rus.size() * 2); int32 toSkip = 0; - for (QString::const_iterator i = rus.cbegin(), e = rus.cend(); i != e;) { - i += toSkip; + for (QString::const_iterator i = rus.cbegin(), e = rus.cend(); i != e; i += toSkip) { result += translitLetterRusEng(*i, (i + 1 == e) ? ' ' : *(i + 1), toSkip); } return result; diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index 9c6b19c64..749c7a977 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -1651,6 +1651,10 @@ void Window::notifyUpdateAllPhotos() { if (_mediaView && !_mediaView->isHidden()) _mediaView->updateControls(); } +void Window::app_activateTextLink(TextLinkPtr link, Qt::MouseButton button) { + link->onClick(button); +} + void Window::notifyUpdateAll() { if (cCustomNotifies()) { for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) { diff --git a/Telegram/SourceFiles/window.h b/Telegram/SourceFiles/window.h index 63c1675d0..af821859f 100644 --- a/Telegram/SourceFiles/window.h +++ b/Telegram/SourceFiles/window.h @@ -281,6 +281,8 @@ public slots: void notifyUpdateAllPhotos(); + void app_activateTextLink(TextLinkPtr link, Qt::MouseButton button); + signals: void resized(const QSize &size);