From 44c46336847a8d8ece3fb00301875af58ca69bf4 Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Sat, 8 Feb 2020 22:26:19 +0200 Subject: [PATCH 1/3] Fix memleak when Icon move ctor is used --- ui/style/style_core_icon.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/style/style_core_icon.h b/ui/style/style_core_icon.h index 045d12a..f5c3f59 100644 --- a/ui/style/style_core_icon.h +++ b/ui/style/style_core_icon.h @@ -153,7 +153,7 @@ public: } Icon(const Icon &other) : _data(other._data) { } - Icon(Icon &&other) : _data(base::take(other._data)), _owner(base::take(_owner)) { + Icon(Icon &&other) : _data(base::take(other._data)), _owner(base::take(other._owner)) { } Icon &operator=(const Icon &other) { Expects(!_owner); From be5ed0053adddfa70a739bf19b8d84e540e7e0f8 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 5 Feb 2020 13:52:48 +0300 Subject: [PATCH 2/3] Removed emoji sets from lib_ui. --- ui/emoji_config.cpp | 11 ----------- ui/emoji_config.h | 9 --------- 2 files changed, 20 deletions(-) diff --git a/ui/emoji_config.cpp b/ui/emoji_config.cpp index 47f76d6..ac96452 100644 --- a/ui/emoji_config.cpp +++ b/ui/emoji_config.cpp @@ -37,13 +37,6 @@ constexpr auto kMaxId = uint32(1 << 8); constexpr auto kScaleForTouchBar = 150; -const auto kSets = { - Set{ 0, 0, 0, "Mac", ":/gui/emoji/set0_preview.webp" }, - Set{ 1, 246, 7'336'383, "Android", ":/gui/emoji/set1_preview.webp" }, - Set{ 2, 206, 5'038'738, "Twemoji", ":/gui/emoji/set2_preview.webp" }, - Set{ 3, 238, 6'992'260, "JoyPixels", ":/gui/emoji/set3_preview.webp" }, -}; - // Right now we can't allow users of Ui::Emoji to create custom sizes. // Any Instance::Instance() can invalidate Universal.id() and sprites. // So all Instance::Instance() should happen before async generations. @@ -527,10 +520,6 @@ void ClearIrrelevantCache() { }); } -std::vector Sets() { - return kSets | ranges::to_vector; -} - int CurrentSetId() { Expects(Universal != nullptr); diff --git a/ui/emoji_config.h b/ui/emoji_config.h index 9256150..e8a8eba 100644 --- a/ui/emoji_config.h +++ b/ui/emoji_config.h @@ -29,18 +29,9 @@ void Clear(); void ClearIrrelevantCache(); -struct Set { - int id = 0; - int postId = 0; - int size = 0; - QString name; - QString previewPath; -}; - // Thread safe, callback is called on main thread. void SwitchToSet(int id, Fn callback); -std::vector Sets(); int CurrentSetId(); bool SetIsReady(int id); rpl::producer<> Updated(); From ccc12ce3da8f9ac30f30228c225585f732f74d5f Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 25 Feb 2020 13:17:00 +0400 Subject: [PATCH 3/3] Fix crash in rounding of shared images. Regression was introduced in 721d143c89. --- ui/image/image_prepare.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ui/image/image_prepare.cpp b/ui/image/image_prepare.cpp index 176e307..c774456 100644 --- a/ui/image/image_prepare.cpp +++ b/ui/image/image_prepare.cpp @@ -463,12 +463,17 @@ void prepareRound( if (imageWidth < 2 * cornerWidth || imageHeight < 2 * cornerHeight) { return; } + + // We need to detach image first (if it is shared), before we + // count some offsets using QImage::bytesPerLine etc, because + // bytesPerLine may change on detach, this leads to crashes: + // Real image bytesPerLine is smaller than the one we use for offsets. + auto ints = reinterpret_cast(image.bits()); + constexpr auto imageIntsPerPixel = 1; auto imageIntsPerLine = (image.bytesPerLine() >> 2); Assert(image.depth() == static_cast((imageIntsPerPixel * sizeof(uint32)) << 3)); Assert(image.bytesPerLine() == (imageIntsPerLine << 2)); - - auto ints = reinterpret_cast(image.bits()); auto intsTopLeft = ints + target.x() + target.y() * imageIntsPerLine; auto intsTopRight = ints + target.x() + target.width() - cornerWidth + target.y() * imageIntsPerLine; auto intsBottomLeft = ints + target.x() + (target.y() + target.height() - cornerHeight) * imageIntsPerLine;