fix potential crash in edge-case layout situations
Merge pull request #87 from nucleic/fix-layout-refresh

fix potential crash in edge-case layout situations