Otherwise it would fail when opening the same file twice in the same instance. (cherry picked from commit d7a4573d)