Part of logging an NSView is redrawing it if it's dirty However, a view can ask to be redrawn by setting its needsDisplay flag to true When this happens in a playground, the self.needsDisplay = true line forces the view to be logged - logging the view forces it to be redrawn, and unless there's a way out that does not force-redraw, this ends up being an endless loop & of course at some point we run out of stack, and "random" crashes ensue
Part of logging an NSView is redrawing it if it's dirty
However, a view can ask to be redrawn by setting its needsDisplay flag to true
When this happens in a playground, the
self.needsDisplay = true line
forces the view to be logged - logging the view forces it to be redrawn, and unless there's a way out that does not force-redraw, this ends up being an endless loop & of course at some point we run out of stack, and "random" crashes ensue

Add a set of views currently being logged and add/remove views as needed to ensure we don't try to actively log the same view twice

Since UI drawing can only happen on the main thread, if you try to concurrently log views from different threads, you already have a problem, so this can be treated as a single-threaded problem

Fixes <rdar://problem/17027976>


Swift SVN r19730

swiftix/swift,jtbandes/swift,johnno1962d/swift,jtbandes/swift,tkremenek/swift,Jnosh/swift,LeoShimonaka/swift,hooman/swift,arvedviehweger/swift,shahmishal/swift,Jnosh/swift,danielmartin/swift,emilstahl/swift,arvedviehweger/swift,felix91gr/swift,ahoppen/swift,manavgabhawala/swift,JGiola/swift,jopamer/swift,OscarSwanros/swift,amraboelela/swift,OscarSwanros/swift,KrishMunot/swift,ahoppen/swift,karwa/swift,parkera/swift,JaSpa/swift,therealbnut/swift,gregomni/swift,mightydeveloper/swift,IngmarStein/swift,manavgabhawala/swift,uasys/swift,alblue/swift,xwu/swift,dduan/swift,karwa/swift,hughbe/swift,gottesmm/swift,practicalswift/swift,cbrentharris/swift,jmgc/swift,stephentyrone/swift,tinysun212/swift-windows,felix91gr/swift,sdulal/swift,Ivacker/swift,SwiftAndroid/swift,CodaFi/swift,khizkhiz/swift,hooman/swift,khizkhiz/swift,practicalswift/swift,rudkx/swift,airspeedswift/swift,glessard/swift,kusl/swift,felix91gr/swift,shajrawi/swift,KrishMunot/swift,ken0nek/swift,kstaring/swift,xedin/swift,tkremenek/swift,practicalswift/swift,aschwaighofer/swift,rudkx/swift,zisko/swift,nathawes/swift,zisko/swift,tkremenek/swift,jckarter/swift,dduan/swift,ken0nek/swift,ken0nek/swift,harlanhaskins/swift,devincoughlin/swift,return/swift,huonw/swift,devincoughlin/swift,emilstahl/swift,KrishMunot/swift,lorentey/swift,swiftix/swift,shahmishal/swift,sschiau/swift,MukeshKumarS/Swift,allevato/swift,gottesmm/swift,bitjammer/swift,parkera/swift,LeoShimonaka/swift,swiftix/swift,SwiftAndroid/swift,kstaring/swift,SwiftAndroid/swift,danielmartin/swift,ken0nek/swift,cbrentharris/swift,cbrentharris/swift,therealbnut/swift,roambotics/swift,johnno1962d/swift,shahmishal/swift,apple/swift,amraboelela/swift,mightydeveloper/swift,swiftix/swift,roambotics/swift,amraboelela/swift,austinzheng/swift,sschiau/swift,sschiau/swift,therealbnut/swift,LeoShimonaka/swift,modocache/swift,Jnosh/swift,jckarter/swift,austinzheng/swift,uasys/swift,felix91gr/swift,johnno1962d/swift,mightydeveloper/swift,karwa/swift,tjw/swift,MukeshKumarS/Swift,LeoShimonaka/swift,gribozavr/swift,tjw/swift,CodaFi/swift,xedin/swift,codestergit/swift,aschwaighofer/swift,emilstahl/swift,felix91gr/swift,rudkx/swift,emilstahl/swift,benlangmuir/swift,shajrawi/swift,brentdax/swift,austinzheng/swift,airspeedswift/swift,xwu/swift,ahoppen/swift,natecook1000/swift,slavapestov/swift,stephentyrone/swift,gribozavr/swift,tjw/swift,ben-ng/swift,amraboelela/swift,ben-ng/swift,ken0nek/swift,shajrawi/swift,felix91gr/swift,rudkx/swift,nathawes/swift,natecook1000/swift,sdulal/swift,codestergit/swift,KrishMunot/swift,glessard/swift,kperryua/swift,calebd/swift,kusl/swift,uasys/swift,arvedviehweger/swift,adrfer/swift,mightydeveloper/swift,swiftix/swift.old,therealbnut/swift,shajrawi/swift,glessard/swift,russbishop/swift,devincoughlin/swift,MukeshKumarS/Swift,calebd/swift,stephentyrone/swift,emilstahl/swift,devincoughlin/swift,hooman/swift,tkremenek/swift,xedin/swift,practicalswift/swift,tardieu/swift,brentdax/swift,tjw/swift,ben-ng/swift,bitjammer/swift,lorentey/swift,glessard/swift,danielmartin/swift,adrfer/swift,djwbrown/swift,MukeshKumarS/Swift,dreamsxin/swift,codestergit/swift,uasys/swift,allevato/swift,atrick/swift,calebd/swift,airspeedswift/swift,brentdax/swift,practicalswift/swift,Ivacker/swift,therealbnut/swift,JGiola/swift,shahmishal/swift,kentya6/swift,sdulal/swift,OscarSwanros/swift,nathawes/swift,arvedviehweger/swift,brentdax/swift,amraboelela/swift,OscarSwanros/swift,gottesmm/swift,amraboelela/swift,slavapestov/swift,aschwaighofer/swift,tinysun212/swift-windows,dduan/swift,allevato/swift,roambotics/swift,ken0nek/swift,sschiau/swift,kstaring/swift,Ivacker/swift,nathawes/swift,jmgc/swift,glessard/swift,gregomni/swift,return/swift,IngmarStein/swift,jopamer/swift,allevato/swift,slavapestov/swift,practicalswift/swift,tkremenek/swift,practicalswift/swift,austinzheng/swift,SwiftAndroid/swift,russbishop/swift,xedin/swift,jckarter/swift,mightydeveloper/swift,shahmishal/swift,zisko/swift,kperryua/swift,kusl/swift,huonw/swift,arvedviehweger/swift,austinzheng/swift,modocache/swift,amraboelela/swift,return/swift,shajrawi/swift,devincoughlin/swift,milseman/swift,djwbrown/swift,tjw/swift,parkera/swift,jmgc/swift,sdulal/swift,airspeedswift/swift,gribozavr/swift,milseman/swift,LeoShimonaka/swift,russbishop/swift,modocache/swift,jopamer/swift,ben-ng/swift,karwa/swift,huonw/swift,mightydeveloper/swift,swiftix/swift,atrick/swift,deyton/swift,devincoughlin/swift,MukeshKumarS/Swift,modocache/swift,KrishMunot/swift,hooman/swift,djwbrown/swift,brentdax/swift,adrfer/swift,tkremenek/swift,gottesmm/swift,zisko/swift,lorentey/swift,ahoppen/swift,milseman/swift,austinzheng/swift,danielmartin/swift,jtbandes/swift,frootloops/swift,gmilos/swift,shahmishal/swift,airspeedswift/swift,Jnosh/swift,emilstahl/swift,Ivacker/swift,calebd/swift,gregomni/swift,gmilos/swift,sschiau/swift,manavgabhawala/swift,kstaring/swift,hooman/swift,return/swift,airspeedswift/swift,SwiftAndroid/swift,johnno1962d/swift,kusl/swift,jopamer/swift,gmilos/swift,return/swift,slavapestov/swift,harlanhaskins/swift,cbrentharris/swift,hooman/swift,alblue/swift,MukeshKumarS/Swift,kentya6/swift,gribozavr/swift,KrishMunot/swift,apple/swift,apple/swift,kperryua/swift,zisko/swift,tardieu/swift,kusl/swift,karwa/swift,xwu/swift,Jnosh/swift,deyton/swift,hughbe/swift,return/swift,bitjammer/swift,jtbandes/swift,adrfer/swift,cbrentharris/swift,stephentyrone/swift,karwa/swift,johnno1962d/swift,MukeshKumarS/Swift,apple/swift,xwu/swift,codestergit/swift,dduan/swift,zisko/swift,Ivacker/swift,tardieu/swift,ken0nek/swift,gregomni/swift,frootloops/swift,Ivacker/swift,gottesmm/swift,therealbnut/swift,gregomni/swift,bitjammer/swift,tjw/swift,jmgc/swift,aschwaighofer/swift,swiftix/swift,frootloops/swift,swiftix/swift.old,KrishMunot/swift,gribozavr/swift,khizkhiz/swift,benlangmuir/swift,tardieu/swift,karwa/swift,frootloops/swift,ahoppen/swift,atrick/swift,kstaring/swift,LeoShimonaka/swift,sschiau/swift,therealbnut/swift,felix91gr/swift,lorentey/swift,tardieu/swift,jtbandes/swift,djwbrown/swift,huonw/swift,ben-ng/swift,atrick/swift,milseman/swift,hughbe/swift,airspeedswift/swift,swiftix/swift.old,manavgabhawala/swift,cbrentharris/swift,tardieu/swift,swiftix/swift.old,apple/swift,shajrawi/swift,adrfer/swift,karwa/swift,austinzheng/swift,lorentey/swift,LeoShimonaka/swift,danielmartin/swift,jmgc/swift,kentya6/swift,nathawes/swift,alblue/swift,gmilos/swift,khizkhiz/swift,IngmarStein/swift,frootloops/swift,deyton/swift,russbishop/swift,IngmarStein/swift,codestergit/swift,calebd/swift,calebd/swift,gmilos/swift,devincoughlin/swift,natecook1000/swift,gribozavr/swift,codestergit/swift,shajrawi/swift,dduan/swift,uasys/swift,practicalswift/swift,manavgabhawala/swift,OscarSwanros/swift,jtbandes/swift,alblue/swift,tinysun212/swift-windows,swiftix/swift.old,ben-ng/swift,parkera/swift,gottesmm/swift,bitjammer/swift,gmilos/swift,xedin/swift,jopamer/swift,gribozavr/swift,OscarSwanros/swift,manavgabhawala/swift,ben-ng/swift,kstaring/swift,modocache/swift,jckarter/swift,tkremenek/swift,kperryua/swift,stephentyrone/swift,CodaFi/swift,sschiau/swift,CodaFi/swift,roambotics/swift,harlanhaskins/swift,JGiola/swift,dduan/swift,calebd/swift,parkera/swift,aschwaighofer/swift,cbrentharris/swift,xedin/swift,apple/swift,glessard/swift,roambotics/swift,russbishop/swift,huonw/swift,deyton/swift,sdulal/swift,rudkx/swift,harlanhaskins/swift,benlangmuir/swift,IngmarStein/swift,tinysun212/swift-windows,jmgc/swift,tardieu/swift,swiftix/swift.old,atrick/swift,slavapestov/swift,roambotics/swift,gregomni/swift,alblue/swift,nathawes/swift,djwbrown/swift,natecook1000/swift,brentdax/swift,khizkhiz/swift,khizkhiz/swift,parkera/swift,sdulal/swift,kusl/swift,danielmartin/swift,arvedviehweger/swift,johnno1962d/swift,adrfer/swift,sdulal/swift,tinysun212/swift-windows,tjw/swift,parkera/swift,IngmarStein/swift,gmilos/swift,Jnosh/swift,johnno1962d/swift,return/swift,hughbe/swift,kentya6/swift,allevato/swift,jmgc/swift,aschwaighofer/swift,harlanhaskins/swift,devincoughlin/swift,deyton/swift,arvedviehweger/swift,benlangmuir/swift,harlanhaskins/swift,kperryua/swift,kentya6/swift,uasys/swift,slavapestov/swift,milseman/swift,allevato/swift,emilstahl/swift,kperryua/swift,bitjammer/swift,jckarter/swift,natecook1000/swift,lorentey/swift,gribozavr/swift,benlangmuir/swift,kentya6/swift,jckarter/swift,shajrawi/swift,cbrentharris/swift,benlangmuir/swift,sdulal/swift,alblue/swift,kstaring/swift,deyton/swift,JaSpa/swift,slavapestov/swift,codestergit/swift,hooman/swift,gottesmm/swift,xwu/swift,Ivacker/swift,huonw/swift,danielmartin/swift,xedin/swift,kperryua/swift,hughbe/swift,jopamer/swift,shahmishal/swift,aschwaighofer/swift,djwbrown/swift,manavgabhawala/swift,frootloops/swift,kentya6/swift,modocache/swift,xedin/swift,atrick/swift,milseman/swift,Ivacker/swift,mightydeveloper/swift,tinysun212/swift-windows,harlanhaskins/swift,xwu/swift,russbishop/swift,Jnosh/swift,JaSpa/swift,khizkhiz/swift,kusl/swift,ahoppen/swift,swiftix/swift.old,bitjammer/swift,JaSpa/swift,allevato/swift,CodaFi/swift,lorentey/swift,djwbrown/swift,stephentyrone/swift,russbishop/swift,stephentyrone/swift,natecook1000/swift,rudkx/swift,IngmarStein/swift,mightydeveloper/swift,JGiola/swift,emilstahl/swift,frootloops/swift,uasys/swift,JaSpa/swift,jckarter/swift,swiftix/swift.old,huonw/swift,nathawes/swift,dduan/swift,LeoShimonaka/swift,xwu/swift,JGiola/swift,JaSpa/swift,hughbe/swift,tinysun212/swift-windows,JaSpa/swift,modocache/swift,CodaFi/swift,dreamsxin/swift,jopamer/swift,SwiftAndroid/swift,kentya6/swift,shahmishal/swift,alblue/swift,hughbe/swift,adrfer/swift,jtbandes/swift,swiftix/swift,sschiau/swift,SwiftAndroid/swift,natecook1000/swift,JGiola/swift,milseman/swift,OscarSwanros/swift,CodaFi/swift,lorentey/swift,zisko/swift,kusl/swift,deyton/swift,brentdax/swift,parkera/swift