2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Replace SelectedItemSet with MessageIdsList.

Use vector<FullMsgId> everywhere instead QMap<..,HistoryItem*>.
The old way the app crashed in case some messages were deleted.
If the items are needed use HistoryItemsList=vector<HistoryItem*>.
This commit is contained in:
John Preston
2017-12-06 14:13:38 +04:00
parent 3845985a6b
commit 6764a3cc86
25 changed files with 269 additions and 248 deletions

View File

@@ -450,21 +450,11 @@ DeleteMessagesBox::DeleteMessagesBox(
DeleteMessagesBox::DeleteMessagesBox(
QWidget*,
const SelectedItemSet &selected)
: _ids(CollectFrom(selected)) {
MessageIdsList &&selected)
: _ids(std::move(selected)) {
Expects(!_ids.empty());
}
std::vector<FullMsgId> DeleteMessagesBox::CollectFrom(
const SelectedItemSet &items) {
return ranges::make_iterator_range(
items.begin(),
items.end()
) | ranges::view::transform([](not_null<HistoryItem*> item) {
return item->fullId();
}) | ranges::to_vector;
}
void DeleteMessagesBox::prepare() {
auto text = QString();
if (_moderateFrom) {

View File

@@ -177,7 +177,7 @@ public:
QWidget*,
not_null<HistoryItem*> item,
bool suggestModerateActions);
DeleteMessagesBox(QWidget*, const SelectedItemSet &selected);
DeleteMessagesBox(QWidget*, MessageIdsList &&selected);
protected:
void prepare() override;
@@ -188,9 +188,7 @@ protected:
private:
void deleteAndClear();
static std::vector<FullMsgId> CollectFrom(const SelectedItemSet &items);
const std::vector<FullMsgId> _ids;
const MessageIdsList _ids;
const bool _singleItem = false;
UserData *_moderateFrom = nullptr;
ChannelData *_moderateInChannel = nullptr;

View File

@@ -892,7 +892,7 @@ void AddBotToGroupBoxController::prepareViewHook() {
}
ChooseRecipientBoxController::ChooseRecipientBoxController(
base::lambda<void(not_null<PeerData*>)> callback)
base::lambda_once<void(not_null<PeerData*>)> callback)
: _callback(std::move(callback)) {
}

View File

@@ -243,7 +243,7 @@ private:
class ChooseRecipientBoxController : public ChatsListBoxController {
public:
ChooseRecipientBoxController(
base::lambda<void(not_null<PeerData*>)> callback);
base::lambda_once<void(not_null<PeerData*>)> callback);
void rowClicked(not_null<PeerListRow*> row) override;
@@ -257,6 +257,6 @@ protected:
not_null<History*> history) override;
private:
base::lambda<void(not_null<PeerData*>)> _callback;
base::lambda_once<void(not_null<PeerData*>)> _callback;
};