From bd015f5c977f9ee3b03fcc9a2092b13672de6bff Mon Sep 17 00:00:00 2001 From: attila Date: Fri, 21 Mar 2025 18:13:32 +0100 Subject: [PATCH] Fix psabi warning emitted by GCC on ARM64 The type std::pair, float> inherits from an empty base on C++17. Due to a bug in GCC 10.1 this would prevent the compiler from treating it as a HFA type, and it would use a different register to pass it, than it does in newer GCC versions. Because of this ABI change an ABI warning is emitted by GCC today, hinting at this fact. By using a custom struct that does not inherit from an empty base we are avoiding emitting this warning. --- modules/juce_gui_basics/widgets/juce_TextEditor.cpp | 10 +++++----- modules/juce_gui_basics/widgets/juce_TextEditor.h | 11 +++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index adca801da0..ba044e31ae 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -661,7 +661,7 @@ void TextEditor::repaintText (Range range) const auto info = getCursorEdge (caretState.withPosition (range.getEnd()) .withPreferredEdge (Edge::leading)); - y2 = (int) (info.first.y + lh * 2.0f); + y2 = (int) (info.anchor.y + lh * 2.0f); } const auto offset = getYOffset(); @@ -872,7 +872,7 @@ Range TextEditor::getLineRangeForIndex (int index) + lastParagraphItem.range.getStart(); } -std::pair, float> TextEditor::getTextSelectionEdge (int index, Edge edge) const +TextEditor::CaretEdge TextEditor::getTextSelectionEdge (int index, Edge edge) const { jassert (0 <= index && index < getTotalNumChars()); const auto textRange = Range::withStartAndLength ((int64) index, 1); @@ -1702,8 +1702,8 @@ TextEditor::Edge TextEditor::getEdgeTypeCloserToPosition (int indexInText, Point { const auto testCaret = caretState.withPosition (indexInText); - const auto leading = getCursorEdge (testCaret.withPreferredEdge (Edge::leading)).first.getDistanceFrom (pos); - const auto trailing = getCursorEdge (testCaret.withPreferredEdge (Edge::trailing)).first.getDistanceFrom (pos); + const auto leading = getCursorEdge (testCaret.withPreferredEdge (Edge::leading)).anchor.getDistanceFrom (pos); + const auto trailing = getCursorEdge (testCaret.withPreferredEdge (Edge::trailing)).anchor.getDistanceFrom (pos); if (leading < trailing) return Edge::leading; @@ -2139,7 +2139,7 @@ bool TextEditor::isEmpty() const return getTotalNumChars() == 0; } -std::pair, float> TextEditor::getCursorEdge (const CaretState& tempCaret) const +TextEditor::CaretEdge TextEditor::getCursorEdge (const CaretState& tempCaret) const { const auto visualIndex = tempCaret.getVisualIndex(); jassert (0 <= visualIndex && visualIndex <= getTotalNumChars()); diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index 4b03eb493a..7c8504e6c7 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -906,8 +906,15 @@ private: void insert (const String&, int insertIndex, const Font&, Colour, UndoManager*, int newCaretPos); void reinsert (const TextEditorStorageChunks& chunks); void remove (Range, UndoManager*, int caretPositionToMoveTo, TextEditorStorageChunks* removedOut = nullptr); - std::pair, float> getTextSelectionEdge (int index, Edge edge) const; - std::pair, float> getCursorEdge (const CaretState& caret) const; + + struct CaretEdge + { + Point anchor; + float height{}; + }; + + CaretEdge getTextSelectionEdge (int index, Edge edge) const; + CaretEdge getCursorEdge (const CaretState& caret) const; void updateCaretPosition(); void updateValueFromText(); void textWasChangedByValue();