mirror of
https://github.com/rive-app/rive-ios.git
synced 2026-01-18 17:11:28 +01:00
fix: add nullptr check when retrieving text run on iOS at the artboard
Issue: https://github.com/rive-app/rive-ios/issues/286 Doing a small check on the artboard query for a text run for `nullptr` before returning from the Artboard Diffs= 35daf194f fix: add nullptr check when retrieving text run on iOS at the artboard (#6312) Co-authored-by: Zachary Plata <plata.zach@gmail.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
fabb7f97fe7b69368c9a7369febfecbc90be49cd
|
||||
35daf194f427d04fb4a906f8162a1da53709aa5d
|
||||
|
||||
@@ -1 +1 @@
|
||||
7b7595392d849217e43a829b71dfad58ecf29b06
|
||||
683bae68fa2a0cf8515f2dbfb35bdd0c3a298ecd
|
||||
|
||||
@@ -24,7 +24,11 @@ struct TextInputView: DismissableView {
|
||||
.padding()
|
||||
.onChange(of: userInput, perform: { newValue in
|
||||
if (!newValue.isEmpty) {
|
||||
try! rvm.setTextRunValue("MyRun", textValue: userInput)
|
||||
do {
|
||||
try rvm.setTextRunValue("MyRun", textValue: userInput)
|
||||
} catch {
|
||||
debugPrint(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
rvm.view()
|
||||
|
||||
@@ -221,7 +221,11 @@ static int artInstanceCount = 0;
|
||||
{
|
||||
const std::string stdName = std::string([name UTF8String]);
|
||||
auto riveTextRun = _artboardInstance->find<rive::TextValueRun>(stdName);
|
||||
return [[RiveTextValueRun alloc] initWithTextValueRun:std::move(riveTextRun)];
|
||||
if (riveTextRun != nullptr)
|
||||
{
|
||||
return [[RiveTextValueRun alloc] initWithTextValueRun:std::move(riveTextRun)];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -141,4 +141,13 @@
|
||||
XCTAssertTrue([[textRun text] isEqualToString:@"Hello text"]);
|
||||
}
|
||||
|
||||
- (void)testCatchingErrorOnBadTextRun
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"testtext" error:nil];
|
||||
NSError* error = nil;
|
||||
RiveArtboard* artboard = [file artboardFromName:@"New Artboard" error:&error];
|
||||
RiveTextValueRun* textRun = [artboard textRun:@"BADRUN"];
|
||||
XCTAssertNil(textRun);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user