Fix layer switching and assertion errors
Fix layer switching and assertion errors

CURA-3848

ROBO3D/CuraEngine,alephobjects/CuraEngine,Ultimaker/CuraEngine,ROBO3D/CuraEngine,alephobjects/CuraEngine,ROBO3D/CuraEngine,Ultimaker/CuraEngine,alephobjects/CuraEngine