mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
UniquePointer > std_::unique_ptr, MakeUnique > std_::make_unique.
This commit is contained in:
@@ -831,7 +831,7 @@ void File::ensureAnimation() const {
|
||||
void File::checkAnimationFinished() {
|
||||
if (_animation && !_animation->_a_thumbOver.animating() && !_animation->radial.animating()) {
|
||||
if (getShownDocument()->loaded()) {
|
||||
_animation.clear();
|
||||
_animation = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -277,7 +277,7 @@ private:
|
||||
|
||||
RadialAnimation radial;
|
||||
};
|
||||
mutable UniquePointer<AnimationData> _animation;
|
||||
mutable std_::unique_ptr<AnimationData> _animation;
|
||||
|
||||
Text _title, _description;
|
||||
ClickHandlerPtr _open, _cancel;
|
||||
|
@@ -99,25 +99,25 @@ void ItemBase::update() {
|
||||
}
|
||||
}
|
||||
|
||||
UniquePointer<ItemBase> ItemBase::createLayout(Result *result, bool forceThumb) {
|
||||
std_::unique_ptr<ItemBase> ItemBase::createLayout(Result *result, bool forceThumb) {
|
||||
using Type = Result::Type;
|
||||
|
||||
switch (result->_type) {
|
||||
case Type::Photo: return MakeUnique<internal::Photo>(result); break;
|
||||
case Type::Photo: return std_::make_unique<internal::Photo>(result); break;
|
||||
case Type::Audio:
|
||||
case Type::File: return MakeUnique<internal::File>(result); break;
|
||||
case Type::Video: return MakeUnique<internal::Video>(result); break;
|
||||
case Type::Sticker: return MakeUnique<internal::Sticker>(result); break;
|
||||
case Type::Gif: return MakeUnique<internal::Gif>(result); break;
|
||||
case Type::File: return std_::make_unique<internal::File>(result); break;
|
||||
case Type::Video: return std_::make_unique<internal::Video>(result); break;
|
||||
case Type::Sticker: return std_::make_unique<internal::Sticker>(result); break;
|
||||
case Type::Gif: return std_::make_unique<internal::Gif>(result); break;
|
||||
case Type::Article:
|
||||
case Type::Venue: return MakeUnique<internal::Article>(result, forceThumb); break;
|
||||
case Type::Contact: return MakeUnique<internal::Contact>(result); break;
|
||||
case Type::Venue: return std_::make_unique<internal::Article>(result, forceThumb); break;
|
||||
case Type::Contact: return std_::make_unique<internal::Contact>(result); break;
|
||||
}
|
||||
return UniquePointer<ItemBase>();
|
||||
return std_::unique_ptr<ItemBase>();
|
||||
}
|
||||
|
||||
UniquePointer<ItemBase> ItemBase::createLayoutGif(DocumentData *document) {
|
||||
return MakeUnique<internal::Gif>(document, true);
|
||||
std_::unique_ptr<ItemBase> ItemBase::createLayoutGif(DocumentData *document) {
|
||||
return std_::make_unique<internal::Gif>(document, true);
|
||||
}
|
||||
|
||||
DocumentData *ItemBase::getResultDocument() const {
|
||||
|
@@ -91,8 +91,8 @@ public:
|
||||
update();
|
||||
}
|
||||
|
||||
static UniquePointer<ItemBase> createLayout(Result *result, bool forceThumb);
|
||||
static UniquePointer<ItemBase> createLayoutGif(DocumentData *document);
|
||||
static std_::unique_ptr<ItemBase> createLayout(Result *result, bool forceThumb);
|
||||
static std_::unique_ptr<ItemBase> createLayoutGif(DocumentData *document);
|
||||
|
||||
protected:
|
||||
DocumentData *getResultDocument() const;
|
||||
|
@@ -60,10 +60,10 @@ Result *getResultFromLoader(FileLoader *loader) {
|
||||
Result::Result(const Creator &creator) : _queryId(creator.queryId), _type(creator.type) {
|
||||
}
|
||||
|
||||
UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &mtpData) {
|
||||
std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult &mtpData) {
|
||||
using StringToTypeMap = QMap<QString, Result::Type>;
|
||||
static StaticNeverFreedPointer<StringToTypeMap> stringToTypeMap{ ([]() -> StringToTypeMap* {
|
||||
auto result = MakeUnique<StringToTypeMap>();
|
||||
auto result = std_::make_unique<StringToTypeMap>();
|
||||
result->insert(qsl("photo"), Result::Type::Photo);
|
||||
result->insert(qsl("video"), Result::Type::Video);
|
||||
result->insert(qsl("audio"), Result::Type::Audio);
|
||||
@@ -86,10 +86,10 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||
};
|
||||
Type type = getInlineResultType(mtpData);
|
||||
if (type == Type::Unknown) {
|
||||
return UniquePointer<Result>();
|
||||
return std_::unique_ptr<Result>();
|
||||
}
|
||||
|
||||
auto result = MakeUnique<Result>(Creator{ queryId, type });
|
||||
auto result = std_::make_unique<Result>(Creator{ queryId, type });
|
||||
const MTPBotInlineMessage *message = nullptr;
|
||||
switch (mtpData.type()) {
|
||||
case mtpc_botInlineResult: {
|
||||
@@ -126,18 +126,18 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||
bool badAttachment = (result->_photo && !result->_photo->access) || (result->_document && !result->_document->isValid());
|
||||
|
||||
if (!message) {
|
||||
return UniquePointer<Result>();
|
||||
return std_::unique_ptr<Result>();
|
||||
}
|
||||
|
||||
// Ensure required media fields for layouts.
|
||||
if (result->_type == Type::Photo) {
|
||||
if (!result->_photo && result->_content_url.isEmpty()) {
|
||||
return UniquePointer<Result>();
|
||||
return std_::unique_ptr<Result>();
|
||||
}
|
||||
result->createPhoto();
|
||||
} else if (result->_type == Type::File || result->_type == Type::Gif || result->_type == Type::Sticker) {
|
||||
if (!result->_document && result->_content_url.isEmpty()) {
|
||||
return UniquePointer<Result>();
|
||||
return std_::unique_ptr<Result>();
|
||||
}
|
||||
result->createDocument();
|
||||
}
|
||||
@@ -153,7 +153,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||
result->sendData.reset(new internal::SendFile(result->_document, qs(r.vcaption)));
|
||||
}
|
||||
if (r.has_reply_markup()) {
|
||||
result->_mtpKeyboard = MakeUnique<MTPReplyMarkup>(r.vreply_markup);
|
||||
result->_mtpKeyboard = std_::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -162,7 +162,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||
EntitiesInText entities = r.has_entities() ? entitiesFromMTP(r.ventities.c_vector().v) : EntitiesInText();
|
||||
result->sendData.reset(new internal::SendText(qs(r.vmessage), entities, r.is_no_webpage()));
|
||||
if (r.has_reply_markup()) {
|
||||
result->_mtpKeyboard = MakeUnique<MTPReplyMarkup>(r.vreply_markup);
|
||||
result->_mtpKeyboard = std_::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -174,7 +174,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||
badAttachment = true;
|
||||
}
|
||||
if (r.has_reply_markup()) {
|
||||
result->_mtpKeyboard = MakeUnique<MTPReplyMarkup>(r.vreply_markup);
|
||||
result->_mtpKeyboard = std_::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -186,7 +186,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||
badAttachment = true;
|
||||
}
|
||||
if (r.has_reply_markup()) {
|
||||
result->_mtpKeyboard = MakeUnique<MTPReplyMarkup>(r.vreply_markup);
|
||||
result->_mtpKeyboard = std_::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -194,7 +194,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||
const auto &r(message->c_botInlineMessageMediaContact());
|
||||
result->sendData.reset(new internal::SendContact(qs(r.vfirst_name), qs(r.vlast_name), qs(r.vphone_number)));
|
||||
if (r.has_reply_markup()) {
|
||||
result->_mtpKeyboard = MakeUnique<MTPReplyMarkup>(r.vreply_markup);
|
||||
result->_mtpKeyboard = std_::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -204,7 +204,7 @@ UniquePointer<Result> Result::create(uint64 queryId, const MTPBotInlineResult &m
|
||||
}
|
||||
|
||||
if (badAttachment || !result->sendData || !result->sendData->isValid()) {
|
||||
return UniquePointer<Result>();
|
||||
return std_::unique_ptr<Result>();
|
||||
}
|
||||
|
||||
if (result->_thumb->isNull() && !result->_thumb_url.isEmpty()) {
|
||||
|
@@ -43,10 +43,10 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
// Constructor is public only for MakeUnique<>() to work.
|
||||
// Constructor is public only for std::make_unique<>() to work.
|
||||
// You should use create() static method instead.
|
||||
explicit Result(const Creator &creator);
|
||||
static UniquePointer<Result> create(uint64 queryId, const MTPBotInlineResult &mtpData);
|
||||
static std_::unique_ptr<Result> create(uint64 queryId, const MTPBotInlineResult &mtpData);
|
||||
Result(const Result &other) = delete;
|
||||
Result &operator=(const Result &other) = delete;
|
||||
|
||||
@@ -112,11 +112,11 @@ private:
|
||||
DocumentData *_document = nullptr;
|
||||
PhotoData *_photo = nullptr;
|
||||
|
||||
UniquePointer<MTPReplyMarkup> _mtpKeyboard;
|
||||
std_::unique_ptr<MTPReplyMarkup> _mtpKeyboard;
|
||||
|
||||
ImagePtr _thumb, _locationThumb;
|
||||
|
||||
UniquePointer<internal::SendData> sendData;
|
||||
std_::unique_ptr<internal::SendData> sendData;
|
||||
|
||||
};
|
||||
Result *getResultFromLoader(FileLoader *loader);
|
||||
|
Reference in New Issue
Block a user