Replace t_assert() with Assert().

Also use this assertions for Expects(), Ensures() and Unexpected().
This commit is contained in:
John Preston 2017-08-17 12:06:26 +03:00
parent b3da99c302
commit 25ffaaaa2d
107 changed files with 492 additions and 435 deletions

View file

@ -1144,7 +1144,7 @@ void ApiWrap::handlePrivacyChange(mtpTypeId keyTypeId, const MTPVector<MTPPrivac
_contactsStatusesRequestId = request(MTPcontacts_GetStatuses()).done([this](const MTPVector<MTPContactStatus> &result) {
_contactsStatusesRequestId = 0;
for_const (auto &item, result.v) {
t_assert(item.type() == mtpc_contactStatus);
Assert(item.type() == mtpc_contactStatus);
auto &data = item.c_contactStatus();
if (auto user = App::userLoaded(data.vuser_id.v)) {
auto oldOnlineTill = user->onlineTill;
@ -1889,7 +1889,7 @@ void ApiWrap::sendSaveChatAdminsRequests(not_null<ChatData*> chat) {
auto removeOne = [&](auto user) { editOne(user, false); };
auto admins = _chatAdminsToSave.take(chat);
t_assert(!!admins);
Assert(!!admins);
auto toRemove = chat->admins;
auto toAppoint = std::vector<not_null<UserData*>>();

View file

@ -1452,7 +1452,7 @@ namespace {
} else if (peerIsChannel(id)) {
newData = new ChannelData(id);
}
t_assert(newData != nullptr);
Assert(newData != nullptr);
newData->input = MTPinputPeer(MTP_inputPeerEmpty());
i = peersData.insert(id, newData);

View file

@ -161,7 +161,7 @@ namespace App {
History *historyLoaded(const PeerId &peer);
HistoryItem *histItemById(ChannelId channelId, MsgId itemId);
inline History *history(const PeerData *peer) {
t_assert(peer != nullptr);
Assert(peer != nullptr);
return history(peer->id);
}
inline History *historyLoaded(const PeerData *peer) {

View file

@ -622,7 +622,7 @@ void connect(const char *signal, QObject *object, const char *method) {
}
void launch() {
t_assert(application() != 0);
Assert(application() != 0);
float64 dpi = Application::primaryScreen()->logicalDotsPerInch();
if (dpi <= 108) { // 0-96-108

View file

@ -163,7 +163,7 @@ QString AuthSessionData::getSoundPath(const QString &key) const {
AuthSession &Auth() {
auto result = Messenger::Instance().authSession();
t_assert(result != nullptr);
Assert(result != nullptr);
return *result;
}

View file

@ -0,0 +1,71 @@
/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#pragma once
#include <cstdlib>
namespace base {
namespace assertion {
// Client must define that method.
void log(const char *message, const char *file, int line);
// Release build assertions.
inline void noop() {
}
[[noreturn]] inline void fail(const char *message, const char *file, int line) {
log(message, file, line);
// Crash with access violation and generate crash report.
volatile auto nullptr_value = (int*)nullptr;
*nullptr_value = 0;
// Silent the possible failure to comply noreturn warning.
std::abort();
}
inline void validate(bool condition, const char *message, const char *file, int line) {
(GSL_UNLIKELY(!(condition))) ? fail(message, file, line) : noop();
}
} // namespace assertion
} // namespace base
#define AssertCustom(condition, message) (::base::assertion::validate(condition, message, __FILE__, __LINE__))
#define Assert(condition) AssertCustom(condition, "\"" #condition "\"")
// Define our own versions of Expects() and Ensures().
// Let them crash with reports and logging.
#ifdef Expects
#undef Expects
#endif // Expects
#define Expects(condition) (::base::assertion::validate(condition, "\"" #condition "\"", __FILE__, __LINE__))
#ifdef Ensures
#undef Ensures
#endif // Ensures
#define Ensures(condition) (::base::assertion::validate(condition, "\"" #condition "\"", __FILE__, __LINE__))
#ifdef Unexpected
#undef Unexpected
#endif // Unexpected
#define Unexpected(message) (::base::assertion::fail("Unexpected: " message, __FILE__, __LINE__))

View file

@ -357,7 +357,7 @@ public:
}
inline Return operator()(Args... args) {
t_assert(data_.vtable != nullptr);
Assert(data_.vtable != nullptr);
return data_.vtable->call(data_.storage, std::forward<Args>(args)...);
}
@ -429,7 +429,7 @@ public:
}
inline Return operator()(Args... args) const {
t_assert(this->data_.vtable != nullptr);
Assert(this->data_.vtable != nullptr);
return this->data_.vtable->const_call(this->data_.storage, std::forward<Args>(args)...);
}

View file

@ -437,7 +437,7 @@ protected:
void unsubscribe(int index) {
if (!index) return;
auto count = static_cast<int>(_subscriptions.size());
t_assert(index > 0 && index <= count);
Assert(index > 0 && index <= count);
_subscriptions[index - 1].destroy();
if (index == count) {
while (index > 0 && !_subscriptions[--index]) {

View file

@ -171,7 +171,7 @@ public:
auto length = BN_num_bytes(raw());
auto result = base::byte_vector(length, gsl::byte());
auto resultSize = BN_bn2bin(raw(), reinterpret_cast<unsigned char*>(result.data()));
t_assert(resultSize == length);
Assert(resultSize == length);
return result;
}

View file

@ -27,7 +27,7 @@ namespace parse {
QByteArray stripComments(const QByteArray &content);
inline bool skipWhitespaces(const char *&from, const char *end) {
t_assert(from <= end);
Assert(from <= end);
while (from != end && (
(*from == ' ') ||
(*from == '\n') ||
@ -39,7 +39,7 @@ inline bool skipWhitespaces(const char *&from, const char *end) {
}
inline QLatin1String readName(const char *&from, const char *end) {
t_assert(from <= end);
Assert(from <= end);
auto start = from;
while (from != end && (
(*from >= 'a' && *from <= 'z') ||

View file

@ -37,7 +37,7 @@ const RuntimeComposerMetadata *GetRuntimeComposerMetadata(uint64 mask) {
auto i = RuntimeComposerMetadatas.data.constFind(mask);
if (i == RuntimeComposerMetadatas.data.cend()) {
RuntimeComposerMetadata *meta = new RuntimeComposerMetadata(mask);
t_assert(meta != nullptr);
Assert(meta != nullptr);
i = RuntimeComposerMetadatas.data.insert(mask, meta);
}

View file

@ -70,7 +70,7 @@ struct RuntimeComponent {
while (true) {
auto last = RuntimeComponentIndexLast.loadAcquire();
if (RuntimeComponentIndexLast.testAndSetOrdered(last, last + 1)) {
t_assert(last < 64);
Assert(last < 64);
if (MyIndex.testAndSetOrdered(0, last + 1)) {
RuntimeComponentWraps[last] = RuntimeComponentWrapStruct(
sizeof(Type),
@ -154,7 +154,7 @@ public:
auto meta = GetRuntimeComposerMetadata(mask);
auto data = operator new(meta->size);
t_assert(data != nullptr);
Assert(data != nullptr);
_data = data;
_meta() = meta;
@ -166,7 +166,7 @@ public:
auto space = RuntimeComponentWraps[i].Size;
auto alignedAt = constructAt;
std::align(RuntimeComponentWraps[i].Align, space, alignedAt, space);
t_assert(alignedAt == constructAt);
Assert(alignedAt == constructAt);
RuntimeComponentWraps[i].Construct(constructAt, this);
} catch (...) {
while (i > 0) {

View file

@ -90,7 +90,7 @@ TaskQueue::TaskQueueList::TaskQueueList() {
}
void TaskQueue::TaskQueueList::Register(TaskQueue *queue) {
t_assert(!queue->SerialTaskInProcess());
Assert(!queue->SerialTaskInProcess());
Insert(queue, kAllQueuesList);
if (queue->priority_ == Priority::Normal) {
@ -106,7 +106,7 @@ void TaskQueue::TaskQueueList::Unregister(TaskQueue *queue) {
}
void TaskQueue::TaskQueueList::Insert(TaskQueue *queue, int list_index_) {
t_assert(list_index_ < kQueuesListsCount);
Assert(list_index_ < kQueuesListsCount);
auto tail = Tail();
if (lists_[list_index_] == tail) {
@ -114,7 +114,7 @@ void TaskQueue::TaskQueueList::Insert(TaskQueue *queue, int list_index_) {
}
auto &list_entry = queue->list_entries_[list_index_];
t_assert(list_entry.after == nullptr);
Assert(list_entry.after == nullptr);
if ((list_entry.before = tail->list_entries_[list_index_].before)) {
list_entry.before->list_entries_[list_index_].after = queue;
}
@ -123,14 +123,14 @@ void TaskQueue::TaskQueueList::Insert(TaskQueue *queue, int list_index_) {
}
void TaskQueue::TaskQueueList::Remove(TaskQueue *queue, int list_index_) {
t_assert(list_index_ < kQueuesListsCount);
Assert(list_index_ < kQueuesListsCount);
auto &list_entry = queue->list_entries_[list_index_];
t_assert(list_entry.after != nullptr);
Assert(list_entry.after != nullptr);
if (lists_[list_index_] == queue) {
lists_[list_index_] = list_entry.after;
} else {
t_assert(list_entry.before != nullptr);
Assert(list_entry.before != nullptr);
list_entry.before->list_entries_[list_index_].after = list_entry.after;
}
list_entry.after->list_entries_[list_index_].before = list_entry.before;
@ -141,7 +141,7 @@ bool TaskQueue::TaskQueueList::IsInList(TaskQueue *queue) const {
if (queue->list_entries_[kAllQueuesList].after) {
return true;
}
t_assert(queue->list_entries_[kOnlyNormalQueuesList].after == nullptr);
Assert(queue->list_entries_[kOnlyNormalQueuesList].after == nullptr);
return false;
}
@ -158,15 +158,15 @@ void TaskQueue::TaskQueueList::Clear() {
}
bool TaskQueue::TaskQueueList::Empty(int list_index_) const {
t_assert(list_index_ < kQueuesListsCount);
Assert(list_index_ < kQueuesListsCount);
auto list = lists_[list_index_];
t_assert(list != nullptr);
Assert(list != nullptr);
return (list->list_entries_[list_index_].after == nullptr);
}
TaskQueue *TaskQueue::TaskQueueList::TakeFirst(int list_index_) {
t_assert(!Empty(list_index_));
Assert(!Empty(list_index_));
auto queue = lists_[list_index_];
Unregister(queue);
@ -194,7 +194,7 @@ void TaskQueue::TaskThreadPool::AddQueueTask(TaskQueue *queue, Task &&task) {
ThreadFunction();
});
} else if (some_threads_are_vacant) {
t_assert(threads_count > tasks_in_process_);
Assert(threads_count > tasks_in_process_);
thread_condition_.wakeOne();
}
}
@ -276,7 +276,7 @@ void TaskQueue::TaskThreadPool::ThreadFunction() {
auto take_from_list_ = take_only_normal ? kOnlyNormalQueuesList : kAllQueuesList;
auto queue = queue_list_.TakeFirst(take_from_list_);
t_assert(!queue->tasks_.empty());
Assert(!queue->tasks_.empty());
task = std::move(queue->tasks_.front());
queue->tasks_.pop_front();
@ -285,7 +285,7 @@ void TaskQueue::TaskThreadPool::ThreadFunction() {
// Serial queues are returned in the list for processing
// only after the task is finished.
serial_queue = queue;
t_assert(serial_queue->destroyed_flag_ == nullptr);
Assert(serial_queue->destroyed_flag_ == nullptr);
serial_queue->destroyed_flag_ = &serial_queue_destroyed;
} else if (!queue->tasks_.empty()) {
queue_list_.Register(queue);
@ -326,20 +326,20 @@ void TaskQueue::Put(Task &&task) {
Sandbox::MainThreadTaskAdded();
} else {
t_assert(type_ != Type::Special);
Assert(type_ != Type::Special);
TaskThreadPool::Instance()->AddQueueTask(this, std::move(task));
}
}
void TaskQueue::ProcessMainTasks() { // static
t_assert(std::this_thread::get_id() == MainThreadId);
Assert(std::this_thread::get_id() == MainThreadId);
while (ProcessOneMainTask()) {
}
}
void TaskQueue::ProcessMainTasks(TimeMs max_time_spent) { // static
t_assert(std::this_thread::get_id() == MainThreadId);
Assert(std::this_thread::get_id() == MainThreadId);
auto start_time = getms();
while (ProcessOneMainTask()) {
@ -370,7 +370,7 @@ bool TaskQueue::IsMyThread() const {
if (type_ == Type::Main) {
return (std::this_thread::get_id() == MainThreadId);
}
t_assert(type_ != Type::Special);
Assert(type_ != Type::Special);
return false;
}

View file

@ -84,7 +84,7 @@ template <typename Object, void (*Creator)(const child_entry &)>
class object_registrator {
public:
inline object_registrator() {
t_assert(!first_dispatch_fired());
Assert(!first_dispatch_fired());
Creator(child_entry {
&is_parent<Object>::check,
&_index,
@ -701,7 +701,7 @@ private:
class virtual_override_registrator {
public:
inline virtual_override_registrator() {
t_assert(!virtual_methods::first_dispatch_fired());
Assert(!virtual_methods::first_dispatch_fired());
BaseMethod::template virtual_method_register_override<ConcreteMethod>();
}

View file

@ -397,7 +397,7 @@ void GroupInfoBox::createGroup(not_null<PeerListBox*> selectUsersBox, const QStr
inputs.reserve(users.size());
for (auto peer : users) {
auto user = peer->asUser();
t_assert(user != nullptr);
Assert(user != nullptr);
if (!user->isSelf()) {
inputs.push_back(user->inputUser);
}

View file

@ -148,7 +148,7 @@ void CalendarBox::Context::skipMonth(int skip) {
}
int CalendarBox::Context::daysShiftForMonth(QDate month) {
t_assert(!month.isNull());
Assert(!month.isNull());
constexpr auto kMaxRows = 6;
auto inMonthIndex = month.day() - 1;
auto inWeekIndex = month.dayOfWeek() - 1;
@ -156,7 +156,7 @@ int CalendarBox::Context::daysShiftForMonth(QDate month) {
}
int CalendarBox::Context::rowsCountForMonth(QDate month) {
t_assert(!month.isNull());
Assert(!month.isNull());
auto daysShift = daysShiftForMonth(month);
auto daysCount = month.daysInMonth();
auto cellsCount = daysShift + daysCount;
@ -360,7 +360,7 @@ void CalendarBox::Inner::mousePressEvent(QMouseEvent *e) {
setPressed(_selected);
if (_selected != kEmptySelection) {
auto index = _selected + _context->daysShift();
t_assert(index >= 0);
Assert(index >= 0);
auto row = index / kDaysInWeek;
auto col = index % kDaysInWeek;

View file

@ -430,7 +430,7 @@ DeleteMessagesBox::DeleteMessagesBox(QWidget*, HistoryItem *item, bool suggestMo
DeleteMessagesBox::DeleteMessagesBox(QWidget*, const SelectedItemSet &selected) {
auto count = selected.size();
t_assert(count > 0);
Assert(count > 0);
_ids.reserve(count);
for_const (auto item, selected) {
_ids.push_back(item->fullId());
@ -440,7 +440,7 @@ DeleteMessagesBox::DeleteMessagesBox(QWidget*, const SelectedItemSet &selected)
void DeleteMessagesBox::prepare() {
auto text = QString();
if (_moderateFrom) {
t_assert(_moderateInChannel != nullptr);
Assert(_moderateInChannel != nullptr);
text = lang(lng_selected_delete_sure_this);
if (_moderateBan) {
_banUser.create(this, lang(lng_ban_user), false, st::defaultBoxCheckbox);

View file

@ -118,7 +118,7 @@ void EditParticipantBox::Inner::removeControl(QPointer<TWidget> widget) {
auto row = std::find_if(_rows.begin(), _rows.end(), [widget](auto &&row) {
return (row.widget == widget);
});
t_assert(row != _rows.end());
Assert(row != _rows.end());
row->widget.destroy();
_rows.erase(row);
}
@ -250,7 +250,7 @@ void EditAdminBox::prepare() {
auto addAdmins = _checkboxes.find(Flag::f_add_admins);
if (addAdmins != _checkboxes.end()) {
_aboutAddAdmins = addControl(object_ptr<Ui::FlatLabel>(this, st::boxLabel), st::rightsAboutMargin);
t_assert(addAdmins != _checkboxes.end());
Assert(addAdmins != _checkboxes.end());
subscribe(addAdmins->second->checkedChanged, [this](bool checked) {
refreshAboutAddAdminsText();
});
@ -295,7 +295,7 @@ void EditAdminBox::applyDependencies(QPointer<Ui::Checkbox> changed) {
void EditAdminBox::refreshAboutAddAdminsText() {
auto addAdmins = _checkboxes.find(Flag::f_add_admins);
t_assert(addAdmins != _checkboxes.end());
Assert(addAdmins != _checkboxes.end());
auto text = [this, addAdmins] {
if (!canSave()) {
return lang(lng_rights_about_admin_cant_edit);
@ -480,6 +480,6 @@ TimeId EditRestrictedBox::getRealUntilValue() const {
} else if (_until == kUntilOneWeek) {
return unixtime() + kSecondsInWeek;
}
t_assert(_until >= 0);
Assert(_until >= 0);
return _until;
}

View file

@ -66,7 +66,7 @@ std::vector<not_null<UserData*>> PrivacyExceptionsBoxController::getResult() con
users.reserve(peers.size());
for_const (auto peer, peers) {
auto user = peer->asUser();
t_assert(user != nullptr);
Assert(user != nullptr);
users.push_back(user);
}
}

View file

@ -278,10 +278,10 @@ void PeerListController::search(const QString &query) {
void PeerListController::peerListSearchAddRow(not_null<PeerData*> peer) {
if (auto row = delegate()->peerListFindRow(peer->id)) {
t_assert(row->id() == row->peer()->id);
Assert(row->id() == row->peer()->id);
delegate()->peerListAppendFoundRow(row);
} else if (auto row = createSearchRow(peer)) {
t_assert(row->id() == row->peer()->id);
Assert(row->id() == row->peer()->id);
delegate()->peerListAppendSearchRow(std::move(row));
}
}
@ -585,7 +585,7 @@ void PeerListBox::Inner::addRowEntry(not_null<PeerListRow*> row) {
addToSearchIndex(row);
}
if (_controller->isRowSelected(row->peer())) {
t_assert(row->id() == row->peer()->id);
Assert(row->id() == row->peer()->id);
changeCheckState(row, true, PeerListRow::SetStyle::Fast);
}
}
@ -643,10 +643,10 @@ void PeerListBox::Inner::prependRowFromSearchResult(not_null<PeerListRow*> row)
if (!row->isSearchResult()) {
return;
}
t_assert(_rowsById.find(row->id()) != _rowsById.cend());
Assert(_rowsById.find(row->id()) != _rowsById.cend());
auto index = row->absoluteIndex();
t_assert(index >= 0 && index < _searchRows.size());
t_assert(_searchRows[index].get() == row);
Assert(index >= 0 && index < _searchRows.size());
Assert(_searchRows[index].get() == row);
row->setIsSearchResult(false);
_rows.insert(_rows.begin(), std::move(_searchRows[index]));
@ -682,8 +682,8 @@ void PeerListBox::Inner::removeRow(not_null<PeerListRow*> row) {
auto isSearchResult = row->isSearchResult();
auto &eraseFrom = isSearchResult ? _searchRows : _rows;
t_assert(index >= 0 && index < eraseFrom.size());
t_assert(eraseFrom[index].get() == row);
Assert(index >= 0 && index < eraseFrom.size());
Assert(eraseFrom[index].get() == row);
setSelected(Selected());
setPressed(Selected());
@ -705,8 +705,8 @@ void PeerListBox::Inner::convertRowToSearchResult(not_null<PeerListRow*> row) {
return removeRow(row);
}
auto index = row->absoluteIndex();
t_assert(index >= 0 && index < _rows.size());
t_assert(_rows[index].get() == row);
Assert(index >= 0 && index < _rows.size());
Assert(_rows[index].get() == row);
removeFromSearchIndex(row);
row->setIsSearchResult(true);
@ -925,7 +925,7 @@ void PeerListBox::Inner::setPressed(Selected pressed) {
void PeerListBox::Inner::paintRow(Painter &p, TimeMs ms, RowIndex index) {
auto row = getRow(index);
t_assert(row != nullptr);
Assert(row != nullptr);
row->lazyInitialize();
auto peer = row->peer();
@ -1016,8 +1016,8 @@ void PeerListBox::Inner::selectSkip(int direction) {
lastEnabled = firstEnabled - 1;
}
t_assert(lastEnabled < rowsCount);
t_assert(firstEnabled - 1 <= lastEnabled);
Assert(lastEnabled < rowsCount);
Assert(firstEnabled - 1 <= lastEnabled);
// Always pass through the first enabled item when changing from / to none selected.
if ((_selected.index.value > firstEnabled && newSelectedIndex < firstEnabled)
@ -1037,7 +1037,7 @@ void PeerListBox::Inner::selectSkip(int direction) {
auto delta = (direction > 0) ? 1 : -1;
for (newSelectedIndex += delta; ; newSelectedIndex += delta) {
// We must find an enabled row, firstEnabled <= us <= lastEnabled.
t_assert(newSelectedIndex >= 0 && newSelectedIndex < rowsCount);
Assert(newSelectedIndex >= 0 && newSelectedIndex < rowsCount);
if (!getRow(RowIndex(newSelectedIndex))->disabled()) {
break;
}
@ -1253,17 +1253,17 @@ bool PeerListBox::Inner::enumerateShownRows(Callback callback) {
template <typename Callback>
bool PeerListBox::Inner::enumerateShownRows(int from, int to, Callback callback) {
t_assert(0 <= from);
t_assert(from <= to);
Assert(0 <= from);
Assert(from <= to);
if (showingSearch()) {
t_assert(to <= _filterResults.size());
Assert(to <= _filterResults.size());
for (auto i = from; i != to; ++i) {
if (!callback(_filterResults[i])) {
return false;
}
}
} else {
t_assert(to <= _rows.size());
Assert(to <= _rows.size());
for (auto i = from; i != to; ++i) {
if (!callback(_rows[i].get())) {
return false;
@ -1288,7 +1288,7 @@ PeerListRow *PeerListBox::Inner::getRow(RowIndex index) {
PeerListBox::Inner::RowIndex PeerListBox::Inner::findRowIndex(not_null<PeerListRow*> row, RowIndex hint) {
if (!showingSearch()) {
t_assert(!row->isSearchResult());
Assert(!row->isSearchResult());
return RowIndex(row->absoluteIndex());
}

View file

@ -445,8 +445,8 @@ void AddParticipantsBoxController::Start(not_null<ChatData*> chat) {
auto users = std::vector<not_null<UserData*>>();
for (auto peer : rows) {
auto user = peer->asUser();
t_assert(user != nullptr);
t_assert(!user->isSelf());
Assert(user != nullptr);
Assert(!user->isSelf());
users.push_back(peer->asUser());
}
App::main()->addParticipants(chat, users);
@ -470,8 +470,8 @@ void AddParticipantsBoxController::Start(
auto users = std::vector<not_null<UserData*>>();
for (auto peer : rows) {
auto user = peer->asUser();
t_assert(user != nullptr);
t_assert(!user->isSelf());
Assert(user != nullptr);
Assert(!user->isSelf());
users.push_back(peer->asUser());
}
App::main()->addParticipants(channel, users);
@ -673,8 +673,8 @@ void EditChatAdminsBoxController::Start(not_null<ChatData*> chat) {
auto users = std::vector<not_null<UserData*>>();
for (auto peer : rows) {
auto user = peer->asUser();
t_assert(user != nullptr);
t_assert(!user->isSelf());
Assert(user != nullptr);
Assert(!user->isSelf());
users.push_back(peer->asUser());
}
Auth().api().editChatAdmins(chat, !controller->allAreAdmins(), { users.cbegin(), users.cend() });

View file

@ -561,7 +561,7 @@ EditCaptionBox::EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId) :
_thumb = App::pixmapFromImageInPlace(_thumb.toImage().scaled(_thumbw * cIntRetinaFactor(), _thumbh * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
_thumb.setDevicePixelRatio(cRetinaFactor());
}
t_assert(_animated || _photo || _doc);
Assert(_animated || _photo || _doc);
_field.create(this, st::confirmCaptionArea, langFactory(lng_photo_caption), caption);
_field->setMaxLength(MaxPhotoCaption);

View file

@ -361,7 +361,7 @@ void StickerSetBox::Inner::paintEvent(QPaintEvent *e) {
for (int32 j = 0; j < kStickersPanelPerRow; ++j) {
int32 index = i * kStickersPanelPerRow + j;
if (index >= _pack.size()) break;
t_assert(index < _packOvers.size());
Assert(index < _packOvers.size());
DocumentData *doc = _pack.at(index);
QPoint pos(st::stickersPadding.left() + j * st::stickersSize.width(), st::stickersPadding.top() + i * st::stickersSize.height());

View file

@ -132,7 +132,7 @@ object_ptr<StickersBox::Inner> StickersBox::Tab::takeWidget() {
void StickersBox::Tab::returnWidget(object_ptr<Inner> widget) {
_widget = std::move(widget);
t_assert(_widget == _weak);
Assert(_widget == _weak);
}
void StickersBox::Tab::saveScrollTop() {
@ -404,7 +404,7 @@ void StickersBox::switchTab() {
if (!_tabs) return;
auto tab = _tabs->activeSection();
t_assert(tab >= 0 && tab < _tabIndices.size());
Assert(tab >= 0 && tab < _tabIndices.size());
auto newSection = _tabIndices[tab];
auto newTab = _tab;

View file

@ -251,7 +251,7 @@ void BoxController::rowClicked(not_null<PeerListRow*> row) {
void BoxController::rowActionClicked(not_null<PeerListRow*> row) {
auto user = row->peer()->asUser();
t_assert(user != nullptr);
Assert(user != nullptr);
Current().startOutgoingCall(user);
}
@ -323,7 +323,7 @@ BoxController::Row *BoxController::rowForItem(HistoryItem *item) {
// In that case we sometimes need to return rowAt(left + 1), not rowAt(left).
if (result->minItemId() > itemId && left + 1 < fullRowsCount) {
auto possibleResult = static_cast<Row*>(v->peerListRowAt(left + 1).get());
t_assert(possibleResult->maxItemId() < itemId);
Assert(possibleResult->maxItemId() < itemId);
if (possibleResult->canAddItem(item)) {
return possibleResult;
}

View file

@ -118,8 +118,8 @@ void Call::start(base::const_byte_span random) {
// Save config here, because it is possible that it changes between
// different usages inside the same call.
_dhConfig = _delegate->getDhConfig();
t_assert(_dhConfig.g != 0);
t_assert(!_dhConfig.p.empty());
Assert(_dhConfig.g != 0);
Assert(!_dhConfig.p.empty());
generateModExpFirst(random);
if (_state == State::Starting || _state == State::Requesting) {
@ -242,7 +242,7 @@ void Call::redial() {
if (_state != State::Busy) {
return;
}
t_assert(_controller == nullptr);
Assert(_controller == nullptr);
_type = Type::Outgoing;
setState(State::Requesting);
_answerAfterDhConfigReceived = false;

View file

@ -134,7 +134,7 @@ std::vector<EmojiPtr> ComputeEmojiFingerprint(not_null<Call*> call) {
auto size = Offsets[index + 1] - offset;
auto string = QString::fromRawData(reinterpret_cast<QChar*>(Data + offset), size);
auto emoji = Ui::Emoji::Find(string);
t_assert(emoji != nullptr);
Assert(emoji != nullptr);
}
if (call->isKeyShaForFingerprintReady()) {
auto sha256 = call->getKeyShaForFingerprint();
@ -146,7 +146,7 @@ std::vector<EmojiPtr> ComputeEmojiFingerprint(not_null<Call*> call) {
auto size = Offsets[index + 1] - offset;
auto string = QString::fromRawData(reinterpret_cast<QChar*>(Data + offset), size);
auto emoji = Ui::Emoji::Find(string);
t_assert(emoji != nullptr);
Assert(emoji != nullptr);
result.push_back(emoji);
}
}

View file

@ -85,10 +85,10 @@ Panel::Button::Button(QWidget *parent, const style::CallButton &stFrom, const st
_bgMask = prepareRippleMask();
_bgFrom = App::pixmapFromImageInPlace(style::colorizeImage(_bgMask, _stFrom->bg));
if (_stTo) {
t_assert(_stFrom->button.width == _stTo->button.width);
t_assert(_stFrom->button.height == _stTo->button.height);
t_assert(_stFrom->button.rippleAreaPosition == _stTo->button.rippleAreaPosition);
t_assert(_stFrom->button.rippleAreaSize == _stTo->button.rippleAreaSize);
Assert(_stFrom->button.width == _stTo->button.width);
Assert(_stFrom->button.height == _stTo->button.height);
Assert(_stFrom->button.rippleAreaPosition == _stTo->button.rippleAreaPosition);
Assert(_stFrom->button.rippleAreaSize == _stTo->button.rippleAreaSize);
_bg = QImage(_bgMask.size(), QImage::Format_ARGB32_Premultiplied);
_bg.setDevicePixelRatio(cRetinaFactor());

View file

@ -430,7 +430,7 @@ QString SuggestionsController::getEmojiQuery() {
auto isGoodCharBeforeSuggestion = [isSuggestionChar](QChar ch) {
return !isSuggestionChar(ch) || (ch == 0);
};
t_assert(position > 0 && position <= text.size());
Assert(position > 0 && position <= text.size());
for (auto i = position; i != 0;) {
auto ch = text[--i];
if (ch == ':') {

View file

@ -380,7 +380,7 @@ void GifsListWidget::enterFromChildEvent(QEvent *e, QWidget *child) {
void GifsListWidget::clearSelection() {
if (_selected >= 0) {
int srow = _selected / MatrixRowShift, scol = _selected % MatrixRowShift;
t_assert(srow >= 0 && srow < _rows.size() && scol >= 0 && scol < _rows[srow].items.size());
Assert(srow >= 0 && srow < _rows.size() && scol >= 0 && scol < _rows[srow].items.size());
ClickHandler::clearActive(_rows[srow].items[scol]);
setCursor(style::cur_default);
}
@ -564,7 +564,7 @@ void GifsListWidget::deleteUnusedInlineLayouts() {
GifsListWidget::Row &GifsListWidget::layoutInlineRow(Row &row, int32 sumWidth) {
auto count = int(row.items.size());
t_assert(count <= kInlineItemsMaxPerRow);
Assert(count <= kInlineItemsMaxPerRow);
// enumerate items in the order of growing maxWidth()
// for that sort item indices by maxWidth()
@ -740,7 +740,7 @@ bool GifsListWidget::inlineItemVisible(const InlineBots::Layout::ItemBase *layou
auto row = position / MatrixRowShift;
auto col = position % MatrixRowShift;
t_assert((row < _rows.size()) && (col < _rows[row].items.size()));
Assert((row < _rows.size()) && (col < _rows[row].items.size()));
auto &inlineItems = _rows[row].items;
auto top = 0;
@ -912,12 +912,12 @@ void GifsListWidget::updateSelected() {
int scol = (_selected >= 0) ? (_selected % MatrixRowShift) : -1;
if (_selected != sel) {
if (srow >= 0 && scol >= 0) {
t_assert(srow >= 0 && srow < _rows.size() && scol >= 0 && scol < _rows[srow].items.size());
Assert(srow >= 0 && srow < _rows.size() && scol >= 0 && scol < _rows[srow].items.size());
_rows[srow].items[scol]->update();
}
_selected = sel;
if (row >= 0 && col >= 0) {
t_assert(row >= 0 && row < _rows.size() && col >= 0 && col < _rows[row].items.size());
Assert(row >= 0 && row < _rows.size() && col >= 0 && col < _rows[row].items.size());
_rows[row].items[col]->update();
}
if (_previewShown && _selected >= 0 && _pressed != _selected) {

View file

@ -406,7 +406,7 @@ void SetPackAndEmoji(Set &set, StickerPack &&pack, const QVector<MTPStickerPack>
set.stickers = std::move(pack);
set.emoji.clear();
for_const (auto &mtpPack, packs) {
t_assert(mtpPack.type() == mtpc_stickerPack);
Assert(mtpPack.type() == mtpc_stickerPack);
auto &pack = mtpPack.c_stickerPack();
if (auto emoji = Ui::Emoji::Find(qs(pack.vemoticon))) {
emoji = emoji->original();

View file

@ -876,7 +876,7 @@ bool StickersListWidget::hasRemoveButton(int index) const {
return true;
}
if (set.id == Stickers::MegagroupSetId) {
t_assert(_megagroupSet != nullptr);
Assert(_megagroupSet != nullptr);
if (index + 1 != _mySets.size()) {
return true;
}
@ -908,7 +908,7 @@ void StickersListWidget::mousePressEvent(QMouseEvent *e) {
void StickersListWidget::setPressed(OverState newPressed) {
if (auto button = base::get_if<OverButton>(&_pressed)) {
auto &sets = shownSets();
t_assert(button->section >= 0 && button->section < sets.size());
Assert(button->section >= 0 && button->section < sets.size());
auto &set = sets[button->section];
if (set.ripple) {
set.ripple->lastStop();
@ -921,7 +921,7 @@ void StickersListWidget::setPressed(OverState newPressed) {
_pressed = newPressed;
if (auto button = base::get_if<OverButton>(&_pressed)) {
auto &sets = shownSets();
t_assert(button->section >= 0 && button->section < sets.size());
Assert(button->section >= 0 && button->section < sets.size());
auto &set = sets[button->section];
if (!set.ripple) {
set.ripple = createButtonRipple(button->section);
@ -996,9 +996,9 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
auto &sets = shownSets();
if (pressed && pressed == _selected) {
if (auto sticker = base::get_if<OverSticker>(&pressed)) {
t_assert(sticker->section >= 0 && sticker->section < sets.size());
Assert(sticker->section >= 0 && sticker->section < sets.size());
auto &set = sets[sticker->section];
t_assert(sticker->index >= 0 && sticker->index < set.pack.size());
Assert(sticker->index >= 0 && sticker->index < set.pack.size());
if (stickerHasDeleteButton(set, sticker->index) && sticker->overDelete) {
if (set.id == Stickers::RecentSetId) {
removeRecentSticker(sticker->section, sticker->index);
@ -1011,10 +1011,10 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
}
emit selected(set.pack[sticker->index]);
} else if (auto set = base::get_if<OverSet>(&pressed)) {
t_assert(set->section >= 0 && set->section < sets.size());
Assert(set->section >= 0 && set->section < sets.size());
displaySet(sets[set->section].id);
} else if (auto button = base::get_if<OverButton>(&pressed)) {
t_assert(button->section >= 0 && button->section < sets.size());
Assert(button->section >= 0 && button->section < sets.size());
if (_section == Section::Featured) {
installSet(sets[button->section].id);
} else if (sets[button->section].id == Stickers::MegagroupSetId) {
@ -1479,7 +1479,7 @@ bool StickersListWidget::setHasTitle(const Set &set) const {
bool StickersListWidget::stickerHasDeleteButton(const Set &set, int index) const {
if (set.id == Stickers::RecentSetId) {
t_assert(index >= 0 && index < _custom.size());
Assert(index >= 0 && index < _custom.size());
return _custom[index];
}
return (set.id == Stickers::FavedSetId);
@ -1508,9 +1508,9 @@ void StickersListWidget::setSelected(OverState newSelected) {
if (_previewShown && _pressed != _selected) {
if (auto sticker = base::get_if<OverSticker>(&_selected)) {
_pressed = _selected;
t_assert(sticker->section >= 0 && sticker->section < sets.size());
Assert(sticker->section >= 0 && sticker->section < sets.size());
auto &set = sets[sticker->section];
t_assert(sticker->index >= 0 && sticker->index < set.pack.size());
Assert(sticker->index >= 0 && sticker->index < set.pack.size());
Ui::showMediaPreview(set.pack[sticker->index]);
}
}
@ -1524,9 +1524,9 @@ void StickersListWidget::onSettings() {
void StickersListWidget::onPreview() {
if (auto sticker = base::get_if<OverSticker>(&_pressed)) {
auto &sets = shownSets();
t_assert(sticker->section >= 0 && sticker->section < sets.size());
Assert(sticker->section >= 0 && sticker->section < sets.size());
auto &set = sets[sticker->section];
t_assert(sticker->index >= 0 && sticker->index < set.pack.size());
Assert(sticker->index >= 0 && sticker->index < set.pack.size());
Ui::showMediaPreview(set.pack[sticker->index]);
_previewShown = true;
}

View file

@ -143,7 +143,7 @@ void TabbedPanel::paintEvent(QPaintEvent *e) {
}
if (showAnimating) {
t_assert(_showAnimation != nullptr);
Assert(_showAnimation != nullptr);
if (auto opacity = _a_opacity.current(_hiding ? 0. : 1.)) {
_showAnimation->paintFrame(p, 0, 0, width(), _a_show.current(1.), opacity);
}

View file

@ -85,24 +85,24 @@ void TabbedSelector::SlideAnimation::setFinalImages(Direction direction, QImage
_leftImage = QPixmap::fromImage(std::move(left).convertToFormat(QImage::Format_ARGB32_Premultiplied), Qt::ColorOnly);
_rightImage = QPixmap::fromImage(std::move(right).convertToFormat(QImage::Format_ARGB32_Premultiplied), Qt::ColorOnly);
t_assert(!_leftImage.isNull());
t_assert(!_rightImage.isNull());
Assert(!_leftImage.isNull());
Assert(!_rightImage.isNull());
_width = _leftImage.width();
_height = _rightImage.height();
t_assert(!(_width % cIntRetinaFactor()));
t_assert(!(_height % cIntRetinaFactor()));
t_assert(_leftImage.devicePixelRatio() == _rightImage.devicePixelRatio());
t_assert(_rightImage.width() == _width);
t_assert(_rightImage.height() == _height);
t_assert(QRect(0, 0, _width, _height).contains(inner));
Assert(!(_width % cIntRetinaFactor()));
Assert(!(_height % cIntRetinaFactor()));
Assert(_leftImage.devicePixelRatio() == _rightImage.devicePixelRatio());
Assert(_rightImage.width() == _width);
Assert(_rightImage.height() == _height);
Assert(QRect(0, 0, _width, _height).contains(inner));
_innerLeft = inner.x();
_innerTop = inner.y();
_innerWidth = inner.width();
_innerHeight = inner.height();
t_assert(!(_innerLeft % cIntRetinaFactor()));
t_assert(!(_innerTop % cIntRetinaFactor()));
t_assert(!(_innerWidth % cIntRetinaFactor()));
t_assert(!(_innerHeight % cIntRetinaFactor()));
Assert(!(_innerLeft % cIntRetinaFactor()));
Assert(!(_innerTop % cIntRetinaFactor()));
Assert(!(_innerWidth % cIntRetinaFactor()));
Assert(!(_innerHeight % cIntRetinaFactor()));
_innerRight = _innerLeft + _innerWidth;
_innerBottom = _innerTop + _innerHeight;
@ -118,13 +118,13 @@ void TabbedSelector::SlideAnimation::setFinalImages(Direction direction, QImage
}
void TabbedSelector::SlideAnimation::start() {
t_assert(!_leftImage.isNull());
t_assert(!_rightImage.isNull());
Assert(!_leftImage.isNull());
Assert(!_rightImage.isNull());
RoundShadowAnimation::start(_width, _height, _leftImage.devicePixelRatio());
auto checkCorner = [this](const Corner &corner) {
if (!corner.valid()) return;
t_assert(corner.width <= _innerWidth);
t_assert(corner.height <= _innerHeight);
Assert(corner.width <= _innerWidth);
Assert(corner.height <= _innerHeight);
};
checkCorner(_topLeft);
checkCorner(_topRight);
@ -617,7 +617,7 @@ bool TabbedSelector::hasSectionIcons() const {
void TabbedSelector::switchTab() {
auto tab = _tabsSlider->activeSection();
t_assert(tab >= 0 && tab < Tab::kCount);
Assert(tab >= 0 && tab < Tab::kCount);
auto newTabType = static_cast<SelectorTab>(tab);
if (_currentTabType == newTabType) {
return;

View file

@ -625,7 +625,7 @@ for restype in typesList:
getters += '\tconst MTPD' + name + ' &c_' + name + '() const;\n'; # const getter
constructsBodies += 'const MTPD' + name + ' &MTP' + restype + '::c_' + name + '() const {\n';
if (withType):
constructsBodies += '\tt_assert(_type == mtpc_' + name + ');\n';
constructsBodies += '\tAssert(_type == mtpc_' + name + ');\n';
constructsBodies += '\treturn queryData<MTPD' + name + '>();\n';
constructsBodies += '}\n';
@ -770,7 +770,7 @@ for restype in typesList:
typesText += '\tmtpTypeId type() const;\n'; # type id method
methods += 'mtpTypeId MTP' + restype + '::type() const {\n';
if (withType):
methods += '\tt_assert(_type != 0);\n';
methods += '\tAssert(_type != 0);\n';
methods += '\treturn _type;\n';
else:
methods += '\treturn mtpc_' + v[0][0] + ';\n';

View file

@ -748,8 +748,8 @@ int palette::indexOfColor(style::color c) const {\n\
}\n\
\n\
color palette::colorAtIndex(int index) const {\n\
t_assert(_ready);\n\
t_assert(index >= 0 && index < kCount);\n\
Assert(_ready);\n\
Assert(index >= 0 && index < kCount);\n\
return _colors[index];\n\
}\n\
\n\

View file

@ -181,22 +181,22 @@ namespace {
int _ffmpegLockManager(void **mutex, AVLockOp op) {
switch (op) {
case AV_LOCK_CREATE: {
t_assert(*mutex == 0);
Assert(*mutex == 0);
*mutex = reinterpret_cast<void*>(new QMutex());
} break;
case AV_LOCK_OBTAIN: {
t_assert(*mutex != 0);
Assert(*mutex != 0);
reinterpret_cast<QMutex*>(*mutex)->lock();
} break;
case AV_LOCK_RELEASE: {
t_assert(*mutex != 0);
Assert(*mutex != 0);
reinterpret_cast<QMutex*>(*mutex)->unlock();
}; break;
case AV_LOCK_DESTROY: {
t_assert(*mutex != 0);
Assert(*mutex != 0);
delete reinterpret_cast<QMutex*>(*mutex);
*mutex = 0;
} break;
@ -662,7 +662,7 @@ char *hashMd5Hex(const int32 *hashmd5, void *dest) {
}
void memset_rand(void *data, uint32 len) {
t_assert(_sslInited);
Assert(_sslInited);
RAND_bytes((uchar*)data, len);
}

View file

@ -22,42 +22,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "core/basic_types.h"
// Release build assertions.
inline void t_noop() {
}
[[noreturn]] inline void t_assert_fail(const char *message, const char *file, int32 line) {
auto info = qsl("%1 %2:%3").arg(message).arg(file).arg(line);
LOG(("Assertion Failed! ") + info);
SignalHandlers::setCrashAnnotation("Assertion", info);
// Crash with access violation and generate crash report.
volatile int *t_assert_nullptr = nullptr;
*t_assert_nullptr = 0;
// Silent the possible failure to comply noreturn warning.
std::abort();
}
#define t_assert_full(condition, message, file, line) ((GSL_UNLIKELY(!(condition))) ? t_assert_fail(message, file, line) : t_noop())
#define t_assert_c(condition, comment) t_assert_full(condition, "\"" #condition "\" (" comment ")", __FILE__, __LINE__)
#define t_assert(condition) t_assert_full(condition, "\"" #condition "\"", __FILE__, __LINE__)
// Declare our own versions of Expects() and Ensures().
// Let them crash with reports and logging.
#ifdef Expects
#undef Expects
#endif // Expects
#define Expects(condition) t_assert_full(condition, "\"" #condition "\"", __FILE__, __LINE__)
#ifdef Ensures
#undef Ensures
#endif // Ensures
#define Ensures(condition) t_assert_full(condition, "\"" #condition "\"", __FILE__, __LINE__)
#ifdef Unexpected
#undef Unexpected
#endif // Unexpected
#define Unexpected(message) t_assert_fail("Unexpected: " message, __FILE__, __LINE__)
// Define specializations for QByteArray for Qt 5.3.2, because
// QByteArray in Qt 5.3.2 doesn't declare "pointer" subtype.
#ifdef OS_MAC_OLD
@ -667,7 +631,7 @@ public:
return data();
}
T &operator*() const {
t_assert(!isNull());
Assert(!isNull());
return *data();
}
explicit operator bool() const {
@ -710,7 +674,7 @@ public:
return data();
}
T &operator*() const {
t_assert(!isNull());
Assert(!isNull());
return *data();
}
explicit operator bool() const {

View file

@ -60,11 +60,11 @@ public:
}
}
Structure *operator->() {
t_assert(_p != nullptr);
Assert(_p != nullptr);
return static_cast<Structure*>(_p);
}
const Structure *operator->() const {
t_assert(_p != nullptr);
Assert(_p != nullptr);
return static_cast<const Structure*>(_p);
}
explicit operator bool() const {

View file

@ -82,17 +82,17 @@ void IndexedList::moveToTop(PeerData *peer) {
void IndexedList::movePinned(Row *row, int deltaSign) {
auto swapPinnedIndexWith = find(row);
t_assert(swapPinnedIndexWith != cend());
Assert(swapPinnedIndexWith != cend());
if (deltaSign > 0) {
++swapPinnedIndexWith;
} else {
t_assert(swapPinnedIndexWith != cbegin());
Assert(swapPinnedIndexWith != cbegin());
--swapPinnedIndexWith;
}
auto history1 = row->history();
auto history2 = (*swapPinnedIndexWith)->history();
t_assert(history1->isPinnedDialog());
t_assert(history2->isPinnedDialog());
Assert(history1->isPinnedDialog());
Assert(history2->isPinnedDialog());
auto index1 = history1->getPinnedIndex();
auto index2 = history2->getPinnedIndex();
history1->setPinnedIndex(index2);
@ -100,7 +100,7 @@ void IndexedList::movePinned(Row *row, int deltaSign) {
}
void IndexedList::peerNameChanged(PeerData *peer, const PeerData::Names &oldNames, const PeerData::NameFirstChars &oldChars) {
t_assert(_sortMode != SortMode::Date);
Assert(_sortMode != SortMode::Date);
if (_sortMode == SortMode::Name) {
adjustByName(peer, oldNames, oldChars);
} else {
@ -109,7 +109,7 @@ void IndexedList::peerNameChanged(PeerData *peer, const PeerData::Names &oldName
}
void IndexedList::peerNameChanged(Mode list, PeerData *peer, const PeerData::Names &oldNames, const PeerData::NameFirstChars &oldChars) {
t_assert(_sortMode == SortMode::Date);
Assert(_sortMode == SortMode::Date);
adjustNames(list, peer, oldNames, oldChars);
}

View file

@ -729,7 +729,7 @@ int DialogsInner::updateReorderIndexGetCount() {
}
auto count = shownPinnedCount();
t_assert(index < count);
Assert(index < count);
if (count < 2) {
stopReorderPinned();
return 0;

View file

@ -203,7 +203,7 @@ const style::icon *ChatTypeIcon(PeerData *peer, bool active, bool selected) {
}
void paintUnreadBadge(Painter &p, const QRect &rect, const UnreadBadgeStyle &st) {
t_assert(rect.height() == st.size);
Assert(rect.height() == st.size);
int index = (st.muted ? 0x03 : 0x00) + (st.active ? 0x02 : (st.selected ? 0x01 : 0x00));
int size = st.size, sizehalf = size / 2;
@ -211,7 +211,7 @@ void paintUnreadBadge(Painter &p, const QRect &rect, const UnreadBadgeStyle &st)
unreadBadgeStyle.createIfNull();
auto badgeData = unreadBadgeStyle->sizes;
if (st.sizeId > 0) {
t_assert(st.sizeId < UnreadBadgeSizesCount);
Assert(st.sizeId < UnreadBadgeSizesCount);
badgeData = &unreadBadgeStyle->sizes[st.sizeId];
}
auto bg = unreadBadgeStyle->bg[index];

View file

@ -382,7 +382,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
_dialogsFull = true;
}
t_assert(messagesList != nullptr);
Assert(messagesList != nullptr);
App::feedMsgs(*messagesList, NewMessageLast);
unreadCountsReceived(*dialogsList);

View file

@ -372,17 +372,17 @@ void unreadCounterUpdated() {
} // namespace Notify
#define DefineReadOnlyVar(Namespace, Type, Name) const Type &Name() { \
t_assert_full(Namespace##Data != 0, #Namespace "Data != nullptr in " #Namespace "::" #Name, __FILE__, __LINE__); \
AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::" #Name); \
return Namespace##Data->Name; \
}
#define DefineRefVar(Namespace, Type, Name) DefineReadOnlyVar(Namespace, Type, Name) \
Type &Ref##Name() { \
t_assert_full(Namespace##Data != 0, #Namespace "Data != nullptr in " #Namespace "::Ref" #Name, __FILE__, __LINE__); \
AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::Ref" #Name); \
return Namespace##Data->Name; \
}
#define DefineVar(Namespace, Type, Name) DefineRefVar(Namespace, Type, Name) \
void Set##Name(const Type &Name) { \
t_assert_full(Namespace##Data != 0, #Namespace "Data != nullptr in " #Namespace "::Set" #Name, __FILE__, __LINE__); \
AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::Set" #Name); \
Namespace##Data->Name = Name; \
}

View file

@ -722,7 +722,7 @@ void Histories::setIsPinned(History *history, bool isPinned) {
minIndexHistory = pinned;
}
}
t_assert(minIndexHistory != nullptr);
Assert(minIndexHistory != nullptr);
minIndexHistory->setPinnedDialog(false);
}
} else {
@ -1543,7 +1543,7 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice) {
}
}
t_assert(!isBuildingFrontBlock());
Assert(!isBuildingFrontBlock());
if (!slice.isEmpty()) {
bool atLeastOneAdded = false;
for (auto i = slice.cend(), e = slice.cbegin(); i != e;) {
@ -1797,7 +1797,7 @@ void History::countScrollTopItem(int top) {
auto item = block->items[itemIndex];
itemTop = block->y() + item->y();
if (itemTop > top) {
t_assert(itemIndex > 0 || blockIndex > 0);
Assert(itemIndex > 0 || blockIndex > 0);
if (itemIndex > 0) {
scrollTopItem = block->items[itemIndex - 1];
} else {
@ -1871,15 +1871,15 @@ HistoryItem *History::addNewInTheMiddle(HistoryItem *newItem, int32 blockIndex,
}
void History::startBuildingFrontBlock(int expectedItemsCount) {
t_assert(!isBuildingFrontBlock());
t_assert(expectedItemsCount > 0);
Assert(!isBuildingFrontBlock());
Assert(expectedItemsCount > 0);
_buildingFrontBlock.reset(new BuildingBlock());
_buildingFrontBlock->expectedItemsCount = expectedItemsCount;
}
HistoryBlock *History::finishBuildingFrontBlock() {
t_assert(isBuildingFrontBlock());
Assert(isBuildingFrontBlock());
// Some checks if there was some message history already
auto block = _buildingFrontBlock->block;
@ -2184,7 +2184,7 @@ void History::clearOnDestroy() {
}
History::PositionInChatListChange History::adjustByPosInChatList(Dialogs::Mode list, Dialogs::IndexedList *indexed) {
t_assert(indexed != nullptr);
Assert(indexed != nullptr);
Dialogs::Row *lnk = mainChatListLink(list);
int32 movedFrom = lnk->pos();
indexed->adjustByPos(chatListLinks(list));
@ -2197,7 +2197,7 @@ int History::posInChatList(Dialogs::Mode list) const {
}
Dialogs::Row *History::addToChatList(Dialogs::Mode list, Dialogs::IndexedList *indexed) {
t_assert(indexed != nullptr);
Assert(indexed != nullptr);
if (!inChatList(list)) {
chatListLinks(list) = indexed->addToEnd(this);
if (list == Dialogs::Mode::All && unreadCount()) {
@ -2209,7 +2209,7 @@ Dialogs::Row *History::addToChatList(Dialogs::Mode list, Dialogs::IndexedList *i
}
void History::removeFromChatList(Dialogs::Mode list, Dialogs::IndexedList *indexed) {
t_assert(indexed != nullptr);
Assert(indexed != nullptr);
if (inChatList(list)) {
indexed->del(peer);
chatListLinks(list).clear();
@ -2221,14 +2221,14 @@ void History::removeFromChatList(Dialogs::Mode list, Dialogs::IndexedList *index
}
void History::removeChatListEntryByLetter(Dialogs::Mode list, QChar letter) {
t_assert(letter != 0);
Assert(letter != 0);
if (inChatList(list)) {
chatListLinks(list).remove(letter);
}
}
void History::addChatListEntryByLetter(Dialogs::Mode list, QChar letter, Dialogs::Row *row) {
t_assert(letter != 0);
Assert(letter != 0);
if (inChatList(list)) {
chatListLinks(list).insert(letter, row);
}

View file

@ -571,7 +571,7 @@ private:
}
Dialogs::Row *mainChatListLink(Dialogs::Mode list) const {
auto it = chatListLinks(list).constFind(0);
t_assert(it != chatListLinks(list).cend());
Assert(it != chatListLinks(list).cend());
return it.value();
}
uint64 _sortKeyInChatList = 0; // like ((unixtime) << 32) | (incremented counter)

View file

@ -72,9 +72,9 @@ void InnerWidget::enumerateItems(Method method) {
--from;
}
if (TopToBottom) {
t_assert(itemTop(from->get()) + from->get()->height() > _visibleTop);
Assert(itemTop(from->get()) + from->get()->height() > _visibleTop);
} else {
t_assert(itemTop(from->get()) < _visibleBottom);
Assert(itemTop(from->get()) < _visibleBottom);
}
while (true) {
@ -84,9 +84,9 @@ void InnerWidget::enumerateItems(Method method) {
// Binary search should've skipped all the items that are above / below the visible area.
if (TopToBottom) {
t_assert(itembottom > _visibleTop);
Assert(itembottom > _visibleTop);
} else {
t_assert(itemtop < _visibleBottom);
Assert(itemtop < _visibleBottom);
}
if (!method(item, itemtop, itembottom)) {
@ -509,7 +509,7 @@ void InnerWidget::addEvents(Direction direction, const QVector<MTPChannelAdminLo
auto &addToItems = (direction == Direction::Up) ? _items : newItemsForDownDirection;
addToItems.reserve(oldItemsCount + events.size() * 2);
for_const (auto &event, events) {
t_assert(event.type() == mtpc_channelAdminLogEvent);
Assert(event.type() == mtpc_channelAdminLogEvent);
auto &data = event.c_channelAdminLogEvent();
if (_itemsByIds.find(data.vid.v) != _itemsByIds.cend()) {
continue;

View file

@ -184,9 +184,9 @@ void HistoryInner::enumerateItemsInHistory(History *history, int historytop, Met
// Binary search should've skipped all the items that are above / below the visible area.
if (TopToBottom) {
t_assert(itembottom > _visibleAreaTop);
Assert(itembottom > _visibleAreaTop);
} else {
t_assert(itemtop < _visibleAreaBottom);
Assert(itemtop < _visibleAreaBottom);
}
if (!method(item, itemtop, itembottom)) {
@ -1868,7 +1868,7 @@ void HistoryInner::adjustCurrent(int32 y) const {
}
void HistoryInner::adjustCurrent(int32 y, History *history) const {
t_assert(!history->isEmpty());
Assert(!history->isEmpty());
_curHistory = history;
if (_curBlock >= history->blocks.size()) {
_curBlock = history->blocks.size() - 1;
@ -2282,11 +2282,11 @@ int HistoryInner::historyScrollTop() const {
auto htop = historyTop();
auto mtop = migratedTop();
if (htop >= 0 && _history->scrollTopItem) {
t_assert(!_history->scrollTopItem->detached());
Assert(!_history->scrollTopItem->detached());
return htop + _history->scrollTopItem->block()->y() + _history->scrollTopItem->y() + _history->scrollTopOffset;
}
if (mtop >= 0 && _migrated->scrollTopItem) {
t_assert(!_migrated->scrollTopItem->detached());
Assert(!_migrated->scrollTopItem->detached());
return mtop + _migrated->scrollTopItem->block()->y() + _migrated->scrollTopItem->y() + _migrated->scrollTopOffset;
}
return ScrollMax;

View file

@ -227,8 +227,8 @@ int ReplyKeyboard::naturalHeight() const {
}
void ReplyKeyboard::paint(Painter &p, int outerWidth, const QRect &clip, TimeMs ms) const {
t_assert(_st != nullptr);
t_assert(_width > 0);
Assert(_st != nullptr);
Assert(_width > 0);
_st->startPaint(p);
for_const (auto &row, _rows) {
@ -246,7 +246,7 @@ void ReplyKeyboard::paint(Painter &p, int outerWidth, const QRect &clip, TimeMs
}
ClickHandlerPtr ReplyKeyboard::getState(QPoint point) const {
t_assert(_width > 0);
Assert(_width > 0);
for_const (auto &row, _rows) {
for_const (auto &button, row) {
@ -688,7 +688,7 @@ void HistoryItem::addLogEntryOriginal(WebPageId localId, const QString &label, c
void HistoryItem::destroy() {
if (isLogEntry()) {
t_assert(detached());
Assert(detached());
} else {
// All this must be done for all items manually in History::clear(false)!
eraseFromOverview();
@ -942,7 +942,7 @@ bool HistoryItem::hasDirectLink() const {
QString HistoryItem::directLink() const {
if (hasDirectLink()) {
auto channel = _history->peer->asChannel();
t_assert(channel != nullptr);
Assert(channel != nullptr);
auto query = channel->username + '/' + QString::number(id);
if (!channel->isMegagroup()) {
if (auto media = getMedia()) {
@ -996,7 +996,7 @@ bool HistoryItem::unread() const {
void HistoryItem::destroyUnreadBar() {
if (Has<HistoryMessageUnreadBar>()) {
t_assert(!isLogEntry());
Assert(!isLogEntry());
RemoveComponents(HistoryMessageUnreadBar::Bit());
setPendingInitDimensions();

View file

@ -955,7 +955,7 @@ protected:
return _block->items.at(_indexInBlock - 1);
}
if (auto previous = _block->previousBlock()) {
t_assert(!previous->items.isEmpty());
Assert(!previous->items.isEmpty());
return previous->items.back();
}
}
@ -967,7 +967,7 @@ protected:
return _block->items.at(_indexInBlock + 1);
}
if (auto next = _block->nextBlock()) {
t_assert(!next->items.isEmpty());
Assert(!next->items.isEmpty());
return next->items.front();
}
}

View file

@ -229,7 +229,7 @@ void HistoryService::setSelfDestruct(HistoryServiceSelfDestruct::Type type, int
bool HistoryService::updateDependent(bool force) {
auto dependent = GetDependentData();
t_assert(dependent != nullptr);
Assert(dependent != nullptr);
if (!force) {
if (!dependent->msgId || dependent->msg) {
@ -626,7 +626,7 @@ void HistoryService::createFromMtp(const MTPDmessage &message) {
case mtpc_messageMediaPhoto: {
if (message.is_media_unread()) {
auto &photo = message.vmedia.c_messageMediaPhoto();
t_assert(photo.has_ttl_seconds());
Assert(photo.has_ttl_seconds());
setSelfDestruct(HistoryServiceSelfDestruct::Type::Photo, photo.vttl_seconds.v);
if (out()) {
setServiceText({ lang(lng_ttl_photo_sent) });
@ -643,7 +643,7 @@ void HistoryService::createFromMtp(const MTPDmessage &message) {
case mtpc_messageMediaDocument: {
if (message.is_media_unread()) {
auto &document = message.vmedia.c_messageMediaDocument();
t_assert(document.has_ttl_seconds());
Assert(document.has_ttl_seconds());
setSelfDestruct(HistoryServiceSelfDestruct::Type::Video, document.vttl_seconds.v);
if (out()) {
setServiceText({ lang(lng_ttl_video_sent) });

View file

@ -957,7 +957,7 @@ void HistoryWidget::highlightMessage(HistoryItem *context) {
int HistoryWidget::itemTopForHighlight(not_null<HistoryItem*> item) const {
auto itemTop = _list->itemTop(item);
t_assert(itemTop >= 0);
Assert(itemTop >= 0);
auto heightLeft = (_scroll->height() - item->height());
if (heightLeft <= 0) {
@ -1084,7 +1084,7 @@ void HistoryWidget::setReportSpamStatus(DBIPeerReportSpamStatus status) {
}
_reportSpamStatus = status;
if (_reportSpamStatus == dbiprsShowButton || _reportSpamStatus == dbiprsReportSent) {
t_assert(_peer != nullptr);
Assert(_peer != nullptr);
_reportSpamPanel.create(this);
connect(_reportSpamPanel, SIGNAL(reportClicked()), this, SLOT(onReportSpamClicked()));
connect(_reportSpamPanel, SIGNAL(hideClicked()), this, SLOT(onReportSpamHide()));
@ -3890,7 +3890,7 @@ void HistoryWidget::toggleTabbedSelectorMode() {
recountChatWidth();
updateControlsGeometry();
} else {
t_assert(_tabbedPanel != nullptr);
Assert(_tabbedPanel != nullptr);
_tabbedPanel->toggleAnimated();
}
}
@ -4319,7 +4319,7 @@ void HistoryWidget::uploadFiles(const QStringList &files, SendMediaType type) {
}
void HistoryWidget::uploadFilesAfterConfirmation(const QStringList &files, const QByteArray &content, const QImage &image, std::unique_ptr<FileLoadTask::MediaInformation> information, SendMediaType type, QString caption) {
t_assert(canWriteMessage());
Assert(canWriteMessage());
auto to = FileLoadTo(_peer->id, _silent->checked(), replyToId());
if (files.size() > 1 && !caption.isEmpty()) {
@ -5167,7 +5167,7 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) {
Ui::showPeerHistory(_peer, _editMsgId ? _editMsgId : replyToId());
}
} else if (_inPinnedMsg) {
t_assert(_pinnedBar != nullptr);
Assert(_pinnedBar != nullptr);
Ui::showPeerHistory(_peer, _pinnedBar->msgId);
}
}
@ -5332,7 +5332,7 @@ void HistoryWidget::updatePinnedBar(bool force) {
}
}
t_assert(_history != nullptr);
Assert(_history != nullptr);
if (!_pinnedBar->msg) {
_pinnedBar->msg = App::histItemById(_history->channelId(), _pinnedBar->msgId);
}

View file

@ -114,7 +114,7 @@ public:
return true;
}
bool getLocationCoords(LocationCoords *outLocation) const override {
t_assert(outLocation != nullptr);
Assert(outLocation != nullptr);
*outLocation = _location;
return true;
}
@ -146,7 +146,7 @@ public:
return true;
}
bool getLocationCoords(LocationCoords *outLocation) const override {
t_assert(outLocation != nullptr);
Assert(outLocation != nullptr);
*outLocation = _location;
return true;
}

View file

@ -262,7 +262,7 @@ void Inner::enterFromChildEvent(QEvent *e, QWidget *child) {
void Inner::clearSelection() {
if (_selected >= 0) {
int srow = _selected / MatrixRowShift, scol = _selected % MatrixRowShift;
t_assert(srow >= 0 && srow < _rows.size() && scol >= 0 && scol < _rows.at(srow).items.size());
Assert(srow >= 0 && srow < _rows.size() && scol >= 0 && scol < _rows.at(srow).items.size());
ClickHandler::clearActive(_rows.at(srow).items.at(scol));
setCursor(style::cur_default);
}
@ -375,7 +375,7 @@ void Inner::deleteUnusedInlineLayouts() {
Inner::Row &Inner::layoutInlineRow(Row &row, int32 sumWidth) {
auto count = int(row.items.size());
t_assert(count <= kInlineItemsMaxPerRow);
Assert(count <= kInlineItemsMaxPerRow);
// enumerate items in the order of growing maxWidth()
// for that sort item indices by maxWidth()
@ -470,7 +470,7 @@ int Inner::refreshInlineRows(PeerData *queryPeer, UserData *bot, const CacheEntr
clearSelection();
t_assert(_inlineBot != 0);
Assert(_inlineBot != 0);
auto count = int(entry->results.size());
auto from = validateExistingInlineRows(entry->results);
@ -588,7 +588,7 @@ bool Inner::inlineItemVisible(const ItemBase *layout) {
}
int row = position / MatrixRowShift, col = position % MatrixRowShift;
t_assert((row < _rows.size()) && (col < _rows[row].items.size()));
Assert((row < _rows.size()) && (col < _rows[row].items.size()));
auto &inlineItems = _rows[row].items;
int top = st::stickerPanPadding;
@ -652,12 +652,12 @@ void Inner::updateSelected() {
int scol = (_selected >= 0) ? (_selected % MatrixRowShift) : -1;
if (_selected != sel) {
if (srow >= 0 && scol >= 0) {
t_assert(srow >= 0 && srow < _rows.size() && scol >= 0 && scol < _rows.at(srow).items.size());
Assert(srow >= 0 && srow < _rows.size() && scol >= 0 && scol < _rows.at(srow).items.size());
_rows[srow].items[scol]->update();
}
_selected = sel;
if (row >= 0 && col >= 0) {
t_assert(row >= 0 && row < _rows.size() && col >= 0 && col < _rows.at(row).items.size());
Assert(row >= 0 && row < _rows.size() && col >= 0 && col < _rows.at(row).items.size());
_rows[row].items[col]->update();
}
if (_previewShown && _selected >= 0 && _pressed != _selected) {
@ -811,7 +811,7 @@ void Widget::paintEvent(QPaintEvent *e) {
}
if (showAnimating) {
t_assert(_showAnimation != nullptr);
Assert(_showAnimation != nullptr);
if (auto opacity = _a_opacity.current(_hiding ? 0. : 1.)) {
_showAnimation->paintFrame(p, 0, 0, width(), _a_show.current(1.), opacity);
}

View file

@ -163,7 +163,7 @@ void Widget::setInnerFocus() {
void Widget::historyMove(Direction direction) {
if (getStep()->animating()) return;
t_assert(_stepHistory.size() > 1);
Assert(_stepHistory.size() > 1);
auto wasStep = getStep((direction == Direction::Back) ? 0 : 1);
if (direction == Direction::Back) {
@ -614,9 +614,9 @@ void Widget::Step::prepareCoverMask() {
auto maskHeight = st::introCoverHeight * cIntRetinaFactor();
auto mask = QImage(maskWidth, maskHeight, QImage::Format_ARGB32_Premultiplied);
auto maskInts = reinterpret_cast<uint32*>(mask.bits());
t_assert(mask.depth() == (sizeof(uint32) << 3));
Assert(mask.depth() == (sizeof(uint32) << 3));
auto maskIntsPerLineAdded = (mask.bytesPerLine() >> 2) - maskWidth;
t_assert(maskIntsPerLineAdded >= 0);
Assert(maskIntsPerLineAdded >= 0);
auto realHeight = static_cast<float64>(maskHeight - 1);
for (auto y = 0; y != maskHeight; ++y) {
auto color = anim::color(st::introCoverTopBg, st::introCoverBottomBg, y / realHeight);

View file

@ -232,7 +232,7 @@ private:
void resetAccount();
Step *getStep(int skip = 0) {
t_assert(_stepHistory.size() + skip > 0);
Assert(_stepHistory.size() + skip > 0);
return _stepHistory.at(_stepHistory.size() - skip - 1);
}
void historyMove(Direction direction);

View file

@ -116,7 +116,7 @@ void CloudManager::requestLanguageList() {
_languagesRequestId = request(MTPlangpack_GetLanguages()).done([this](const MTPVector<MTPLangPackLanguage> &result) {
auto languages = Languages();
for_const (auto &langData, result.v) {
t_assert(langData.type() == mtpc_langPackLanguage);
Assert(langData.type() == mtpc_langPackLanguage);
auto &language = langData.c_langPackLanguage();
languages.push_back({ qs(language.vlang_code), qs(language.vname), qs(language.vnative_name) });
}
@ -312,7 +312,7 @@ void CloudManager::changeIdAndReInitConnection(const QString &id) {
CloudManager &CurrentCloudManager() {
auto result = Messenger::Instance().langCloudManager();
t_assert(result != nullptr);
Assert(result != nullptr);
return *result;
}

View file

@ -161,7 +161,7 @@ private:
QFlags<QIODevice::OpenModeFlag> mode = QIODevice::WriteOnly | QIODevice::Text;
if (type == LogDataMain) { // we can call LOG() in LogDataMain reopen - mutex not locked
if (postfix.isEmpty()) { // instance checked, need to move to log.txt
t_assert(!files[type]->fileName().isEmpty()); // one of log_startXX.txt should've been opened already
Assert(!files[type]->fileName().isEmpty()); // one of log_startXX.txt should've been opened already
QSharedPointer<QFile> to(new QFile(_logsFilePath(type, postfix)));
if (to->exists() && !to->remove()) {
@ -301,7 +301,7 @@ namespace SignalHandlers {
namespace Logs {
void start() {
t_assert(LogsData == 0);
Assert(LogsData == 0);
if (!Sandbox::CheckBetaVersionDir()) {
return;
@ -386,7 +386,7 @@ namespace Logs {
}
if (LogsInMemory) {
t_assert(LogsInMemory != DeletedLogsInMemory);
Assert(LogsInMemory != DeletedLogsInMemory);
LogsInMemoryList list = *LogsInMemory;
for (LogsInMemoryList::const_iterator i = list.cbegin(), e = list.cend(); i != e; ++i) {
if (i->first == LogDataMain) {
@ -429,7 +429,7 @@ namespace Logs {
}
if (LogsInMemory) {
t_assert(LogsInMemory != DeletedLogsInMemory);
Assert(LogsInMemory != DeletedLogsInMemory);
LogsInMemoryList list = *LogsInMemory;
for (LogsInMemoryList::const_iterator i = list.cbegin(), e = list.cend(); i != e; ++i) {
if (i->first != LogDataMain) {
@ -438,7 +438,7 @@ namespace Logs {
}
}
if (LogsInMemory) {
t_assert(LogsInMemory != DeletedLogsInMemory);
Assert(LogsInMemory != DeletedLogsInMemory);
delete LogsInMemory;
}
LogsInMemory = DeletedLogsInMemory;
@ -450,7 +450,7 @@ namespace Logs {
void multipleInstances() {
if (LogsInMemory) {
t_assert(LogsInMemory != DeletedLogsInMemory);
Assert(LogsInMemory != DeletedLogsInMemory);
delete LogsInMemory;
}
LogsInMemory = DeletedLogsInMemory;

View file

@ -117,3 +117,15 @@ namespace SignalHandlers {
}
}
namespace base {
namespace assertion {
inline void log(const char *message, const char *file, int line) {
auto info = QStringLiteral("%1 %2:%3").arg(message).arg(file).arg(line);
LOG(("Assertion Failed! ") + info);
SignalHandlers::setCrashAnnotation("Assertion", info);
}
} // namespace assertion
} // namespace base

View file

@ -381,7 +381,7 @@ void MainWidget::removeFloatPlayer(not_null<Float*> instance) {
auto i = std::find_if(_playerFloats.begin(), _playerFloats.end(), [instance](auto &item) {
return (item.get() == instance);
});
t_assert(i != _playerFloats.end());
Assert(i != _playerFloats.end());
_playerFloats.erase(i);
// ~QWidget() can call HistoryInner::enterEvent() which can
@ -1118,7 +1118,7 @@ void MainWidget::deleteAndExit(ChatData *chat) {
}
void MainWidget::deleteAllFromUser(ChannelData *channel, UserData *from) {
t_assert(channel != nullptr && from != nullptr);
Assert(channel != nullptr && from != nullptr);
QVector<MsgId> toDestroy;
if (auto history = App::historyLoaded(channel->id)) {
@ -5189,7 +5189,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
App::histories().clearPinned();
for (auto i = order.size(); i != 0;) {
auto history = App::historyLoaded(peerFromMTP(order[--i]));
t_assert(history != nullptr);
Assert(history != nullptr);
history->setPinnedDialog(true);
}
} else {

View file

@ -213,7 +213,7 @@ void MainWindow::clearPasscode() {
if (_intro) {
_intro->showAnimated(bg, true);
} else {
t_assert(_main != nullptr);
Assert(_main != nullptr);
_main->showAnimated(bg, true);
Messenger::Instance().checkStartUrl();
}
@ -299,7 +299,7 @@ void MainWindow::setupMain(const MTPUser *self) {
clearWidgets();
t_assert(AuthSession::Exists());
Assert(AuthSession::Exists());
_main.create(bodyWidget(), controller());
_main->show();

View file

@ -79,7 +79,7 @@ bool PlaybackErrorHappened() {
void EnumeratePlaybackDevices() {
auto deviceNames = QStringList();
auto devices = alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
t_assert(devices != nullptr);
Assert(devices != nullptr);
while (*devices != 0) {
auto deviceName8Bit = QByteArray(devices);
auto deviceName = QString::fromLocal8Bit(deviceName8Bit);
@ -98,7 +98,7 @@ void EnumeratePlaybackDevices() {
void EnumerateCaptureDevices() {
auto deviceNames = QStringList();
auto devices = alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER);
t_assert(devices != nullptr);
Assert(devices != nullptr);
while (*devices != 0) {
auto deviceName8Bit = QByteArray(devices);
auto deviceName = QString::fromLocal8Bit(deviceName8Bit);
@ -174,7 +174,7 @@ void ClosePlaybackDevice() {
// Thread: Main.
void Start() {
t_assert(AudioDevice == nullptr);
Assert(AudioDevice == nullptr);
qRegisterMetaType<AudioMsgId>();
qRegisterMetaType<VoiceWaveform>();

View file

@ -50,7 +50,7 @@ bool ErrorHappened(ALCdevice *device) {
} // namespace
void Start() {
t_assert(CaptureInstance == nullptr);
Assert(CaptureInstance == nullptr);
CaptureInstance = new Instance();
instance()->check();
}

View file

@ -38,18 +38,18 @@ bool AudioPlayerLoader::check(const FileLocation &file, const QByteArray &data)
}
void AudioPlayerLoader::saveDecodedSamples(QByteArray *samples, int64 *samplesCount) {
t_assert(_savedSamplesCount == 0);
t_assert(_savedSamples.isEmpty());
t_assert(!_holdsSavedSamples);
Assert(_savedSamplesCount == 0);
Assert(_savedSamples.isEmpty());
Assert(!_holdsSavedSamples);
samples->swap(_savedSamples);
std::swap(*samplesCount, _savedSamplesCount);
_holdsSavedSamples = true;
}
void AudioPlayerLoader::takeSavedDecodedSamples(QByteArray *samples, int64 *samplesCount) {
t_assert(*samplesCount == 0);
t_assert(samples->isEmpty());
t_assert(_holdsSavedSamples);
Assert(*samplesCount == 0);
Assert(samples->isEmpty());
Assert(_holdsSavedSamples);
samples->swap(_savedSamples);
std::swap(*samplesCount, _savedSamplesCount);
_holdsSavedSamples = false;

View file

@ -71,7 +71,7 @@ ReaderImplementation::ReadResult QtGifReaderImplementation::readNextFrame() {
}
bool QtGifReaderImplementation::renderFrame(QImage &to, bool &hasAlpha, const QSize &size) {
t_assert(!_frame.isNull());
Assert(!_frame.isNull());
if (size.isEmpty() || size == _frame.size()) {
int32 w = _frame.width(), h = _frame.height();
if (to.width() == w && to.height() == h && to.format() == _frame.format()) {

View file

@ -229,7 +229,7 @@ QPixmap Reader::current(int32 framew, int32 frameh, int32 outerw, int32 outerh,
Expects(outerh > 0);
auto frame = frameToShow();
t_assert(frame != nullptr);
Assert(frame != nullptr);
auto shouldBePaused = !ms;
if (!shouldBePaused) {
@ -281,7 +281,7 @@ QPixmap Reader::current() {
Expects(_mode == Mode::Video);
auto frame = frameToShow();
t_assert(frame != nullptr);
Assert(frame != nullptr);
frame->displayed.storeRelease(1);
moveToNextShow();
@ -473,7 +473,7 @@ public:
}
bool renderFrame() {
t_assert(frame() != 0 && _request.valid());
Assert(frame() != 0 && _request.valid());
if (!_implementation->renderFrame(frame()->original, frame()->alpha, QSize(_request.framew, _request.frameh))) {
return false;
}
@ -699,7 +699,7 @@ bool Manager::handleProcessResult(ReaderPrivate *reader, ProcessResult result, T
if (!reader->_autoPausedGif && reader->_mode == Reader::Mode::Gif && result == ProcessResult::Repaint) {
int32 ishowing, iprevious;
auto showing = it.key()->frameToShow(&ishowing), previous = it.key()->frameToWriteNext(false, &iprevious);
t_assert(previous != nullptr && showing != nullptr && ishowing >= 0 && iprevious >= 0);
Assert(previous != nullptr && showing != nullptr && ishowing >= 0 && iprevious >= 0);
if (reader->_frames[ishowing].when > 0 && showing->displayed.loadAcquire() <= 0) { // current frame was not shown
if (reader->_frames[ishowing].when + WaitBeforeGifPause < ms || (reader->_frames[iprevious].when && previous->displayed.loadAcquire() <= 0)) {
reader->_autoPausedGif = true;
@ -709,7 +709,7 @@ bool Manager::handleProcessResult(ReaderPrivate *reader, ProcessResult result, T
}
}
if (result == ProcessResult::Started || result == ProcessResult::CopyFrame) {
t_assert(reader->_frame >= 0);
Assert(reader->_frame >= 0);
auto frame = it.key()->_frames + reader->_frame;
frame->clear();
frame->pix = reader->frame()->pix;
@ -754,7 +754,7 @@ Manager::ResultHandleState Manager::handleResult(ReaderPrivate *reader, ProcessR
if (frame) {
frame->clear();
} else {
t_assert(!reader->_request.valid());
Assert(!reader->_request.valid());
}
reader->_frame = index;
}

View file

@ -66,16 +66,16 @@ void PlayButtonLayout::paint(Painter &p, const QBrush &brush) {
}
if (backward) progress = 1. - progress;
t_assert(from != to);
Assert(from != to);
if (from == State::Play) {
if (to == State::Pause) {
paintPlayToPause(p, brush, progress);
} else {
t_assert(to == State::Cancel);
Assert(to == State::Cancel);
paintPlayToCancel(p, brush, progress);
}
} else {
t_assert(from == State::Pause && to == State::Cancel);
Assert(from == State::Pause && to == State::Cancel);
paintPauseToCancel(p, brush, progress);
}
} else {

View file

@ -35,11 +35,11 @@ Float::Float(QWidget *parent, HistoryItem *item, base::lambda<void(bool visible)
, _toggleCallback(std::move(toggleCallback))
, _draggedCallback(std::move(draggedCallback)) {
auto media = _item->getMedia();
t_assert(media != nullptr);
Assert(media != nullptr);
auto document = media->getDocument();
t_assert(document != nullptr);
t_assert(document->isRoundVideo());
Assert(document != nullptr);
Assert(document->isRoundVideo());
auto margin = st::mediaPlayerFloatMargin;
auto size = 2 * margin + st::mediaPlayerFloatSize;

View file

@ -1478,7 +1478,7 @@ void MediaView::createClipReader() {
}
void MediaView::initThemePreview() {
t_assert(_doc && _doc->isTheme());
Assert(_doc && _doc->isTheme());
auto &location = _doc->location();
if (!location.isEmpty() && location.accessEnable()) {
@ -1541,7 +1541,7 @@ void MediaView::createClipController() {
}
void MediaView::setClipControllerGeometry() {
t_assert(_clipController != nullptr);
Assert(_clipController != nullptr);
int controllerBottom = _captionRect.isEmpty() ? height() : _captionRect.y();
_clipController->setGeometry(

View file

@ -411,7 +411,7 @@ void Messenger::startMtp() {
if (_authSession) {
_authSession->data().copyFrom(_private->storedAuthSession->data);
if (auto window = App::wnd()) {
t_assert(window->controller() != nullptr);
Assert(window->controller() != nullptr);
window->controller()->dialogsWidthRatio().set(_private->storedAuthSession->dialogsWidthRatio);
}
}
@ -444,7 +444,7 @@ void Messenger::onAllKeysDestroyed() {
}
void Messenger::suggestMainDcId(MTP::DcId mainDcId) {
t_assert(_mtproto != nullptr);
Assert(_mtproto != nullptr);
_mtproto->suggestMainDcId(mainDcId);
if (_private->mtpConfig.mainDcId != MTP::Instance::Config::kNotSetMainDc) {
@ -453,7 +453,7 @@ void Messenger::suggestMainDcId(MTP::DcId mainDcId) {
}
void Messenger::destroyStaleAuthorizationKeys() {
t_assert(_mtproto != nullptr);
Assert(_mtproto != nullptr);
auto keys = _mtproto->getKeysForWrite();
for (auto &key : keys) {
@ -984,7 +984,7 @@ void Messenger::loggedOut() {
QPoint Messenger::getPointForCallPanelCenter() const {
if (auto activeWindow = getActiveWindow()) {
t_assert(activeWindow->windowHandle() != nullptr);
Assert(activeWindow->windowHandle() != nullptr);
if (activeWindow->isActive()) {
return activeWindow->geometry().center();
}

View file

@ -99,7 +99,7 @@ public:
static Messenger *InstancePointer();
static Messenger &Instance() {
auto result = InstancePointer();
t_assert(result != nullptr);
Assert(result != nullptr);
return *result;
}

View file

@ -75,7 +75,7 @@ public:
static void FillData(Data &authKey, base::const_byte_span computedAuthKey) {
auto computedAuthKeySize = computedAuthKey.size();
t_assert(computedAuthKeySize <= kSize);
Assert(computedAuthKeySize <= kSize);
auto authKeyBytes = gsl::make_span(authKey);
if (computedAuthKeySize < kSize) {
base::set_bytes(authKeyBytes.subspan(0, kSize - computedAuthKeySize), gsl::byte());

View file

@ -46,7 +46,7 @@ void ConfigLoader::load() {
_enumDCTimer.callOnce(kEnumerateDcTimeout);
} else {
auto ids = _instance->dcOptions()->configEnumDcIds();
t_assert(!ids.empty());
Assert(!ids.empty());
_enumCurrent = ids.front();
enumerate();
}
@ -89,7 +89,7 @@ void ConfigLoader::enumerate() {
_enumCurrent = _instance->mainDcId();
}
auto ids = _instance->dcOptions()->configEnumDcIds();
t_assert(!ids.empty());
Assert(!ids.empty());
auto i = std::find(ids.cbegin(), ids.cend(), _enumCurrent);
if (i == ids.cend() || (++i) == ids.cend()) {

View file

@ -54,7 +54,7 @@ bool IsGoodModExpFirst(const openssl::BigNum &modexp, const openssl::BigNum &pri
if (diff.isNegative() || diff.bitsSize() < kMinDiffBitsCount || modexp.bitsSize() < kMinDiffBitsCount) {
return false;
}
t_assert(modexp.bytesSize() <= kMaxModExpSize);
Assert(modexp.bytesSize() <= kMaxModExpSize);
return true;
}
@ -2396,7 +2396,7 @@ void ConnectionPrivate::pqAnswered() {
LOG(("AuthKey Error: could not choose public RSA key"));
return restart();
}
t_assert(rsaKey.isValid());
Assert(rsaKey.isValid());
_authKeyData->server_nonce = res_pq_data.vserver_nonce;
_authKeyData->new_nonce = rand_value<MTPint256>();
@ -3036,7 +3036,7 @@ void ConnectionPrivate::unlockKey() {
ConnectionPrivate::~ConnectionPrivate() {
clearAuthKeyData();
t_assert(_finished && _conn == nullptr && _conn4 == nullptr && _conn6 == nullptr);
Assert(_finished && _conn == nullptr && _conn4 == nullptr && _conn6 == nullptr);
}
void ConnectionPrivate::stop() {

View file

@ -232,14 +232,14 @@ void Instance::Private::start(Config &&config) {
if (isKeysDestroyer()) {
for (auto &dc : _dcenters) {
t_assert(!MustNotCreateSessions);
Assert(!MustNotCreateSessions);
auto shiftedDcId = dc.first;
auto session = std::make_unique<internal::Session>(_instance, shiftedDcId);
auto it = _sessions.emplace(shiftedDcId, std::move(session)).first;
it->second->start();
}
} else if (_mainDcId != Config::kNoneMainDc) {
t_assert(!MustNotCreateSessions);
Assert(!MustNotCreateSessions);
auto main = std::make_unique<internal::Session>(_instance, _mainDcId);
_mainSession = main.get();
_sessions.emplace(_mainDcId, std::move(main));
@ -248,7 +248,7 @@ void Instance::Private::start(Config &&config) {
_checkDelayedTimer.setCallback([this] { checkDelayedRequests(); });
t_assert((_mainDcId == Config::kNoneMainDc) == isKeysDestroyer());
Assert((_mainDcId == Config::kNoneMainDc) == isKeysDestroyer());
if (!isKeysDestroyer()) {
requestConfig();
}
@ -324,12 +324,12 @@ void Instance::Private::restart(ShiftedDcId shiftedDcId) {
int32 Instance::Private::dcstate(ShiftedDcId shiftedDcId) {
if (!shiftedDcId) {
t_assert(_mainSession != nullptr);
Assert(_mainSession != nullptr);
return _mainSession->getState();
}
if (!bareDcId(shiftedDcId)) {
t_assert(_mainSession != nullptr);
Assert(_mainSession != nullptr);
shiftedDcId += bareDcId(_mainSession->getDcWithShift());
}
@ -343,11 +343,11 @@ int32 Instance::Private::dcstate(ShiftedDcId shiftedDcId) {
QString Instance::Private::dctransport(ShiftedDcId shiftedDcId) {
if (!shiftedDcId) {
t_assert(_mainSession != nullptr);
Assert(_mainSession != nullptr);
return _mainSession->transport();
}
if (!bareDcId(shiftedDcId)) {
t_assert(_mainSession != nullptr);
Assert(_mainSession != nullptr);
shiftedDcId += bareDcId(_mainSession->getDcWithShift());
}
@ -423,7 +423,7 @@ void Instance::Private::killSession(ShiftedDcId shiftedDcId) {
if (checkIfMainAndKill(shiftedDcId)) {
checkIfMainAndKill(_mainDcId);
t_assert(!MustNotCreateSessions);
Assert(!MustNotCreateSessions);
auto main = std::make_unique<internal::Session>(_instance, _mainDcId);
_mainSession = main.get();
_sessions.emplace(_mainDcId, std::move(main));
@ -549,7 +549,7 @@ void Instance::Private::addKeysForDestroy(AuthKeysList &&keys) {
auto dc = std::make_shared<internal::Dcenter>(_instance, dcId, std::move(key));
_dcenters.emplace(shiftedDcId, std::move(dc));
t_assert(!MustNotCreateSessions);
Assert(!MustNotCreateSessions);
auto session = std::make_unique<internal::Session>(_instance, shiftedDcId);
auto it = _sessions.emplace(shiftedDcId, std::move(session)).first;
it->second->start();
@ -1172,17 +1172,17 @@ bool Instance::Private::onErrorDefault(mtpRequestId requestId, const RPCError &e
internal::Session *Instance::Private::getSession(ShiftedDcId shiftedDcId) {
if (!shiftedDcId) {
t_assert(_mainSession != nullptr);
Assert(_mainSession != nullptr);
return _mainSession;
}
if (!bareDcId(shiftedDcId)) {
t_assert(_mainSession != nullptr);
Assert(_mainSession != nullptr);
shiftedDcId += bareDcId(_mainSession->getDcWithShift());
}
auto it = _sessions.find(shiftedDcId);
if (it == _sessions.cend()) {
t_assert(!MustNotCreateSessions);
Assert(!MustNotCreateSessions);
it = _sessions.emplace(shiftedDcId, std::make_unique<internal::Session>(_instance, shiftedDcId)).first;
it->second->start();
}

View file

@ -552,7 +552,7 @@ void Session::tryToReceive() {
}
Session::~Session() {
t_assert(_connection == nullptr);
Assert(_connection == nullptr);
}
MTPrpcError rpcClientError(const QString &type, const QString &description) {

View file

@ -204,7 +204,7 @@ void SpecialConfigRequest::handleResponse(const QByteArray &bytes) {
if (!decryptSimpleConfig(bytes)) {
return;
}
t_assert(_simpleConfig.type() == mtpc_help_configSimple);
Assert(_simpleConfig.type() == mtpc_help_configSimple);
auto &config = _simpleConfig.c_help_configSimple();
auto now = unixtime();
if (now < config.vdate.v || now > config.vexpires.v) {
@ -216,7 +216,7 @@ void SpecialConfigRequest::handleResponse(const QByteArray &bytes) {
return;
}
for (auto &entry : config.vip_port_list.v) {
t_assert(entry.type() == mtpc_ipPort);
Assert(entry.type() == mtpc_ipPort);
auto &ipPort = entry.c_ipPort();
auto ip = *reinterpret_cast<const uint32*>(&ipPort.vipv4.v);
auto ipString = qsl("%1.%2.%3.%4").arg((ip >> 24) & 0xFF).arg((ip >> 16) & 0xFF).arg((ip >> 8) & 0xFF).arg(ip & 0xFF);

View file

@ -501,7 +501,7 @@ Voice::Voice(DocumentData *voice, HistoryItem *parent, const style::OverviewFile
, _st(st) {
AddComponents(Info::Bit());
t_assert(_data->voice() != 0);
Assert(_data->voice() != 0);
setDocumentLinks(_data);

View file

@ -371,7 +371,7 @@ void Manager::Private::init(Manager *manager) {
// Unity and other Notify OSD users handle desktop notifications
// extremely poor, even without the ability to close() them.
_serverName = LibNotifyServerName;
t_assert(!_serverName.isEmpty());
Assert(!_serverName.isEmpty());
if (_serverName == qstr("notify-osd")) {
// _poorSupported = true;
_actionsSupported = false;

View file

@ -17,6 +17,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#include "platform/mac/specific_mac.h"
#include <cstdlib>
#include "lang/lang_keys.h"
#include "application.h"
#include "mainwidget.h"

View file

@ -207,7 +207,7 @@ void InitOnTopPanel(QWidget *panel) {
panel->createWinId();
auto platformWindow = [reinterpret_cast<NSView*>(panel->winId()) window];
t_assert([platformWindow isKindOfClass:[NSPanel class]]);
Assert([platformWindow isKindOfClass:[NSPanel class]]);
auto platformPanel = static_cast<NSPanel*>(platformWindow);
[platformPanel setLevel:NSPopUpMenuWindowLevel];
@ -220,7 +220,7 @@ void InitOnTopPanel(QWidget *panel) {
void DeInitOnTopPanel(QWidget *panel) {
auto platformWindow = [reinterpret_cast<NSView*>(panel->winId()) window];
t_assert([platformWindow isKindOfClass:[NSPanel class]]);
Assert([platformWindow isKindOfClass:[NSPanel class]]);
auto platformPanel = static_cast<NSPanel*>(platformWindow);
auto newBehavior = ([platformPanel collectionBehavior] & (~NSWindowCollectionBehaviorCanJoinAllSpaces)) | NSWindowCollectionBehaviorMoveToActiveSpace;
@ -229,7 +229,7 @@ void DeInitOnTopPanel(QWidget *panel) {
void ReInitOnTopPanel(QWidget *panel) {
auto platformWindow = [reinterpret_cast<NSView*>(panel->winId()) window];
t_assert([platformWindow isKindOfClass:[NSPanel class]]);
Assert([platformWindow isKindOfClass:[NSPanel class]]);
auto platformPanel = static_cast<NSPanel*>(platformWindow);
auto newBehavior = ([platformPanel collectionBehavior] & (~NSWindowCollectionBehaviorMoveToActiveSpace)) | NSWindowCollectionBehaviorCanJoinAllSpaces;

View file

@ -108,7 +108,7 @@ void GroupMembersWidget::restrictUser(not_null<UserData*> user) {
void GroupMembersWidget::removePeer(PeerData *selectedPeer) {
auto user = selectedPeer->asUser();
t_assert(user != nullptr);
Assert(user != nullptr);
auto text = lng_profile_sure_kick(lt_user, user->firstName);
auto currentRestrictedRights = MTP_channelBannedRights(MTP_flags(0), MTP_int(0));
if (auto channel = peer()->asMegagroup()) {
@ -426,7 +426,7 @@ GroupMembersWidget::Member *GroupMembersWidget::addUser(ChannelData *megagroup,
}
void GroupMembersWidget::fillMegagroupMembers(ChannelData *megagroup) {
t_assert(megagroup->mgInfo != nullptr);
Assert(megagroup->mgInfo != nullptr);
if (megagroup->mgInfo->lastParticipants.isEmpty()) return;
if (!megagroup->canViewMembers()) {
@ -486,7 +486,7 @@ void GroupMembersWidget::setItemFlags(Item *item, ChannelData *megagroup) {
if (item->adminState != adminState) {
item->adminState = adminState;
auto user = item->peer->asUser();
t_assert(user != nullptr);
Assert(user != nullptr);
if (user->botInfo) {
// Update "has access to messages" status.
item->statusText = QString();

View file

@ -151,7 +151,7 @@ void SharedMediaWidget::onMediaChosen() {
}
void SharedMediaWidget::resizeButtons(int newWidth, int *top) {
t_assert(top != nullptr);
Assert(top != nullptr);
int left = defaultOutlineButtonLeft();
int availableWidth = newWidth - left - st::profileBlockMarginRight;

View file

@ -135,7 +135,7 @@ void FixedBar::addRightAction(RightActionType type, base::lambda<QString()> text
return;
}
} else {
t_assert(_rightActions.size() == _currentAction);
Assert(_rightActions.size() == _currentAction);
_rightActions.push_back(RightAction());
}
_rightActions[_currentAction].type = type;

View file

@ -189,7 +189,7 @@ int InfoWidget::LabeledWidget::resizeGetHeight(int newWidth) {
_label->moveToLeft(0, st::settingsBlockOneLineTextPart.margin.top(), newWidth);
auto labelNatural = _label->naturalWidth();
t_assert(labelNatural >= 0);
Assert(labelNatural >= 0);
_label->resize(qMin(newWidth, labelNatural), _label->height());

View file

@ -135,7 +135,7 @@ void destroyShortcut(QShortcut *shortcut);
struct DataStruct {
DataStruct() {
t_assert(DataPtr == nullptr);
Assert(DataPtr == nullptr);
DataPtr = this;
if (autoRepeatCommands.isEmpty()) {
@ -214,16 +214,16 @@ struct DataStruct {
namespace {
void createCommand(const QString &command, ShortcutCommands::Handler handler) {
t_assert(DataPtr != nullptr);
t_assert(!command.isEmpty());
Assert(DataPtr != nullptr);
Assert(!command.isEmpty());
DataPtr->commands.insert(command, handler);
DataPtr->commandnames.insert(handler, command);
}
QKeySequence setShortcut(const QString &keys, const QString &command) {
t_assert(DataPtr != nullptr);
t_assert(!command.isEmpty());
Assert(DataPtr != nullptr);
Assert(!command.isEmpty());
if (keys.isEmpty()) return QKeySequence();
QKeySequence seq(keys, QKeySequence::PortableText);
@ -265,7 +265,7 @@ QKeySequence setShortcut(const QString &keys, const QString &command) {
}
QKeySequence removeShortcut(const QString &keys) {
t_assert(DataPtr != nullptr);
Assert(DataPtr != nullptr);
if (keys.isEmpty()) return QKeySequence();
QKeySequence seq(keys, QKeySequence::PortableText);
@ -283,7 +283,7 @@ QKeySequence removeShortcut(const QString &keys) {
}
void destroyShortcut(QShortcut *shortcut) {
t_assert(DataPtr != nullptr);
Assert(DataPtr != nullptr);
DataPtr->handlers.remove(shortcut->id());
DataPtr->mediaShortcuts.remove(shortcut);
@ -293,7 +293,7 @@ void destroyShortcut(QShortcut *shortcut) {
} // namespace
void start() {
t_assert(Global::started());
Assert(Global::started());
new DataStruct();
@ -411,12 +411,12 @@ void start() {
}
const QStringList &errors() {
t_assert(DataPtr != nullptr);
Assert(DataPtr != nullptr);
return DataPtr->errors;
}
bool launch(int shortcutId) {
t_assert(DataPtr != nullptr);
Assert(DataPtr != nullptr);
auto it = DataPtr->handlers.constFind(shortcutId);
if (it == DataPtr->handlers.cend()) {
@ -426,7 +426,7 @@ bool launch(int shortcutId) {
}
bool launch(const QString &command) {
t_assert(DataPtr != nullptr);
Assert(DataPtr != nullptr);
auto it = DataPtr->commands.constFind(command);
if (it == DataPtr->commands.cend()) {

View file

@ -62,6 +62,13 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include <map>
#include <algorithm>
#include <memory>
// Ensures/Expects.
#include <gsl/gsl_assert>
// Redefine Ensures/Expects by our own assertions.
#include "base/assertion.h"
#include <gsl/gsl>
#include "base/variant.h"

View file

@ -485,13 +485,13 @@ void mtpFileLoader::makeRequest(int offset) {
auto limit = partSize();
auto shiftedDcId = MTP::downloadDcId(requestData.dcId, requestData.dcIndex);
if (_cdnDcId) {
t_assert(requestData.dcId == _cdnDcId);
Assert(requestData.dcId == _cdnDcId);
return MTP::send(MTPupload_GetCdnFile(MTP_bytes(_cdnToken), MTP_int(offset), MTP_int(limit)), rpcDone(&mtpFileLoader::cdnPartLoaded), rpcFail(&mtpFileLoader::cdnPartFailed), shiftedDcId, 50);
} else if (_urlLocation) {
t_assert(requestData.dcId == _dcId);
Assert(requestData.dcId == _dcId);
return MTP::send(MTPupload_GetWebFile(MTP_inputWebFileLocation(MTP_bytes(_urlLocation->url()), MTP_long(_urlLocation->accessHash())), MTP_int(offset), MTP_int(limit)), rpcDone(&mtpFileLoader::webPartLoaded), rpcFail(&mtpFileLoader::partFailed), shiftedDcId, 50);
} else {
t_assert(requestData.dcId == _dcId);
Assert(requestData.dcId == _dcId);
auto location = [this] {
if (_location) {
return MTP_inputFileLocation(MTP_long(_location->volume()), MTP_int(_location->local()), MTP_long(_location->secret()));
@ -806,7 +806,7 @@ void mtpFileLoader::switchToCDN(int offset, const MTPDupload_fileCdnRedirect &re
void mtpFileLoader::addCdnHashes(const QVector<MTPCdnFileHash> &hashes) {
for_const (auto &hash, hashes) {
t_assert(hash.type() == mtpc_cdnFileHash);
Assert(hash.type() == mtpc_cdnFileHash);
auto &data = hash.c_cdnFileHash();
_cdnFileHashes.emplace(data.voffset.v, CdnFileHash { data.vlimit.v, data.vhash.v });
}

View file

@ -343,7 +343,7 @@ void FileLoadTask::process() {
// Voice sending is supported only from memory for now.
// Because for voice we force mime type and don't read MediaInformation.
// For a real file we always read mime type and read MediaInformation.
t_assert(!isVoice);
Assert(!isVoice);
filesize = info.size();
filename = info.fileName();

View file

@ -2194,6 +2194,6 @@ GameData::GameData(const GameId &id, const uint64 &accessHash, const QString &sh
MsgId clientMsgId() {
static MsgId currentClientMsgId = StartClientMsgId;
t_assert(currentClientMsgId < EndClientMsgId);
Assert(currentClientMsgId < EndClientMsgId);
return currentClientMsgId++;
}

View file

@ -616,7 +616,7 @@ public:
}
float64 current() const {
t_assert(_data != nullptr);
Assert(_data != nullptr);
return _data->value.current();
}
float64 current(float64 def) const {

View file

@ -23,7 +23,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
namespace Ui {
void RoundShadowAnimation::start(int frameWidth, int frameHeight, float64 devicePixelRatio) {
t_assert(!started());
Assert(!started());
_frameWidth = frameWidth;
_frameHeight = frameHeight;
_frame = QImage(_frameWidth, _frameHeight, QImage::Format_ARGB32_Premultiplied);
@ -31,9 +31,9 @@ void RoundShadowAnimation::start(int frameWidth, int frameHeight, float64 device
_frameIntsPerLine = (_frame.bytesPerLine() >> 2);
_frameInts = reinterpret_cast<uint32*>(_frame.bits());
_frameIntsPerLineAdded = _frameIntsPerLine - _frameWidth;
t_assert(_frame.depth() == static_cast<int>(sizeof(uint32) << 3));
t_assert(_frame.bytesPerLine() == (_frameIntsPerLine << 2));
t_assert(_frameIntsPerLineAdded >= 0);
Assert(_frame.depth() == static_cast<int>(sizeof(uint32) << 3));
Assert(_frame.bytesPerLine() == (_frameIntsPerLine << 2));
Assert(_frameIntsPerLineAdded >= 0);
}
void RoundShadowAnimation::setShadow(const style::Shadow &st) {
@ -47,7 +47,7 @@ void RoundShadowAnimation::setShadow(const style::Shadow &st) {
_shadow.bottomRight = cloneImage(st.bottomRight);
_shadow.bottom = cloneImage(st.bottom);
_shadow.bottomLeft = cloneImage(st.bottomLeft);
t_assert(!_shadow.topLeft.isNull()
Assert(!_shadow.topLeft.isNull()
&& !_shadow.top.isNull()
&& !_shadow.topRight.isNull()
&& !_shadow.right.isNull()
@ -73,7 +73,7 @@ void RoundShadowAnimation::setCornerMasks(const QImage &topLeft, const QImage &t
}
void RoundShadowAnimation::setCornerMask(Corner &corner, const QImage &image) {
t_assert(!started());
Assert(!started());
corner.image = image;
if (corner.valid()) {
corner.width = corner.image.width();
@ -81,8 +81,8 @@ void RoundShadowAnimation::setCornerMask(Corner &corner, const QImage &image) {
corner.bytes = corner.image.constBits();
corner.bytesPerPixel = (corner.image.depth() >> 3);
corner.bytesPerLineAdded = corner.image.bytesPerLine() - corner.width * corner.bytesPerPixel;
t_assert(corner.image.depth() == (corner.bytesPerPixel << 3));
t_assert(corner.bytesPerLineAdded >= 0);
Assert(corner.image.depth() == (corner.bytesPerPixel << 3));
Assert(corner.bytesPerLineAdded >= 0);
} else {
corner.width = corner.height = 0;
}
@ -227,25 +227,25 @@ void RoundShadowAnimation::paintShadowHorizontal(int left, int right, int top, c
}
void PanelAnimation::setFinalImage(QImage &&finalImage, QRect inner) {
t_assert(!started());
Assert(!started());
_finalImage = App::pixmapFromImageInPlace(std::move(finalImage).convertToFormat(QImage::Format_ARGB32_Premultiplied));
t_assert(!_finalImage.isNull());
Assert(!_finalImage.isNull());
_finalWidth = _finalImage.width();
_finalHeight = _finalImage.height();
t_assert(!(_finalWidth % cIntRetinaFactor()));
t_assert(!(_finalHeight % cIntRetinaFactor()));
Assert(!(_finalWidth % cIntRetinaFactor()));
Assert(!(_finalHeight % cIntRetinaFactor()));
_finalInnerLeft = inner.x();
_finalInnerTop = inner.y();
_finalInnerWidth = inner.width();
_finalInnerHeight = inner.height();
t_assert(!(_finalInnerLeft % cIntRetinaFactor()));
t_assert(!(_finalInnerTop % cIntRetinaFactor()));
t_assert(!(_finalInnerWidth % cIntRetinaFactor()));
t_assert(!(_finalInnerHeight % cIntRetinaFactor()));
Assert(!(_finalInnerLeft % cIntRetinaFactor()));
Assert(!(_finalInnerTop % cIntRetinaFactor()));
Assert(!(_finalInnerWidth % cIntRetinaFactor()));
Assert(!(_finalInnerHeight % cIntRetinaFactor()));
_finalInnerRight = _finalInnerLeft + _finalInnerWidth;
_finalInnerBottom = _finalInnerTop + _finalInnerHeight;
t_assert(QRect(0, 0, _finalWidth, _finalHeight).contains(inner));
Assert(QRect(0, 0, _finalWidth, _finalHeight).contains(inner));
setStartWidth();
setStartHeight();
@ -263,8 +263,8 @@ void PanelAnimation::setFinalImage(QImage &&finalImage, QRect inner) {
if (!corner.valid()) return;
if ((_startWidth >= 0 && _startWidth < _finalWidth)
|| (_startHeight >= 0 && _startHeight < _finalHeight)) {
t_assert(corner.width <= inner.width());
t_assert(corner.height <= inner.height());
Assert(corner.width <= inner.width());
Assert(corner.height <= inner.height());
}
};
checkCorner(_topLeft);
@ -275,17 +275,17 @@ void PanelAnimation::setFinalImage(QImage &&finalImage, QRect inner) {
void PanelAnimation::setStartWidth() {
_startWidth = qRound(_st.startWidth * _finalInnerWidth);
if (_startWidth >= 0) t_assert(_startWidth <= _finalInnerWidth);
if (_startWidth >= 0) Assert(_startWidth <= _finalInnerWidth);
}
void PanelAnimation::setStartHeight() {
_startHeight = qRound(_st.startHeight * _finalInnerHeight);
if (_startHeight >= 0) t_assert(_startHeight <= _finalInnerHeight);
if (_startHeight >= 0) Assert(_startHeight <= _finalInnerHeight);
}
void PanelAnimation::setStartAlpha() {
_startAlpha = qRound(_st.startOpacity * 255);
t_assert(_startAlpha >= 0 && _startAlpha < 256);
Assert(_startAlpha >= 0 && _startAlpha < 256);
}
void PanelAnimation::setStartFadeTop() {
@ -298,7 +298,7 @@ void PanelAnimation::createFadeMask() {
resultHeight -= remove;
}
auto finalAlpha = qRound(_st.fadeOpacity * 255);
t_assert(finalAlpha >= 0 && finalAlpha < 256);
Assert(finalAlpha >= 0 && finalAlpha < 256);
auto result = QImage(cIntRetinaFactor(), resultHeight, QImage::Format_ARGB32_Premultiplied);
auto ints = reinterpret_cast<uint32*>(result.bits());
auto intsPerLineAdded = (result.bytesPerLine() >> 2) - cIntRetinaFactor();
@ -321,39 +321,39 @@ void PanelAnimation::createFadeMask() {
}
void PanelAnimation::setSkipShadow(bool skipShadow) {
t_assert(!started());
Assert(!started());
_skipShadow = skipShadow;
}
void PanelAnimation::setWidthDuration() {
_widthDuration = _st.widthDuration;
t_assert(_widthDuration >= 0.);
t_assert(_widthDuration <= 1.);
Assert(_widthDuration >= 0.);
Assert(_widthDuration <= 1.);
}
void PanelAnimation::setHeightDuration() {
t_assert(!started());
Assert(!started());
_heightDuration = _st.heightDuration;
t_assert(_heightDuration >= 0.);
t_assert(_heightDuration <= 1.);
Assert(_heightDuration >= 0.);
Assert(_heightDuration <= 1.);
}
void PanelAnimation::setAlphaDuration() {
t_assert(!started());
Assert(!started());
_alphaDuration = _st.opacityDuration;
t_assert(_alphaDuration >= 0.);
t_assert(_alphaDuration <= 1.);
Assert(_alphaDuration >= 0.);
Assert(_alphaDuration <= 1.);
}
void PanelAnimation::start() {
t_assert(!_finalImage.isNull());
Assert(!_finalImage.isNull());
RoundShadowAnimation::start(_finalWidth, _finalHeight, _finalImage.devicePixelRatio());
auto checkCorner = [this](const Corner &corner) {
if (!corner.valid()) return;
if (_startWidth >= 0) t_assert(corner.width <= _startWidth);
if (_startHeight >= 0) t_assert(corner.height <= _startHeight);
t_assert(corner.width <= _finalInnerWidth);
t_assert(corner.height <= _finalInnerHeight);
if (_startWidth >= 0) Assert(corner.width <= _startWidth);
if (_startHeight >= 0) Assert(corner.height <= _startHeight);
Assert(corner.width <= _finalInnerWidth);
Assert(corner.height <= _finalInnerHeight);
};
checkCorner(_topLeft);
checkCorner(_topRight);
@ -362,8 +362,8 @@ void PanelAnimation::start() {
}
void PanelAnimation::paintFrame(QPainter &p, int x, int y, int outerWidth, float64 dt, float64 opacity) {
t_assert(started());
t_assert(dt >= 0.);
Assert(started());
Assert(dt >= 0.);
auto &transition = anim::easeOutCirc;
if (dt < _alphaDuration) opacity *= transition(1., dt / _alphaDuration);

View file

@ -25,8 +25,8 @@ namespace Ui {
void SlideAnimation::setSnapshots(QPixmap leftSnapshot, QPixmap rightSnapshot) {
_leftSnapshot = std::move(leftSnapshot);
_rightSnapshot = std::move(rightSnapshot);
t_assert(!_leftSnapshot.isNull());
t_assert(!_rightSnapshot.isNull());
Assert(!_leftSnapshot.isNull());
Assert(!_rightSnapshot.isNull());
_leftSnapshot.setDevicePixelRatio(cRetinaFactor());
_rightSnapshot.setDevicePixelRatio(cRetinaFactor());
}

View file

@ -33,7 +33,7 @@ FORCE_INLINE uint64 blurGetColors(const uchar *p) {
}
const QPixmap &circleMask(int width, int height) {
t_assert(Global::started());
Assert(Global::started());
uint64 key = uint64(uint32(width)) << 32 | uint64(uint32(height));
@ -65,7 +65,7 @@ QImage prepareBlur(QImage img) {
if (fmt != QImage::Format_RGB32 && fmt != QImage::Format_ARGB32_Premultiplied) {
img = img.convertToFormat(QImage::Format_ARGB32_Premultiplied);
img.setDevicePixelRatio(ratio);
t_assert(!img.isNull());
Assert(!img.isNull());
}
uchar *pix = img.bits();
@ -91,7 +91,7 @@ QImage prepareBlur(QImage img) {
auto was = img;
img = std::move(imgsmall);
imgsmall = QImage();
t_assert(!img.isNull());
Assert(!img.isNull());
pix = img.bits();
if (!pix) return was;
@ -179,11 +179,11 @@ yi += stride;
}
void prepareCircle(QImage &img) {
t_assert(!img.isNull());
Assert(!img.isNull());
img.setDevicePixelRatio(cRetinaFactor());
img = img.convertToFormat(QImage::Format_ARGB32_Premultiplied);
t_assert(!img.isNull());
Assert(!img.isNull());
QPixmap mask = circleMask(img.width(), img.height());
Painter p(&img);
@ -195,14 +195,14 @@ void prepareRound(QImage &image, ImageRoundRadius radius, ImageRoundCorners corn
if (!static_cast<int>(corners)) {
return;
} else if (radius == ImageRoundRadius::Ellipse) {
t_assert(corners == ImageRoundCorners(ImageRoundCorner::All));
Assert(corners == ImageRoundCorners(ImageRoundCorner::All));
prepareCircle(image);
}
t_assert(!image.isNull());
Assert(!image.isNull());
image.setDevicePixelRatio(cRetinaFactor());
image = std::move(image).convertToFormat(QImage::Format_ARGB32_Premultiplied);
t_assert(!image.isNull());
Assert(!image.isNull());
auto masks = App::cornersMask(radius);
prepareRound(image, masks, corners);
@ -218,8 +218,8 @@ void prepareRound(QImage &image, QImage *cornerMasks, ImageRoundCorners corners)
}
constexpr auto imageIntsPerPixel = 1;
auto imageIntsPerLine = (image.bytesPerLine() >> 2);
t_assert(image.depth() == static_cast<int>((imageIntsPerPixel * sizeof(uint32)) << 3));
t_assert(image.bytesPerLine() == (imageIntsPerLine << 2));
Assert(image.depth() == static_cast<int>((imageIntsPerPixel * sizeof(uint32)) << 3));
Assert(image.bytesPerLine() == (imageIntsPerLine << 2));
auto ints = reinterpret_cast<uint32*>(image.bits());
auto intsTopLeft = ints;
@ -233,10 +233,10 @@ void prepareRound(QImage &image, QImage *cornerMasks, ImageRoundCorners corners)
auto maskBytesPerLine = mask.bytesPerLine();
auto maskBytesAdded = maskBytesPerLine - maskWidth * maskBytesPerPixel;
auto maskBytes = mask.constBits();
t_assert(maskBytesAdded >= 0);
t_assert(mask.depth() == (maskBytesPerPixel << 3));
Assert(maskBytesAdded >= 0);
Assert(mask.depth() == (maskBytesPerPixel << 3));
auto imageIntsAdded = imageIntsPerLine - maskWidth * imageIntsPerPixel;
t_assert(imageIntsAdded >= 0);
Assert(imageIntsAdded >= 0);
for (auto y = 0; y != maskHeight; ++y) {
for (auto x = 0; x != maskWidth; ++x) {
auto opacity = static_cast<anim::ShiftedMultiplier>(*maskBytes) + 1;
@ -294,18 +294,18 @@ QImage prepareOpaque(QImage image) {
}
QImage prepare(QImage img, int w, int h, Images::Options options, int outerw, int outerh, const style::color *colored) {
t_assert(!img.isNull());
Assert(!img.isNull());
if (options.testFlag(Images::Option::Blurred)) {
img = prepareBlur(std::move(img));
t_assert(!img.isNull());
Assert(!img.isNull());
}
if (w <= 0 || (w == img.width() && (h <= 0 || h == img.height()))) {
} else if (h <= 0) {
img = img.scaledToWidth(w, options.testFlag(Images::Option::Smooth) ? Qt::SmoothTransformation : Qt::FastTransformation);
t_assert(!img.isNull());
Assert(!img.isNull());
} else {
img = img.scaled(w, h, Qt::IgnoreAspectRatio, options.testFlag(Images::Option::Smooth) ? Qt::SmoothTransformation : Qt::FastTransformation);
t_assert(!img.isNull());
Assert(!img.isNull());
}
if (outerw > 0 && outerh > 0) {
outerw *= cIntRetinaFactor();
@ -325,7 +325,7 @@ QImage prepare(QImage img, int w, int h, Images::Options options, int outerw, in
p.drawImage((result.width() - img.width()) / (2 * cIntRetinaFactor()), (result.height() - img.height()) / (2 * cIntRetinaFactor()), img);
}
img = result;
t_assert(!img.isNull());
Assert(!img.isNull());
}
}
auto corners = [](Images::Options options) {
@ -336,16 +336,16 @@ QImage prepare(QImage img, int w, int h, Images::Options options, int outerw, in
};
if (options.testFlag(Images::Option::Circled)) {
prepareCircle(img);
t_assert(!img.isNull());
Assert(!img.isNull());
} else if (options.testFlag(Images::Option::RoundedLarge)) {
prepareRound(img, ImageRoundRadius::Large, corners(options));
t_assert(!img.isNull());
Assert(!img.isNull());
} else if (options.testFlag(Images::Option::RoundedSmall)) {
prepareRound(img, ImageRoundRadius::Small, corners(options));
t_assert(!img.isNull());
Assert(!img.isNull());
}
if (options.testFlag(Images::Option::Colored)) {
t_assert(colored != nullptr);
Assert(colored != nullptr);
img = prepareColored(*colored, std::move(img));
}
img.setDevicePixelRatio(cRetinaFactor());
@ -742,7 +742,7 @@ QPixmap Image::pixNoCache(int w, int h, Images::Options options, int outerw, int
Images::prepareRound(result, ImageRoundRadius::Small, corners(options));
}
if (options.testFlag(Images::Option::Colored)) {
t_assert(colored != nullptr);
Assert(colored != nullptr);
result = Images::prepareColored(*colored, std::move(result));
}
return App::pixmapFromImageInPlace(std::move(result));

View file

@ -78,11 +78,11 @@ void colorizeImage(const QImage &src, QColor c, QImage *outResult, QRect srcRect
if (srcRect.isNull()) {
srcRect = src.rect();
} else {
t_assert(src.rect().contains(srcRect));
Assert(src.rect().contains(srcRect));
}
auto width = srcRect.width();
auto height = srcRect.height();
t_assert(outResult && outResult->rect().contains(QRect(dstPoint, srcRect.size())));
Assert(outResult && outResult->rect().contains(QRect(dstPoint, srcRect.size())));
auto pattern = anim::shifted(c);
@ -91,16 +91,16 @@ void colorizeImage(const QImage &src, QColor c, QImage *outResult, QRect srcRect
auto resultIntsPerLine = (outResult->bytesPerLine() >> 2);
auto resultIntsAdded = resultIntsPerLine - width * resultIntsPerPixel;
auto resultInts = reinterpret_cast<uint32*>(outResult->bits()) + dstPoint.y() * resultIntsPerLine + dstPoint.x() * resultIntsPerPixel;
t_assert(resultIntsAdded >= 0);
t_assert(outResult->depth() == static_cast<int>((resultIntsPerPixel * sizeof(uint32)) << 3));
t_assert(outResult->bytesPerLine() == (resultIntsPerLine << 2));
Assert(resultIntsAdded >= 0);
Assert(outResult->depth() == static_cast<int>((resultIntsPerPixel * sizeof(uint32)) << 3));
Assert(outResult->bytesPerLine() == (resultIntsPerLine << 2));
auto maskBytesPerPixel = (src.depth() >> 3);
auto maskBytesPerLine = src.bytesPerLine();
auto maskBytesAdded = maskBytesPerLine - width * maskBytesPerPixel;
auto maskBytes = src.constBits() + srcRect.y() * maskBytesPerLine + srcRect.x() * maskBytesPerPixel;
t_assert(maskBytesAdded >= 0);
t_assert(src.depth() == (maskBytesPerPixel << 3));
Assert(maskBytesAdded >= 0);
Assert(src.depth() == (maskBytesPerPixel << 3));
for (int y = 0; y != height; ++y) {
for (int x = 0; x != width; ++x) {
auto maskOpacity = static_cast<anim::ShiftedMultiplier>(*maskBytes) + 1;

View file

@ -45,7 +45,7 @@ inline int pxAdjust(int value, int scale) {
QImage createIconMask(const IconMask *mask, DBIScale scale) {
auto maskImage = QImage::fromData(mask->data(), mask->size(), "PNG");
maskImage.setDevicePixelRatio(cRetinaFactor());
t_assert(!maskImage.isNull());
Assert(!maskImage.isNull());
// images are layouted like this:
// 200x 100x
@ -89,7 +89,7 @@ QSize readGeneratedSize(const IconMask *mask, DBIScale scale) {
qint32 width = 0, height = 0;
stream >> width >> height;
t_assert(stream.status() == QDataStream::Ok);
Assert(stream.status() == QDataStream::Ok);
switch (scale) {
case dbisOne: return QSize(width, height);
@ -284,8 +284,8 @@ void IconData::fill(QPainter &p, const QRect &rect) const {
auto partSize = _parts[0].size();
for_const (auto &part, _parts) {
t_assert(part.offset() == QPoint(0, 0));
t_assert(part.size() == partSize);
Assert(part.offset() == QPoint(0, 0));
Assert(part.size() == partSize);
part.fill(p, rect);
}
}
@ -295,16 +295,16 @@ void IconData::fill(QPainter &p, const QRect &rect, QColor colorOverride) const
auto partSize = _parts[0].size();
for_const (auto &part, _parts) {
t_assert(part.offset() == QPoint(0, 0));
t_assert(part.size() == partSize);
Assert(part.offset() == QPoint(0, 0));
Assert(part.size() == partSize);
part.fill(p, rect, colorOverride);
}
}
QImage IconData::instance(QColor colorOverride, DBIScale scale) const {
t_assert(_parts.size() == 1);
Assert(_parts.size() == 1);
auto &part = _parts[0];
t_assert(part.offset() == QPoint(0, 0));
Assert(part.offset() == QPoint(0, 0));
return part.instance(colorOverride, scale);
}

View file

@ -166,13 +166,13 @@ public:
Icon(Icon &&other) : _data(base::take(other._data)), _owner(base::take(_owner)) {
}
Icon &operator=(const Icon &other) {
t_assert(!_owner);
Assert(!_owner);
_data = other._data;
_owner = false;
return *this;
}
Icon &operator=(Icon &&other) {
t_assert(!_owner);
Assert(!_owner);
_data = base::take(other._data);
_owner = base::take(other._owner);
return *this;

View file

@ -686,7 +686,7 @@ bool CrossButton::stopLoadingAnimation(TimeMs ms) {
auto stopPeriod = (_loadingStopMs - _loadingStartMs) / _st.loadingPeriod;
auto currentPeriod = (ms - _loadingStartMs) / _st.loadingPeriod;
if (currentPeriod != stopPeriod) {
t_assert(currentPeriod > stopPeriod);
Assert(currentPeriod > stopPeriod);
return true;
}
return false;

View file

@ -113,8 +113,8 @@ void ToggleView::paint(Painter &p, int left, int top, int outerWidth, TimeMs ms)
}
void ToggleView::paintXV(Painter &p, int left, int top, int outerWidth, float64 toggled, const QBrush &brush) {
t_assert(_st->vsize > 0);
t_assert(_st->stroke > 0);
Assert(_st->vsize > 0);
Assert(_st->stroke > 0);
static const auto sqrt2 = sqrt(2.);
auto stroke = (0. + _st->stroke) / sqrt2;
if (toggled < 1) {

View file

@ -76,7 +76,7 @@ void DiscreteSlider::addSection(const QString &label) {
}
void DiscreteSlider::setSections(const QStringList &labels) {
t_assert(!labels.isEmpty());
Assert(!labels.isEmpty());
_sections.clear();
for_const (auto &label, labels) {

Some files were not shown because too many files have changed in this diff Show more