Partially work around currently unimplemented cache invalidation in wxMac and do it on the fly if an invalid index is passed to GetDisplay() to at least avoid crashing, even if this doesn't fully solve the problem, e.g. we still can use stale information. Closes #18607.