fix(ios): avoid double-initializing FLTPDFView#332
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe initializer for FLTPDFViewController now checks the result of [super init] and returns nil if initialization fails, and documents that FLTPDFView should be created with alloc/init (not new) to avoid UIKit trait-collection initialization issues. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ios/flutter_pdfview/Sources/flutter_pdfview/FlutterPDFView.m (1)
114-117: Critical: Missing[super initWithFrame:frame]call inFLTPDFView.The
initWithFrame:arguments:controller:method sets instance variables and returnsselfwithout ever calling the superclass initializer. SinceFLTPDFViewis aUIViewsubclass (it callsaddSubview:on line 244), you must call[super initWithFrame:frame]to properly initialize the view hierarchy.Without this, the UIView is left in an undefined state, which could cause crashes or undefined behavior—especially on newer iOS versions with trait collection initialization.
🐛 Proposed fix
- (instancetype)initWithFrame:(CGRect)frame arguments:(id _Nullable)args controller:(nonnull FLTPDFViewController *)controller { + self = [super initWithFrame:frame]; + if (!self) return nil; + _controller = controller;
|
Hi @muhammadbiilal, thanks for your PR. This one looks to be fixed in 1.4.5-beta.2. Can you double check that is the case? |
Summary by CodeRabbit