Merge branch 'master' into dev

This commit is contained in:
John Preston 2016-03-15 15:25:49 +03:00
commit 281f762869
18 changed files with 189 additions and 132 deletions

View file

@ -20,8 +20,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#pragma once
static const int32 AppVersion = 9031;
static const wchar_t *AppVersionStr = L"0.9.31";
static const int32 AppVersion = 9032;
static const wchar_t *AppVersionStr = L"0.9.32";
static const bool DevVersion = false;
//#define BETA_VERSION (9030002ULL) // just comment this line to build public version

View file

@ -852,16 +852,19 @@ HistoryItem *ChannelHistory::addNewToBlocks(const MTPMessage &msg, NewMessageTyp
clear(true);
}
HistoryBlock *to = 0;
HistoryBlock *to = nullptr;
bool newBlock = blocks.isEmpty();
if (newBlock) {
to = new HistoryBlock(this);
} else {
to = blocks.back();
t_assert(!to->items.isEmpty());
t_assert(to->items.back() != nullptr);
}
HistoryItem *item = createItem((type == NewMessageLast) ? 0 : to, msg, (type == NewMessageUnread));
if (type == NewMessageLast) {
HistoryItem *item = createItem((type == NewMessageLast) ? nullptr : to, msg, (type == NewMessageUnread));
if (type == NewMessageLast && item) {
if (!item->detached()) {
t_assert(!newBlock);
return item;
}
item->attach(to);
@ -896,10 +899,8 @@ void ChannelHistory::switchMode() {
OtherList savedList;
if (!blocks.isEmpty()) {
savedList.reserve(((blocks.size() - 2) * MessagesPerPage + blocks.back()->items.size()) * (onlyImportant() ? 2 : 1));
for (Blocks::const_iterator i = blocks.cbegin(), e = blocks.cend(); i != e; ++i) {
HistoryBlock *block = *i;
for (HistoryBlock::Items::const_iterator j = block->items.cbegin(), end = block->items.cend(); j != end; ++j) {
HistoryItem *item = *j;
for_const (const HistoryBlock *block, blocks) {
for_const (HistoryItem *item, block->items) {
HistoryItemType itemType = item->type();
if (itemType == HistoryItemMsg || itemType == HistoryItemGroup) {
savedList.push_back(item);
@ -994,7 +995,7 @@ HistoryBlock *ChannelHistory::findGroupBlock(MsgId msgId) const { // find block
if (blocks.size() > 1) for (int32 minBlock = 0, maxBlock = blocks.size();;) {
for (int32 startCheckBlock = (minBlock + maxBlock) / 2, checkBlock = startCheckBlock;;) {
HistoryBlock *block = blocks.at(checkBlock);
HistoryBlock::Items::const_iterator i = block->items.cbegin(), e = block->items.cend();
auto i = block->items.cbegin(), e = block->items.cend();
for (; i != e; ++i) { // out msgs could be a mess in monotonic ids
if (((*i)->id > 0 && !(*i)->out()) || (*i)->type() == HistoryItemGroup) {
MsgId threshold = ((*i)->id > 0) ? (*i)->id : static_cast<HistoryGroup*>(*i)->minId();
@ -1106,6 +1107,12 @@ void ChannelHistory::messageWithIdDeleted(MsgId msgId) {
}
}
ChannelHistory::~ChannelHistory() {
// all items must be destroyed before ChannelHistory is destroyed
// or they will call history()->asChannelHistory() -> undefined behaviour
clearOnDestroy();
}
bool DialogsList::del(const PeerId &peerId, DialogRow *replacedBy) {
RowByPeer::iterator i = rowByPeer.find(peerId);
if (i == rowByPeer.cend()) return false;
@ -1299,7 +1306,7 @@ HistoryItem *History::createItem(HistoryBlock *block, const MTPMessage &msg, boo
case mtpc_message: msgId = msg.c_message().vid.v; break;
case mtpc_messageService: msgId = msg.c_messageService().vid.v; break;
}
if (!msgId) return 0;
if (!msgId) return nullptr;
HistoryItem *result = App::histItemById(channelId(), msgId);
if (result) {
@ -1574,6 +1581,8 @@ HistoryItem *History::addNewService(MsgId msgId, QDateTime date, const QString &
to = new HistoryBlock(this);
} else {
to = blocks.back();
t_assert(!to->items.isEmpty());
t_assert(to->items.back() != nullptr);
}
HistoryItem *result = new HistoryServiceMsg(this, to, msgId, date, text, flags, media);
@ -1595,16 +1604,19 @@ HistoryItem *History::addNewMessage(const MTPMessage &msg, NewMessageType type)
return item;
}
HistoryBlock *to = 0;
HistoryBlock *to = nullptr;
bool newBlock = blocks.isEmpty();
if (newBlock) {
to = new HistoryBlock(this);
} else {
to = blocks.back();
t_assert(!to->items.isEmpty());
t_assert(to->items.back() != nullptr);
}
HistoryItem *item = createItem((type == NewMessageLast) ? 0 : to, msg, (type == NewMessageUnread));
if (type == NewMessageLast) {
HistoryItem *item = createItem((type == NewMessageLast) ? nullptr : to, msg, (type == NewMessageUnread));
if (type == NewMessageLast && item) {
if (!item->detached()) {
t_assert(!newBlock);
return item;
}
item->attach(to);
@ -1613,16 +1625,18 @@ HistoryItem *History::addNewMessage(const MTPMessage &msg, NewMessageType type)
}
HistoryItem *History::addToHistory(const MTPMessage &msg) {
return createItem(0, msg, false);
return createItem(nullptr, msg, false);
}
HistoryItem *History::addNewForwarded(MsgId id, int32 flags, QDateTime date, int32 from, HistoryMessage *item) {
HistoryBlock *to = 0;
HistoryBlock *to = nullptr;
bool newBlock = blocks.isEmpty();
if (newBlock) {
to = new HistoryBlock(this);
} else {
to = blocks.back();
t_assert(!to->items.isEmpty());
t_assert(to->items.back() != nullptr);
}
return addNewItem(to, newBlock, createItemForwarded(to, id, flags, date, from, item), true);
}
@ -1634,6 +1648,8 @@ HistoryItem *History::addNewDocument(MsgId id, int32 flags, int32 viaBotId, MsgI
to = new HistoryBlock(this);
} else {
to = blocks.back();
t_assert(!to->items.isEmpty());
t_assert(to->items.back() != nullptr);
}
return addNewItem(to, newBlock, createItemDocument(to, id, flags, viaBotId, replyTo, date, from, doc, caption), true);
}
@ -1645,6 +1661,8 @@ HistoryItem *History::addNewPhoto(MsgId id, int32 flags, int32 viaBotId, MsgId r
to = new HistoryBlock(this);
} else {
to = blocks.back();
t_assert(!to->items.isEmpty());
t_assert(to->items.back() != nullptr);
}
return addNewItem(to, newBlock, createItemPhoto(to, id, flags, viaBotId, replyTo, date, from, photo, caption), true);
}
@ -1913,10 +1931,10 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
const MTPMessageGroup *groupsBegin = (isChannel() && collapsed) ? collapsed->constData() : 0, *groupsIt = groupsBegin, *groupsEnd = (isChannel() && collapsed) ? (groupsBegin + collapsed->size()) : 0;
HistoryItem *oldFirst = 0, *last = 0;
HistoryItem *oldFirst = nullptr, *last = nullptr;
HistoryBlock *block = new HistoryBlock(this);
block->items.reserve(slice.size() + (collapsed ? collapsed->size() : 0));
for (QVector<MTPmessage>::const_iterator i = slice.cend(), e = slice.cbegin(); i != e;) {
for (auto i = slice.cend(), e = slice.cbegin(); i != e;) {
--i;
HistoryItem *adding = createItem(block, *i, false);
if (!adding) continue;
@ -2079,11 +2097,11 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
if (!slice.isEmpty() || (isChannel() && collapsed && !collapsed->isEmpty())) {
const MTPMessageGroup *groupsBegin = (isChannel() && collapsed) ? collapsed->constData() : 0, *groupsIt = groupsBegin, *groupsEnd = (isChannel() && collapsed) ? (groupsBegin + collapsed->size()) : 0;
HistoryItem *prev = blocks.isEmpty() ? 0 : blocks.back()->items.back();
HistoryItem *prev = blocks.isEmpty() ? nullptr : blocks.back()->items.back();
HistoryBlock *block = new HistoryBlock(this);
block->items.reserve(slice.size() + (collapsed ? collapsed->size() : 0));
for (QVector<MTPmessage>::const_iterator i = slice.cend(), e = slice.cbegin(); i != e;) {
for (auto i = slice.cend(), e = slice.cbegin(); i != e;) {
--i;
HistoryItem *adding = createItem(block, *i, false);
if (!adding) continue;
@ -2148,9 +2166,9 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
int32 History::countUnread(MsgId upTo) {
int32 result = 0;
for (Blocks::const_iterator i = blocks.cend(), e = blocks.cbegin(); i != e;) {
for (auto i = blocks.cend(), e = blocks.cbegin(); i != e;) {
--i;
for (HistoryBlock::Items::const_iterator j = (*i)->items.cend(), en = (*i)->items.cbegin(); j != en;) {
for (auto j = (*i)->items.cend(), en = (*i)->items.cbegin(); j != en;) {
--j;
if ((*j)->id > 0 && (*j)->id <= upTo) {
break;
@ -2165,9 +2183,9 @@ int32 History::countUnread(MsgId upTo) {
void History::updateShowFrom() {
if (showFrom) return;
for (Blocks::const_iterator i = blocks.cend(); i != blocks.cbegin();) {
for (auto i = blocks.cend(); i != blocks.cbegin();) {
--i;
for (HistoryBlock::Items::const_iterator j = (*i)->items.cend(); j != (*i)->items.cbegin();) {
for (auto j = (*i)->items.cend(); j != (*i)->items.cbegin();) {
--j;
if ((*j)->type() == HistoryItemMsg && (*j)->id > 0 && (!(*j)->out() || !showFrom)) {
if ((*j)->id >= inboxReadBefore) {
@ -2463,10 +2481,10 @@ void History::fixLastMessage(bool wasAtBottom) {
}
MsgId History::minMsgId() const {
for (Blocks::const_iterator i = blocks.cbegin(), e = blocks.cend(); i != e; ++i) {
for (HistoryBlock::Items::const_iterator j = (*i)->items.cbegin(), en = (*i)->items.cend(); j != en; ++j) {
if ((*j)->id > 0) {
return (*j)->id;
for_const (const HistoryBlock *block, blocks) {
for_const (const HistoryItem *item, block->items) {
if (item->id > 0) {
return item->id;
}
}
}
@ -2474,9 +2492,9 @@ MsgId History::minMsgId() const {
}
MsgId History::maxMsgId() const {
for (Blocks::const_iterator i = blocks.cend(), e = blocks.cbegin(); i != e;) {
for (auto i = blocks.cend(), e = blocks.cbegin(); i != e;) {
--i;
for (HistoryBlock::Items::const_iterator j = (*i)->items.cend(), en = (*i)->items.cbegin(); j != en;) {
for (auto j = (*i)->items.cend(), en = (*i)->items.cbegin(); j != en;) {
--j;
if ((*j)->id > 0) {
return (*j)->id;
@ -2547,14 +2565,7 @@ void History::clear(bool leaveItems) {
if (App::wnd() && !App::quitting()) App::wnd()->mediaOverviewUpdated(peer, MediaOverviewType(i));
}
}
Blocks lst = blocks;
blocks.clear();
for (Blocks::const_iterator i = lst.cbegin(), e = lst.cend(); i != e; ++i) {
if (leaveItems) {
(*i)->clear(true);
}
delete *i;
}
clearBlocks(leaveItems);
if (leaveItems) {
lastKeyboardInited = false;
} else {
@ -2574,6 +2585,21 @@ void History::clear(bool leaveItems) {
if (leaveItems && App::main()) App::main()->historyCleared(this);
}
void History::clearBlocks(bool leaveItems) {
Blocks lst;
std::swap(lst, blocks);
for_const (HistoryBlock *block, lst) {
if (leaveItems) {
block->clear(true);
}
delete block;
}
}
void History::clearOnDestroy() {
clearBlocks(false);
}
QPair<int32, int32> History::adjustByPosInChatsList(DialogsIndexed &indexed) {
int32 movedFrom = _chatListLinks[0]->pos * st::dlgHeight;
indexed.adjustByPos(_chatListLinks);
@ -2716,12 +2742,6 @@ void History::blockResized(HistoryBlock *block, int32 dh) {
}
}
void History::clearUpto(MsgId msgId) {
for (HistoryItem *item = isEmpty() ? 0 : blocks.back()->items.back(); item && (item->id < 0 || item->id >= msgId); item = isEmpty() ? 0 : blocks.back()->items.back()) {
item->destroy();
}
}
void History::removeBlock(HistoryBlock *block) {
int32 i = blocks.indexOf(block), h = block->height;
if (i >= 0) {
@ -2741,15 +2761,14 @@ void History::removeBlock(HistoryBlock *block) {
}
History::~History() {
clear();
clearOnDestroy();
deleteAndMark(msgDraft);
deleteAndMark(editDraft);
}
int32 HistoryBlock::geomResize(int32 newWidth, int32 *ytransform, const HistoryItem *resizedItem) {
int32 y = 0;
for (Items::iterator i = items.begin(), e = items.end(); i != e; ++i) {
HistoryItem *item = *i;
for_const (HistoryItem *item , items) {
bool updTransform = ytransform && (*ytransform >= item->y) && (*ytransform < item->y + item->height());
if (updTransform) *ytransform -= item->y;
item->y = y;
@ -2768,15 +2787,16 @@ int32 HistoryBlock::geomResize(int32 newWidth, int32 *ytransform, const HistoryI
}
void HistoryBlock::clear(bool leaveItems) {
Items lst = items;
items.clear();
Items lst;
std::swap(lst, items);
if (leaveItems) {
for (Items::const_iterator i = lst.cbegin(), e = lst.cend(); i != e; ++i) {
(*i)->detachFast();
for_const (HistoryItem *item, lst) {
item->detachFast();
}
} else {
for (Items::const_iterator i = lst.cbegin(), e = lst.cend(); i != e; ++i) {
delete *i;
for_const (HistoryItem *item, lst) {
delete item;
}
}
}

View file

@ -238,7 +238,6 @@ public:
return blocks.isEmpty();
}
void clear(bool leaveItems = false);
void clearUpto(MsgId msgId);
void blockResized(HistoryBlock *block, int32 dh);
void removeBlock(HistoryBlock *block);
@ -315,7 +314,7 @@ public:
void removeNotification(HistoryItem *item) {
if (!notifies.isEmpty()) {
for (NotifyQueue::iterator i = notifies.begin(), e = notifies.end(); i != e; ++i) {
for (auto i = notifies.begin(), e = notifies.end(); i != e; ++i) {
if ((*i) == item) {
notifies.erase(i);
break;
@ -429,6 +428,10 @@ public:
void changeMsgId(MsgId oldId, MsgId newId);
protected:
void clearOnDestroy();
private:
ChatListLinksMap _chatListLinks;
@ -438,6 +441,8 @@ private:
MediaOverviewIds overviewIds[OverviewCount];
int32 overviewCountData[OverviewCount]; // -1 - not loaded, 0 - all loaded, > 0 - count, but not all loaded
void clearBlocks(bool leaveItems);
friend class HistoryBlock;
friend class ChannelHistory;
@ -448,6 +453,8 @@ private:
HistoryItem *addMessageGroupAfterPrevToBlock(const MTPDmessageGroup &group, HistoryItem *prev, HistoryBlock *block);
HistoryItem *addMessageGroupAfterPrev(HistoryItem *newItem, HistoryItem *prev);
History(const History &) = delete;
History &operator=(const History &) = delete;
};
class HistoryGroup;
@ -490,6 +497,8 @@ public:
void checkJoinedMessage(bool createUnread = false);
const QDateTime &maxReadMessageDate();
~ChannelHistory();
private:
friend class History;
@ -815,6 +824,9 @@ public:
int32 geomResize(int32 newWidth, int32 *ytransform, const HistoryItem *resizedItem); // return new size
int32 y, height;
History *history;
HistoryBlock(const HistoryBlock &) = delete;
HistoryBlock &operator=(const HistoryBlock &) = delete;
};
class HistoryElem {
@ -1198,9 +1210,6 @@ public:
protected:
HistoryItem(const HistoryItem &);
HistoryItem &operator=(const HistoryItem &);
PeerData *_from;
History *_history;
HistoryBlock *_block;
@ -1208,6 +1217,8 @@ protected:
mutable int32 _authorNameVersion;
HistoryItem(const HistoryItem &) = delete;
HistoryItem &operator=(const HistoryItem &) = delete;
};
class MessageLink : public ITextLink {

View file

@ -1465,7 +1465,7 @@ HistoryItem *HistoryInner::prevItem(HistoryItem *item) {
if (blockIndex > 0) {
return item->history()->blocks[blockIndex - 1]->items.back();
}
if (item->history() == _history && _migrated && _history->loadedAtTop() && _migrated->loadedAtBottom() && !_migrated->isEmpty()) {
if (item->history() == _history && _migrated && _history->loadedAtTop() && !_migrated->isEmpty() && _migrated->loadedAtBottom()) {
return _migrated->blocks.back()->items.back();
}
return 0;
@ -3133,7 +3133,7 @@ void HistoryWidget::sendActionDone(const MTPBool &result, mtpRequestId req) {
}
void HistoryWidget::activate() {
if (_history) updateListSize(0, true);
if (_history) updateListSize(true);
if (App::wnd()) App::wnd()->setInnerFocus();
}
@ -3239,7 +3239,7 @@ void HistoryWidget::notify_clipStopperHidden(ClipStopperType type) {
}
void HistoryWidget::notify_historyItemResized(const HistoryItem *row, bool scrollToIt) {
updateListSize(0, false, false, row, scrollToIt);
updateListSize(false, false, { ScrollChangeNone, 0 }, row, scrollToIt);
}
void HistoryWidget::cmd_search() {
@ -4955,7 +4955,7 @@ void HistoryWidget::doneShow() {
updateReportSpamStatus();
updateBotKeyboard();
updateControlsVisibility();
updateListSize(0, true);
updateListSize(true);
onListScroll();
if (App::wnd()) {
App::wnd()->checkHistoryActivation();
@ -6217,7 +6217,7 @@ void HistoryWidget::resizeEvent(QResizeEvent *e) {
_attachPhoto.move(_attachDocument.x(), _attachDocument.y());
_fieldBarCancel.move(width() - _fieldBarCancel.width(), _field.y() - st::sendPadding - _fieldBarCancel.height());
updateListSize(App::main() ? App::main()->contentScrollAddToY() : 0);
updateListSize(false, false, { ScrollChangeAdd, App::main() ? App::main()->contentScrollAddToY() : 0 });
bool kbShowShown = _history && !_kbShown && _keyboard.hasMarkup();
_field.resize(width() - _send.width() - _attachDocument.width() - _attachEmoji.width() - (kbShowShown ? _kbShow.width() : 0) - (_cmdStartShown ? _cmdStart.width() : 0) - (hasBroadcastToggle() ? _broadcast.width() : 0) - (hasSilentToggle() ? _silent.width() : 0), _field.height());
@ -6303,7 +6303,7 @@ MsgId HistoryWidget::replyToId() const {
return _replyToId ? _replyToId : (_kbReplyTo ? _kbReplyTo->id : 0);
}
void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown, const HistoryItem *resizedItem, bool scrollToIt) {
void HistoryWidget::updateListSize(bool initial, bool loadedDown, const ScrollChange &change, const HistoryItem *resizedItem, bool scrollToIt) {
if (!_history || (initial && _histInited) || (!initial && !_histInited)) return;
if (_firstLoadRequest) {
if (resizedItem) _list->recountHeight(resizedItem);
@ -6362,6 +6362,12 @@ void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown,
}
if ((!initial && !wasAtBottom) || (loadedDown && (!_history->showFrom || _history->unreadBar || _history->loadedAtBottom()) && (!_migrated || !_migrated->showFrom || _migrated->unreadBar || _history->loadedAtBottom()))) {
int32 addToY = 0;
if (change.type == ScrollChangeAdd) {
addToY = change.value;
} else if (change.type == ScrollChangeOldHistoryHeight) {
addToY = _list->historyHeight() - change.value;
}
_scroll.scrollToY(newSt + addToY);
return;
}
@ -6380,7 +6386,7 @@ void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown,
if (iy < 0) {
setMsgId(0);
_histInited = false;
return updateListSize(addToY, initial);
return updateListSize(initial, false, change);
} else {
toY = (_scroll.height() > item->height()) ? qMax(iy - (_scroll.height() - item->height()) / 2, 0) : iy;
_animActiveStart = getms();
@ -6393,13 +6399,13 @@ void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown,
if (iy < 0) {
setMsgId(0);
_histInited = false;
return updateListSize(addToY, initial);
return updateListSize(initial, false, change);
} else {
toY = (_scroll.height() > item->height()) ? qMax(iy - (_scroll.height() - item->height()) / 2, 0) : iy;
_animActiveStart = getms();
_animActiveTimer.start(AnimationTimerDelta);
_activeAnimMsgId = _showAtMsgId;
if (item->isGroupMigrate() && _migrated && _migrated->loadedAtBottom() && _migrated->blocks.back()->items.back()->isGroupMigrate() && _list->historyTop() != _list->historyDrawTop()) {
if (item->isGroupMigrate() && _migrated && !_migrated->isEmpty() && _migrated->loadedAtBottom() && _migrated->blocks.back()->items.back()->isGroupMigrate() && _list->historyTop() != _list->historyDrawTop()) {
_activeAnimMsgId = -_migrated->blocks.back()->items.back()->id;
}
}
@ -6431,7 +6437,7 @@ void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown,
_fixedInScrollMsgId = 0;
_fixedInScrollMsgTop = 0;
_histInited = false;
return updateListSize(addToY, initial);
return updateListSize(initial, false, change);
}
} else {
toY = qMax(iy + item->height() - _fixedInScrollMsgTop, 0);
@ -6447,7 +6453,7 @@ void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown,
if (_migrated->unreadBar) {
setMsgId(ShowAtUnreadMsgId);
_histInited = false;
updateListSize(0, true);
updateListSize(true);
App::wnd()->checkHistoryActivation();
return;
}
@ -6459,7 +6465,7 @@ void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown,
if (_history->unreadBar) {
setMsgId(ShowAtUnreadMsgId);
_histInited = false;
updateListSize(0, true);
updateListSize(true);
App::wnd()->checkHistoryActivation();
return;
}
@ -6470,10 +6476,16 @@ void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown,
}
void HistoryWidget::addMessagesToFront(PeerData *peer, const QVector<MTPMessage> &messages, const QVector<MTPMessageGroup> *collapsed) {
int32 oldH = _list->historyHeight();
int oldH = _list->historyHeight();
_list->messagesReceived(peer, messages, collapsed);
if (!_firstLoadRequest) {
updateListSize(_list->historyHeight() - oldH);
updateListSize(false, false, { ScrollChangeOldHistoryHeight, oldH });
if (_animActiveTimer.isActive() && _activeAnimMsgId > 0 && _migrated && !_migrated->isEmpty() && _migrated->loadedAtBottom() && _migrated->blocks.back()->items.back()->isGroupMigrate() && _list->historyTop() != _list->historyDrawTop() && _history) {
HistoryItem *animActiveItem = App::histItemById(_history->channelId(), _activeAnimMsgId);
if (animActiveItem && animActiveItem->isGroupMigrate()) {
_activeAnimMsgId = -_migrated->blocks.back()->items.back()->id;
}
}
updateBotKeyboard();
}
}
@ -6481,7 +6493,7 @@ void HistoryWidget::addMessagesToFront(PeerData *peer, const QVector<MTPMessage>
void HistoryWidget::addMessagesToBack(PeerData *peer, const QVector<MTPMessage> &messages, const QVector<MTPMessageGroup> *collapsed) {
_list->messagesReceivedDown(peer, messages, collapsed);
if (!_firstLoadRequest) {
updateListSize(0, false, true);
updateListSize(false, true);
}
}

View file

@ -782,10 +782,20 @@ private:
QList<MsgId> _replyReturns;
bool messagesFailed(const RPCError &error, mtpRequestId requestId);
void updateListSize(int32 addToY = 0, bool initial = false, bool loadedDown = false, const HistoryItem *resizedItem = 0, bool scrollToIt = false);
void addMessagesToFront(PeerData *peer, const QVector<MTPMessage> &messages, const QVector<MTPMessageGroup> *collapsed);
void addMessagesToBack(PeerData *peer, const QVector<MTPMessage> &messages, const QVector<MTPMessageGroup> *collapsed);
enum ScrollChangeType {
ScrollChangeNone,
ScrollChangeAdd,
ScrollChangeOldHistoryHeight,
};
struct ScrollChange {
ScrollChangeType type;
int value;
};
void updateListSize(bool initial = false, bool loadedDown = false, const ScrollChange &change = { ScrollChangeNone, 0 }, const HistoryItem *resizedItem = 0, bool scrollToIt = false);
void saveGifDone(DocumentData *doc, const MTPBool &result);
void reportSpamDone(PeerData *peer, const MTPBool &result, mtpRequestId request);

View file

@ -1021,4 +1021,8 @@ namespace SignalHandlers {
}
}
void setAssertionInfo(const QString &info) {
ProcessAnnotations["Assertion"] = info.toUtf8().constData();
}
}

View file

@ -108,5 +108,6 @@ namespace SignalHandlers {
void finish();
void setSelfUsername(const QString &username);
void setAssertionInfo(const QString &info);
}

View file

@ -714,7 +714,7 @@ void ProfileInner::reorderParticipants() {
loadProfilePhotos(_lastPreload);
} else if (_peerChannel && _peerChannel->isMegagroup() && _peerChannel->amIn() && !_peerChannel->mgInfo->lastParticipants.isEmpty()) {
bool needAdmins = true, adminsOutdated = (_peerChannel->mgInfo->lastParticipantsStatus & MegagroupInfo::LastParticipantsAdminsOutdated);
bool orderByOnline = true;// (_peerChannel->count > 0) && (_peerChannel->count <= Global::ChatSizeMax());
bool orderByOnline = (_peerChannel->count > 0) && (_peerChannel->count <= Global::ChatSizeMax());
_onlineText.clear();
if (_peerChannel->mgInfo->lastParticipants.isEmpty() || (needAdmins && adminsOutdated) || _peerChannel->lastParticipantsCountOutdated()) {

View file

@ -851,8 +851,10 @@ namespace {
} else {
_psShadowWindows.setColor(_shInactive);
}
QTimer::singleShot(0, App::wnd(), SLOT(updateCounter()));
App::wnd()->update();
if (Global::started()) {
QMetaObject::invokeMethod(App::wnd(), "updateCounter", Qt::QueuedConnection);
App::wnd()->update();
}
} return false;
case WM_NCPAINT: if (QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS8) return false; *result = 0; return true;

View file

@ -36,28 +36,6 @@ T *exchange(T *&ptr) {
struct NullType {
};
#if __cplusplus < 199711L
#define TDESKTOP_CUSTOM_NULLPTR
#endif
#ifdef TDESKTOP_CUSTOM_NULLPTR
class NullPointerClass {
public:
template <typename T>
operator T*() const {
return 0;
}
template <typename C, typename T>
operator T C::*() const {
return 0;
}
private:
void operator&() const;
};
extern NullPointerClass nullptr;
#endif
template <typename T>
class OrderedSet : public QMap<T, NullType> {
public:
@ -68,6 +46,19 @@ public:
};
#define qsl(s) QStringLiteral(s)
#define qstr(s) QLatin1String(s, sizeof(s) - 1)
// using for_const instead of plain range-based for loop to ensure usage of const_iterator
// it is important for the copy-on-write Qt containers
// if you have "QVector<T*> v" then "for (T * const p : v)" will still call QVector::detach(),
// while "for_const(T *p, v)" won't and "for_const(T *&p, v)" won't compile
template <typename T>
struct ForConstTraits {
typedef const T &ExpressionType;
};
#define for_const(range_declaration, range_expression) for (range_declaration : static_cast<ForConstTraits<decltype(range_expression)>::ExpressionType>(range_expression))
//typedef unsigned char uchar; // Qt has uchar
typedef qint16 int16;
typedef quint16 uint16;
@ -109,7 +100,9 @@ using std::swap;
static volatile int *t_assert_nullptr = 0;
inline void t_noop() {}
inline void t_assert_fail(const char *message, const char *file, int32 line) {
LOG(("Assertion Failed! %1 %2:%3").arg(message).arg(file).arg(line));
QString info(qsl("%1 %2:%3").arg(message).arg(file).arg(line));
LOG(("Assertion Failed! %1 %2:%3").arg(info));
SignalHandlers::setAssertionInfo(info);
*t_assert_nullptr = 0;
}
#define t_assert_full(condition, message, file, line) ((!(condition)) ? t_assert_fail(message, file, line) : t_noop())
@ -277,9 +270,6 @@ private:
};
#define qsl(s) QStringLiteral(s)
#define qstr(s) QLatin1String(s, sizeof(s) - 1)
inline QString fromUtf8Safe(const char *str, int32 size = -1) {
if (!str || !size) return QString();
if (size < 0) size = int32(strlen(str));

View file

@ -78,7 +78,10 @@ void ConnectingWidget::onReconnect() {
MTP::restart();
}
NotifyWindow::NotifyWindow(HistoryItem *msg, int32 x, int32 y, int32 fwdCount) : history(msg->history()), item(msg), fwdCount(fwdCount)
NotifyWindow::NotifyWindow(HistoryItem *msg, int32 x, int32 y, int32 fwdCount) : TWidget(0)
, history(msg->history())
, item(msg)
, fwdCount(fwdCount)
#ifdef Q_OS_WIN
, started(GetTickCount())
#endif
@ -694,6 +697,8 @@ void Window::setupMain(bool anim, const MTPUser *self) {
}
void Window::updateCounter() {
if (App::quitting()) return;
psUpdateCounter();
title->updateCounter();
}

View file

@ -11,7 +11,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.9.31</string>
<string>0.9.32</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>

View file

@ -34,8 +34,8 @@ IDI_ICON1 ICON "SourceFiles\\art\\icon256.ico"
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,9,31,0
PRODUCTVERSION 0,9,31,0
FILEVERSION 0,9,32,0
PRODUCTVERSION 0,9,32,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "0.9.31.0"
VALUE "FileVersion", "0.9.32.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.9.31.0"
VALUE "ProductVersion", "0.9.32.0"
END
END
BLOCK "VarFileInfo"

View file

@ -1726,7 +1726,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.9.31;
CURRENT_PROJECT_VERSION = 0.9.32;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
@ -1745,7 +1745,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 0.9.31;
CURRENT_PROJECT_VERSION = 0.9.32;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_OPTIMIZATION_LEVEL = fast;
GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h;
@ -1774,10 +1774,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.9.31;
CURRENT_PROJECT_VERSION = 0.9.32;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 0.9;
DYLIB_CURRENT_VERSION = 0.9.31;
DYLIB_CURRENT_VERSION = 0.9.32;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
@ -1915,10 +1915,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.9.31;
CURRENT_PROJECT_VERSION = 0.9.32;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 0.9;
DYLIB_CURRENT_VERSION = 0.9.31;
DYLIB_CURRENT_VERSION = 0.9.32;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
FRAMEWORK_SEARCH_PATHS = "";

View file

@ -1,6 +1,6 @@
AppVersion 9031
AppVersion 9032
AppVersionStrMajor 0.9
AppVersionStrSmall 0.9.31
AppVersionStr 0.9.31
AppVersionStrSmall 0.9.32
AppVersionStr 0.9.32
DevChannel 0
BetaVersion 0 9030002

View file

@ -11456,7 +11456,7 @@ index 1ec33df..45d436c 100644
}
return [super performKeyEquivalent:nsevent];
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index da0ba27..9fd21d4 100644
index da0ba27..3f6388c 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -713,6 +713,9 @@ public:
@ -11546,7 +11546,7 @@ index da0ba27..9fd21d4 100644
private:
inline IFileOpenDialog *openFileDialog() const
@@ -1546,6 +1580,55 @@ QList<QUrl> QWindowsNativeOpenFileDialog::dialogResult() const
@@ -1546,6 +1580,57 @@ QList<QUrl> QWindowsNativeOpenFileDialog::dialogResult() const
return result;
}
@ -11587,13 +11587,15 @@ index da0ba27..9fd21d4 100644
+ continue;
+
+ quint64 fullSize = stat.cbSize.QuadPart;
+ result.resize(fullSize);
+ ULONG read = 0;
+ HRESULT r = stream->Read(result.data(), fullSize, &read);
+ if (r == S_FALSE || r == S_OK)
+ return result;
+ if (fullSize <= 64 * 1024 * 1024) {
+ result.resize(fullSize);
+ ULONG read = 0;
+ HRESULT r = stream->Read(result.data(), fullSize, &read);
+ if (r == S_FALSE || r == S_OK)
+ return result;
+
+ result.clear();
+ result.clear();
+ }
+ }
+ }
+ return result;
@ -11602,7 +11604,7 @@ index da0ba27..9fd21d4 100644
QList<QUrl> QWindowsNativeOpenFileDialog::selectedFiles() const
{
QList<QUrl> result;
@@ -1609,6 +1692,8 @@ public:
@@ -1609,6 +1694,8 @@ public:
virtual QUrl directory() const Q_DECL_OVERRIDE;
virtual void selectFile(const QUrl &filename) Q_DECL_OVERRIDE;
virtual QList<QUrl> selectedFiles() const Q_DECL_OVERRIDE;
@ -11611,7 +11613,7 @@ index da0ba27..9fd21d4 100644
virtual void setFilter() Q_DECL_OVERRIDE;
virtual void selectNameFilter(const QString &filter) Q_DECL_OVERRIDE;
virtual QString selectedNameFilter() const Q_DECL_OVERRIDE;
@@ -1702,6 +1787,12 @@ QList<QUrl> QWindowsFileDialogHelper::selectedFiles() const
@@ -1702,6 +1789,12 @@ QList<QUrl> QWindowsFileDialogHelper::selectedFiles() const
return m_data.selectedFiles();
}
@ -11624,7 +11626,7 @@ index da0ba27..9fd21d4 100644
void QWindowsFileDialogHelper::setFilter()
{
qCDebug(lcQpaDialogs) << __FUNCTION__;
@@ -1992,6 +2083,8 @@ public:
@@ -1992,6 +2085,8 @@ public:
virtual QUrl directory() const Q_DECL_OVERRIDE;
virtual void selectFile(const QUrl &url) Q_DECL_OVERRIDE;
virtual QList<QUrl> selectedFiles() const Q_DECL_OVERRIDE;
@ -11633,7 +11635,7 @@ index da0ba27..9fd21d4 100644
virtual void setFilter() Q_DECL_OVERRIDE {}
virtual void selectNameFilter(const QString &) Q_DECL_OVERRIDE;
virtual QString selectedNameFilter() const Q_DECL_OVERRIDE;
@@ -2035,6 +2128,12 @@ QList<QUrl> QWindowsXpFileDialogHelper::selectedFiles() const
@@ -2035,6 +2130,12 @@ QList<QUrl> QWindowsXpFileDialogHelper::selectedFiles() const
return m_data.selectedFiles();
}

View file

@ -1,4 +1,4 @@
##Build instructions for Xcode 6.4
##Build instructions for Xcode 7.2.1
###Prepare folder

View file

@ -1,4 +1,4 @@
##Build instructions for Xcode 6.4
##Build instructions for Xcode 7.2.1
###Prepare folder