Skip to content

Commit

Permalink
Workaround for Swift 2.0 compiler issue (Fixes #406)
Browse files Browse the repository at this point in the history
I cannot avoid committing this into `master`, as Xcode 7.0 is not in beta anymore, and a fix is not expected anytime soon.
The compiler bug was reported to Apple.
  • Loading branch information
danielgindi committed Oct 1, 2015
1 parent d5e58da commit 0a97041
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Charts/Classes/Charts/CombinedChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public class CombinedChartView: BarLineChartViewBase

_highlighter = CombinedHighlighter(chart: self)

_fillFormatter = BarLineChartFillFormatter(chart: self)
/// WORKAROUND: Swift 2.0 compiler malfunctions when optimizations are enabled, and assigning directly to _fillFormatter causes a crash with a EXC_BAD_ACCESS. See https://github.com/danielgindi/ios-charts/issues/406
let workaroundFormatter = BarLineChartFillFormatter(chart: self)
_fillFormatter = workaroundFormatter

renderer = CombinedChartRenderer(chart: self, animator: _animator, viewPortHandler: _viewPortHandler)
}
Expand Down

6 comments on commit 0a97041

@liuxuan30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielgindi _fillFormatter is defined as variable, but creating a constant and assign it to _fillFormatter variable, will swift help to do the proper convention? Like in Objc mutableCopy.
I know Xcode warns me if I use var instead of let, but I am still a little worried...

@pmairoldi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends if it's a reference type or a value type. I believe this is a class so it won't copy. Just point the same pointer to another location. var and let have nothing to do with copying.

@pmairoldi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One day I'm gonna go through this and remove all those !. Everytime I see one I think "there's a crash waiting to happen"

@liuxuan30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petester42 thanks for explaining!

@danielgindi
Copy link
Collaborator Author

@danielgindi danielgindi commented on 0a97041 Oct 6, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmairoldi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya I know for this it has no relation. In this case it should probably be a two stage initialization or lazy initialization

Please sign in to comment.