From d864a8d8eb125579f2bb5f545606ff7880b9042a Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 1 Sep 2016 21:12:04 -0400 Subject: [PATCH 1/2] Fixed crash in Observers (removing an observer inside notify call). --- Telegram/SourceFiles/core/observer.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/core/observer.h b/Telegram/SourceFiles/core/observer.h index 42cc3b221..452a0ef83 100644 --- a/Telegram/SourceFiles/core/observer.h +++ b/Telegram/SourceFiles/core/observer.h @@ -103,7 +103,12 @@ public: void notify(Flags flags, Args&&... args) { t_assert(started()); - for (auto &entry : _list->entries) { + auto &entries = _list->entries; + // This way of iterating (i < entries.size() should be used + // because some entries can be removed from the end of the + // entries list while the loop is still running. + for (int i = 0; i < entries.size(); ++i) { + auto &entry = entries[i]; if (!entry.handler.isNull() && (flags & entry.flags)) { entry.handler.call(std_::forward(args)...); } @@ -131,7 +136,7 @@ private: t_assert(that->started()); - auto &entries(that->_list->entries); + auto &entries = that->_list->entries; if (entries.size() <= connectionIndex) return; if (entries.size() == connectionIndex + 1) { From 659551e4398869afc5f9638d9a649f4c0bc0fb1b Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 2 Sep 2016 00:03:36 -0400 Subject: [PATCH 2/2] Fixed sprite generation for 125% and 150% interface scales. --- Telegram/SourceFiles/codegen/style/structure_types.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/codegen/style/structure_types.h b/Telegram/SourceFiles/codegen/style/structure_types.h index b25fc6fd0..131706b33 100644 --- a/Telegram/SourceFiles/codegen/style/structure_types.h +++ b/Telegram/SourceFiles/codegen/style/structure_types.h @@ -75,7 +75,10 @@ inline bool operator!=(const Type &a, const Type &b) { namespace data { inline int pxAdjust(int value, int scale) { - return qRound((value * scale / 4.) + (value > 0 ? -0.01 : 0.01)); + if (value < 0) { + return -pxAdjust(-value, scale); + } + return static_cast(std::floor((value * scale / 4.) + 0.1)); } struct point {