Fix #9658 (crash with diagrams)