Merge pull request #107406 from Ivorforce/ip-to-string-explicit

Core: Remove implicit conversions from `IPAddress` to `String`, to avoid accidental conversions
This commit is contained in:
Rémi Verschelde 2025-06-12 01:15:53 +02:00
commit d9cd011e2f
No known key found for this signature in database
GPG Key ID: C3336907360768E1
5 changed files with 6 additions and 6 deletions

View File

@ -259,7 +259,7 @@ PackedStringArray IP::_get_local_addresses() const {
List<IPAddress> ip_addresses;
get_local_addresses(&ip_addresses);
for (const IPAddress &E : ip_addresses) {
addresses.push_back(E);
addresses.push_back(String(E));
}
return addresses;

View File

@ -89,7 +89,7 @@ public:
const uint8_t *get_ipv6() const;
void set_ipv6(const uint8_t *p_buf);
operator String() const;
explicit operator String() const;
IPAddress(const String &p_string);
IPAddress(uint32_t p_a, uint32_t p_b, uint32_t p_c, uint32_t p_d, bool is_v6 = false);
IPAddress() { clear(); }

View File

@ -68,7 +68,7 @@ Error PacketPeerUDP::leave_multicast_group(IPAddress p_multi_address, const Stri
}
String PacketPeerUDP::_get_packet_ip() const {
return get_packet_address();
return String(get_packet_address());
}
Error PacketPeerUDP::_set_dest_address(const String &p_address, int p_port) {

View File

@ -821,7 +821,7 @@ struct VariantInternalAccessor<const T *> {
template <>
struct VariantInternalAccessor<IPAddress> {
static _FORCE_INLINE_ IPAddress get(const Variant *v) { return IPAddress(*VariantInternal::get_string(v)); }
static _FORCE_INLINE_ void set(Variant *v, IPAddress p_value) { *VariantInternal::get_string(v) = p_value; }
static _FORCE_INLINE_ void set(Variant *v, IPAddress p_value) { *VariantInternal::get_string(v) = String(p_value); }
};
template <>

View File

@ -1386,12 +1386,12 @@ void EditorSettings::setup_network() {
}
// Select current IP (found)
if (ip == current) {
selected = ip;
selected = String(ip);
}
if (!hint.is_empty()) {
hint += ",";
}
hint += ip;
hint += String(ip);
}
// Add hints with valid IP addresses to remote_host property.