Skip to content

Commit bd015f5

Browse files
committed
Fix psabi warning emitted by GCC on ARM64
The type std::pair<Point<float>, 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.
1 parent 5f5a247 commit bd015f5

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

modules/juce_gui_basics/widgets/juce_TextEditor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ void TextEditor::repaintText (Range<int> range)
661661
const auto info = getCursorEdge (caretState.withPosition (range.getEnd())
662662
.withPreferredEdge (Edge::leading));
663663

664-
y2 = (int) (info.first.y + lh * 2.0f);
664+
y2 = (int) (info.anchor.y + lh * 2.0f);
665665
}
666666

667667
const auto offset = getYOffset();
@@ -872,7 +872,7 @@ Range<int64> TextEditor::getLineRangeForIndex (int index)
872872
+ lastParagraphItem.range.getStart();
873873
}
874874

875-
std::pair<Point<float>, float> TextEditor::getTextSelectionEdge (int index, Edge edge) const
875+
TextEditor::CaretEdge TextEditor::getTextSelectionEdge (int index, Edge edge) const
876876
{
877877
jassert (0 <= index && index < getTotalNumChars());
878878
const auto textRange = Range<int64>::withStartAndLength ((int64) index, 1);
@@ -1702,8 +1702,8 @@ TextEditor::Edge TextEditor::getEdgeTypeCloserToPosition (int indexInText, Point
17021702
{
17031703
const auto testCaret = caretState.withPosition (indexInText);
17041704

1705-
const auto leading = getCursorEdge (testCaret.withPreferredEdge (Edge::leading)).first.getDistanceFrom (pos);
1706-
const auto trailing = getCursorEdge (testCaret.withPreferredEdge (Edge::trailing)).first.getDistanceFrom (pos);
1705+
const auto leading = getCursorEdge (testCaret.withPreferredEdge (Edge::leading)).anchor.getDistanceFrom (pos);
1706+
const auto trailing = getCursorEdge (testCaret.withPreferredEdge (Edge::trailing)).anchor.getDistanceFrom (pos);
17071707

17081708
if (leading < trailing)
17091709
return Edge::leading;
@@ -2139,7 +2139,7 @@ bool TextEditor::isEmpty() const
21392139
return getTotalNumChars() == 0;
21402140
}
21412141

2142-
std::pair<Point<float>, float> TextEditor::getCursorEdge (const CaretState& tempCaret) const
2142+
TextEditor::CaretEdge TextEditor::getCursorEdge (const CaretState& tempCaret) const
21432143
{
21442144
const auto visualIndex = tempCaret.getVisualIndex();
21452145
jassert (0 <= visualIndex && visualIndex <= getTotalNumChars());

modules/juce_gui_basics/widgets/juce_TextEditor.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,15 @@ class JUCE_API TextEditor : public TextInputTarget,
906906
void insert (const String&, int insertIndex, const Font&, Colour, UndoManager*, int newCaretPos);
907907
void reinsert (const TextEditorStorageChunks& chunks);
908908
void remove (Range<int>, UndoManager*, int caretPositionToMoveTo, TextEditorStorageChunks* removedOut = nullptr);
909-
std::pair<Point<float>, float> getTextSelectionEdge (int index, Edge edge) const;
910-
std::pair<Point<float>, float> getCursorEdge (const CaretState& caret) const;
909+
910+
struct CaretEdge
911+
{
912+
Point<float> anchor;
913+
float height{};
914+
};
915+
916+
CaretEdge getTextSelectionEdge (int index, Edge edge) const;
917+
CaretEdge getCursorEdge (const CaretState& caret) const;
911918
void updateCaretPosition();
912919
void updateValueFromText();
913920
void textWasChangedByValue();

0 commit comments

Comments
 (0)