Fix the bug in shader window ownership - clear nullptr's first