From b4b9e2089fc53e2d4f81b0762345251fca238dae Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 2 Aug 2020 17:42:44 +0200 Subject: [PATCH] libicon: reorder gradient stops when loading from BMessage Some files have gradients stops stored in an incorrect order. Fixes #14210 --- src/libs/icon/style/GradientTransformable.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libs/icon/style/GradientTransformable.cpp b/src/libs/icon/style/GradientTransformable.cpp index 2bfc42dfa0..c84aab7de4 100644 --- a/src/libs/icon/style/GradientTransformable.cpp +++ b/src/libs/icon/style/GradientTransformable.cpp @@ -70,9 +70,11 @@ Gradient::Gradient(BMessage* archive) // color steps BGradient::ColorStop step; for (int32 i = 0; archive->FindFloat("offset", i, &step.offset) >= B_OK; i++) { - if (archive->FindInt32("color", i, (int32*)&step.color) >= B_OK) - AddColor(step, i); - else + if (archive->FindInt32("color", i, (int32*)&step.color) >= B_OK) { + // Use the slower method of adding by offset in case the gradient + // was not stored with steps in the correct order + AddColor(step.color, step.offset); + } else break; } if (archive->FindInt32("type", (int32*)&fType) < B_OK)