Only set the pattern function pointer if the pattern surface is valid, spotted by...