Issue #3487820: 'layout' context in getLayout() causes potential null reference errors
We need to make sure that the selected layout entity exists because it might be pointing to a null reference
We need to make sure that the selected layout entity exists because it might be pointing to a null reference