Switching EK2/EK3_ALT_SOURCE during flight

Is it safe to switch EK2/EK3_ALT_SOURCE during flight ? i tried doing this on SITL, everything seems alright when switching alt source from baro to GPS but when i switched back from GPS to baro then i found EK2/EK3_ALT_SOURCE did get updated to 0 but by looking at raw baro and GPS altitudes, i found SITL quadcopter seems to be using GPS alt cause quadcopter altitude seems to be following GPS altitude more closely.

I was using this to print baro and gps altitudes in copter.cpp:

int32_t ret_alt_cms=0;
bool check_gps_alt;
check_gps_alt=AP::gps().location().get_alt_cm(Location::AltFrame::ABOVE_HOME,ret_alt_cms);
gcs().send_text(MAV_SEVERITY_INFO, “REL_GPS_ALT: %d”,ret_alt_cms);
gcs().send_text(MAV_SEVERITY_INFO, “BARO_ALT: %d\n”,baro_alt);