Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maxNumSubviews == -1 #17

Open
peterkos opened this issue Feb 1, 2020 · 4 comments
Open

maxNumSubviews == -1 #17

peterkos opened this issue Feb 1, 2020 · 4 comments

Comments

@peterkos
Copy link

peterkos commented Feb 1, 2020

Not sure how to reproduce this, but for some reason maxNumSubviews ends up being -1, which causes a crash in TimelineTableViewCell on this line:

let views = viewsInStackView.count <= maxNumSubviews ? viewsInStackView : Array(viewsInStackView[0..<maxNumSubviews])

Just curious if anyone else has had this problem?
I'm working on a fork on my end, so it may be caused by that. However refactoring this line to be a bit cleaner couldn't hurt

@peterkos
Copy link
Author

peterkos commented Feb 1, 2020

Yeah, I think it's fork specific, as in the definition

Int(floor(stackView.frame.size.width / (stackView.frame.size.height + stackView.spacing))) - 1

the ratio is evaluated to 0, which is then turned to -1.

Thoughts on submitting a fix?

@kf99916
Copy link
Owner

kf99916 commented Feb 3, 2020

@peterkos thank your for reporting this issue. It should be checked whether maxNumSubviews and divisor are valid or not. I will try to fix it when I am available. BTW, I would appreciate it if you can help fix it or provide reproduce test cases.

@peterkos
Copy link
Author

peterkos commented Feb 3, 2020

I'm busy through the weekend, so I wont' be able to investigate further until then. But here's my temporary fix:

+ var views = viewsInStackView
+ // Overwrite if too many views
+ if (viewsInStackView.count > maxNumSubviews && maxNumSubviews >= 0) {
+    views = Array(viewsInStackView[0..<maxNumSubviews])
+ }

@thachonline
Copy link

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants