Crash when saving after painting on a layer

See the last point in Nomad Change Log - #22 by stephomi