mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 21:21:17 +01:00
fix: static analysis fixes (#9918) c71be9b1a2
* fix: static analysis fixes * Update packages/runtime/src/file.cpp * chore: checking if glyph coverage broke test * chore: try a different fix Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com> Co-authored-by: hernan <hernan@rive.app>
This commit is contained in:
@@ -1 +1 @@
|
||||
3aa5b93199675c7639d7b47a4b4814c99372ef3e
|
||||
c71be9b1a22c8f1b7e8eba5b28c12660e111662c
|
||||
|
||||
@@ -12,7 +12,16 @@ template <typename T> class TypedChild
|
||||
public:
|
||||
TypedChild(Core** child, Core** end) : m_child(child), m_end(end) {}
|
||||
|
||||
T* operator*() const { return (*m_child)->template as<T>(); }
|
||||
T* operator*() const
|
||||
{
|
||||
auto child = *m_child;
|
||||
if (child == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return child->template as<T>();
|
||||
}
|
||||
|
||||
TypedChild& operator++()
|
||||
{
|
||||
m_child++;
|
||||
|
||||
@@ -242,7 +242,7 @@ Vec2D ScrollConstraint::positionAtIndex(float index)
|
||||
uint32_t i = 0;
|
||||
Vec2D contentGap = gap();
|
||||
float floorIndex = std::floor(index);
|
||||
LayoutNodeProvider* lastChild;
|
||||
LayoutNodeProvider* lastChild = nullptr;
|
||||
for (auto child : content()->children())
|
||||
{
|
||||
auto c = LayoutNodeProvider::from(child);
|
||||
@@ -261,6 +261,11 @@ Vec2D ScrollConstraint::positionAtIndex(float index)
|
||||
i += count;
|
||||
}
|
||||
}
|
||||
if (lastChild == nullptr)
|
||||
{
|
||||
return Vec2D();
|
||||
}
|
||||
|
||||
auto bounds =
|
||||
lastChild->layoutBoundsForNode((int)lastChild->numLayoutNodes() - 1);
|
||||
return Vec2D(-bounds.left(), -bounds.top());
|
||||
|
||||
@@ -261,7 +261,7 @@ ImportResult File::read(BinaryReader& reader, const RuntimeHeader& header)
|
||||
// TODO: @hernan consider moving this to a special importer. It's not that
|
||||
// simple because Core doesn't have a typeKey, so it should be treated as
|
||||
// a special case. In any case, it's not that bad having it here for now.
|
||||
Core* lastBindableObject;
|
||||
Core* lastBindableObject = nullptr;
|
||||
while (!reader.reachedEnd())
|
||||
{
|
||||
auto object = readRuntimeObject(reader, header);
|
||||
@@ -332,6 +332,10 @@ ImportResult File::read(BinaryReader& reader, const RuntimeHeader& header)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lastBindableObject == object)
|
||||
{
|
||||
lastBindableObject = nullptr;
|
||||
}
|
||||
fprintf(stderr,
|
||||
"Failed to import object of type %d\n",
|
||||
object->coreType());
|
||||
|
||||
@@ -132,6 +132,7 @@ void LinearGradient::applyTo(RenderPaint* renderPaint, float opacityModifier)
|
||||
parent()->as<ShapePaint>()->isFlagged(PathFlags::world);
|
||||
Vec2D start(startX(), startY());
|
||||
Vec2D end(endX(), endY());
|
||||
|
||||
// Check if we need to update the world space gradient (if there's no
|
||||
// shape container, presumably it's the artboard and we're already in
|
||||
// world).
|
||||
@@ -150,7 +151,7 @@ void LinearGradient::applyTo(RenderPaint* renderPaint, float opacityModifier)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_deformer)
|
||||
if (m_deformer && m_shapePaintContainer != nullptr)
|
||||
{
|
||||
const Mat2D& world = m_shapePaintContainer->worldTransform();
|
||||
Mat2D inverseWorld;
|
||||
|
||||
@@ -87,7 +87,6 @@ void FullyShapedText::shape(Span<Unichar> text,
|
||||
isEllipsisLineLast = lastLineIndex == ellipsisLine;
|
||||
|
||||
int32_t lineIndex = 0;
|
||||
paragraphIndex = 0;
|
||||
m_bounds =
|
||||
AABB(0.0f, minY, measuredWidth, std::max(minY, y - paragraphSpacing));
|
||||
|
||||
|
||||
@@ -189,7 +189,6 @@ void RawText::update()
|
||||
isEllipsisLineLast = lastLineIndex == ellipsisLine;
|
||||
|
||||
int lineIndex = 0;
|
||||
paragraphIndex = 0;
|
||||
switch (m_sizing)
|
||||
{
|
||||
case TextSizing::autoWidth:
|
||||
|
||||
@@ -134,7 +134,7 @@ float TextModifierGroup::glyphCoverage(uint32_t textIndex,
|
||||
{
|
||||
c += coverage(textIndex + i);
|
||||
}
|
||||
return c /= (float)codePointCount;
|
||||
return c / (float)codePointCount;
|
||||
}
|
||||
|
||||
void TextModifierGroup::onTextWorldTransformDirty()
|
||||
|
||||
Reference in New Issue
Block a user