Fix "invalid nullptr parameter" warning from QObject::connect
The window() of the QDeclarativeGeoMap item might be nullptr when it is
used in tests. And the window might also change if the item is move into
a different scene.
So only connect to a valid window pointer, and reconnect when the window
changes. This requires that we store a pointer to the old QQuickWindow
in the item, as we need to disconnect from the old window (and the
QQuickItem::itemChanged doesn't provide access to the old window).
Pick-to: 6.2
Change-Id: Id79a6c19990109d3900d5e483968b4f4cd4b2fbc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>