# Conflicts:
#	indra/llmessage/lltemplatemessagedispatcher.cpp
#	indra/newview/llappviewer.cpp
master
Ansariel 2024-07-06 12:42:19 +02:00
commit 75aa83aab6
16 changed files with 299 additions and 168 deletions

View File

@ -41,20 +41,11 @@
#include "llstring.h"
#include "llfasttimer.h"
static const F64 DATE_EPOCH = 0.0;
static const F64 LL_APR_USEC_PER_SEC = 1000000.0;
// should be APR_USEC_PER_SEC, but that relies on INT64_C which
// isn't defined in glib under our build set up for some reason
LLDate::LLDate() : mSecondsSinceEpoch(DATE_EPOCH)
{}
LLDate::LLDate(const LLDate& date) :
mSecondsSinceEpoch(date.mSecondsSinceEpoch)
{}
LLDate::LLDate(F64SecondsImplicit seconds_since_epoch) :
mSecondsSinceEpoch(seconds_since_epoch.value())
{}

View File

@ -45,16 +45,13 @@
*/
class LL_COMMON_API LLDate
{
static constexpr F64 DATE_EPOCH = 0.0;
public:
/**
* @brief Construct a date equal to epoch.
*/
LLDate();
/**
* @brief Construct a date equal to the source date.
*/
LLDate(const LLDate& date);
constexpr LLDate() : mSecondsSinceEpoch(DATE_EPOCH)
{}
/**
* @brief Construct a date from a seconds since epoch value.

View File

@ -106,6 +106,9 @@ public:
static void reset(Impl*& var, Impl* impl);
///< safely set var to refer to the new impl (possibly shared)
static void move(Impl*& var, Impl*& impl);
///< safely move impl from one object to another
static Impl& safe( Impl*);
static const Impl& safe(const Impl*);
///< since a NULL Impl* is used for undefined, this ensures there is
@ -123,11 +126,17 @@ public:
virtual void assign(Impl*& var, LLSD::Boolean);
virtual void assign(Impl*& var, LLSD::Integer);
virtual void assign(Impl*& var, LLSD::Real);
virtual void assign(Impl*& var, const char*);
virtual void assign(Impl*& var, const LLSD::String&);
virtual void assign(Impl*& var, const LLSD::UUID&);
virtual void assign(Impl*& var, const LLSD::Date&);
virtual void assign(Impl*& var, const LLSD::URI&);
virtual void assign(Impl*& var, const LLSD::Binary&);
virtual void assign(Impl*& var, LLSD::String&&);
virtual void assign(Impl*& var, LLSD::UUID&&);
virtual void assign(Impl*& var, LLSD::Date&&);
virtual void assign(Impl*& var, LLSD::URI&&);
virtual void assign(Impl*& var, LLSD::Binary&&);
///< If the receiver is the right type and unshared, these are simple
// data assignments, othewise the default implementation handless
// constructing the proper Impl subclass
@ -145,11 +154,11 @@ public:
virtual String asXMLRPCValue() const { return "<nil/>"; }
virtual bool has(const String&) const { return false; }
virtual LLSD get(const String&) const { return LLSD(); }
virtual bool has(std::string_view) const { return false; }
virtual LLSD get(std::string_view) const { return LLSD(); }
virtual LLSD getKeys() const { return LLSD::emptyArray(); }
virtual void erase(const String&) { }
virtual const LLSD& ref(const String&) const{ return undef(); }
virtual const LLSD& ref(std::string_view) const{ return undef(); }
virtual size_t size() const { return 0; }
virtual LLSD get(size_t) const { return LLSD(); }
@ -185,7 +194,7 @@ namespace LLSDUnnamedNamespace
namespace
#endif
{
template<LLSD::Type T, class Data, class DataRef = Data>
template<LLSD::Type T, class Data, class DataRef = Data, class DataMove = Data>
class ImplBase : public LLSD::Impl
///< This class handles most of the work for a subclass of Impl
// for a given simple data type. Subclasses of this provide the
@ -198,6 +207,7 @@ namespace
public:
ImplBase(DataRef value) : mValue(value) { }
ImplBase(DataMove value) : mValue(std::move(value)) { }
virtual LLSD::Type type() const { return T; }
@ -212,11 +222,21 @@ namespace
mValue = value;
}
}
virtual void assign(LLSD::Impl*& var, DataMove value) {
if (shared())
{
Impl::assign(var, std::move(value));
}
else
{
mValue = std::move(value);
}
}
};
class ImplBoolean
: public ImplBase<LLSD::TypeBoolean, LLSD::Boolean>
class ImplBoolean final
: public ImplBase<LLSD::TypeBoolean, LLSD::Boolean, LLSD::Boolean, LLSD::Boolean&&>
{
public:
ImplBoolean(LLSD::Boolean v) : Base(v) { }
@ -238,8 +258,8 @@ namespace
{ return mValue ? "true" : ""; }
class ImplInteger
: public ImplBase<LLSD::TypeInteger, LLSD::Integer>
class ImplInteger final
: public ImplBase<LLSD::TypeInteger, LLSD::Integer, LLSD::Integer, LLSD::Integer&&>
{
public:
ImplInteger(LLSD::Integer v) : Base(v) { }
@ -256,8 +276,8 @@ namespace
{ return llformat("%d", mValue); }
class ImplReal
: public ImplBase<LLSD::TypeReal, LLSD::Real>
class ImplReal final
: public ImplBase<LLSD::TypeReal, LLSD::Real, LLSD::Real, LLSD::Real&&>
{
public:
ImplReal(LLSD::Real v) : Base(v) { }
@ -280,11 +300,12 @@ namespace
{ return llformat("%lg", mValue); }
class ImplString
: public ImplBase<LLSD::TypeString, LLSD::String, const LLSD::String&>
class ImplString final
: public ImplBase<LLSD::TypeString, LLSD::String, const LLSD::String&, LLSD::String&&>
{
public:
ImplString(const LLSD::String& v) : Base(v) { }
ImplString(LLSD::String&& v) : Base(std::move(v)) {}
virtual LLSD::Boolean asBoolean() const { return !mValue.empty(); }
virtual LLSD::Integer asInteger() const;
@ -297,6 +318,19 @@ namespace
virtual const LLSD::String& asStringRef() const { return mValue; }
virtual LLSD::String asXMLRPCValue() const { return "<string>" + LLStringFn::xml_encode(mValue) + "</string>"; }
using LLSD::Impl::assign; // Unhiding base class virtuals...
virtual void assign(LLSD::Impl*& var, const char* value)
{
if (shared())
{
Impl::assign(var, value);
}
else
{
mValue = value;
}
}
};
LLSD::Integer ImplString::asInteger() const
@ -326,11 +360,12 @@ namespace
}
class ImplUUID
: public ImplBase<LLSD::TypeUUID, LLSD::UUID, const LLSD::UUID&>
class ImplUUID final
: public ImplBase<LLSD::TypeUUID, LLSD::UUID, const LLSD::UUID&, LLSD::UUID&&>
{
public:
ImplUUID(const LLSD::UUID& v) : Base(v) { }
ImplUUID(LLSD::UUID&& v) : Base(std::move(v)) { }
virtual LLSD::String asString() const{ return mValue.asString(); }
virtual LLSD::UUID asUUID() const { return mValue; }
@ -339,14 +374,18 @@ namespace
};
class ImplDate
: public ImplBase<LLSD::TypeDate, LLSD::Date, const LLSD::Date&>
class ImplDate final
: public ImplBase<LLSD::TypeDate, LLSD::Date, const LLSD::Date&, LLSD::Date&&>
{
public:
ImplDate(const LLSD::Date& v)
: ImplBase<LLSD::TypeDate, LLSD::Date, const LLSD::Date&>(v)
: ImplBase(v)
{ }
ImplDate(LLSD::Date&& v)
: ImplBase(std::move(v))
{ }
virtual LLSD::Integer asInteger() const
{
return (LLSD::Integer)(mValue.secondsSinceEpoch());
@ -362,11 +401,12 @@ namespace
};
class ImplURI
: public ImplBase<LLSD::TypeURI, LLSD::URI, const LLSD::URI&>
class ImplURI final
: public ImplBase<LLSD::TypeURI, LLSD::URI, const LLSD::URI&, LLSD::URI&&>
{
public:
ImplURI(const LLSD::URI& v) : Base(v) { }
ImplURI(LLSD::URI&& v) : Base(std::move(v)) { }
virtual LLSD::String asString() const{ return mValue.asString(); }
virtual LLSD::URI asURI() const { return mValue; }
@ -375,11 +415,12 @@ namespace
};
class ImplBinary
: public ImplBase<LLSD::TypeBinary, LLSD::Binary, const LLSD::Binary&>
class ImplBinary final
: public ImplBase<LLSD::TypeBinary, LLSD::Binary, const LLSD::Binary&, LLSD::Binary&&>
{
public:
ImplBinary(const LLSD::Binary& v) : Base(v) { }
ImplBinary(LLSD::Binary&& v) : Base(std::move(v)) { }
virtual const LLSD::Binary& asBinary() const{ return mValue; }
@ -387,10 +428,10 @@ namespace
};
class ImplMap : public LLSD::Impl
class ImplMap final : public LLSD::Impl
{
private:
typedef std::map<LLSD::String, LLSD> DataMap;
typedef std::map<LLSD::String, LLSD, std::less<>> DataMap;
DataMap mData;
@ -419,17 +460,17 @@ namespace
return os.str();
}
virtual bool has(const LLSD::String&) const;
virtual bool has(std::string_view) const;
using LLSD::Impl::get; // Unhiding get(size_t)
using LLSD::Impl::erase; // Unhiding erase(size_t)
using LLSD::Impl::ref; // Unhiding ref(size_t)
virtual LLSD get(const LLSD::String&) const;
virtual LLSD get(std::string_view) const;
virtual LLSD getKeys() const;
void insert(const LLSD::String& k, const LLSD& v);
void insert(std::string_view k, const LLSD& v);
virtual void erase(const LLSD::String&);
LLSD& ref(const LLSD::String&);
virtual const LLSD& ref(const LLSD::String&) const;
LLSD& ref(std::string_view);
virtual const LLSD& ref(std::string_view) const;
virtual size_t size() const { return mData.size(); }
@ -457,14 +498,14 @@ namespace
}
}
bool ImplMap::has(const LLSD::String& k) const
bool ImplMap::has(const std::string_view k) const
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD;
DataMap::const_iterator i = mData.find(k);
return i != mData.end();
}
LLSD ImplMap::get(const LLSD::String& k) const
LLSD ImplMap::get(const std::string_view k) const
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD;
DataMap::const_iterator i = mData.find(k);
@ -484,10 +525,10 @@ namespace
return keys;
}
void ImplMap::insert(const LLSD::String& k, const LLSD& v)
void ImplMap::insert(std::string_view k, const LLSD& v)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD;
mData.insert(DataMap::value_type(k, v));
mData.emplace(k, v);
}
void ImplMap::erase(const LLSD::String& k)
@ -496,15 +537,21 @@ namespace
mData.erase(k);
}
LLSD& ImplMap::ref(const LLSD::String& k)
LLSD& ImplMap::ref(std::string_view k)
{
return mData[k];
DataMap::iterator i = mData.lower_bound(k);
if (i == mData.end() || mData.key_comp()(k, i->first))
{
return mData.emplace_hint(i, std::make_pair(k, LLSD()))->second;
}
return i->second;
}
const LLSD& ImplMap::ref(const LLSD::String& k) const
const LLSD& ImplMap::ref(std::string_view k) const
{
DataMap::const_iterator i = mData.lower_bound(k);
if (i == mData.end() || mData.key_comp()(k, i->first))
if (i == mData.end() || mData.key_comp()(k, i->first))
{
return undef();
}
@ -532,7 +579,7 @@ namespace
{
//std::cout << " " << (*iter).first << ": " << (*iter).second << std::endl;
Impl::calcStats((*iter).second, type_counts, share_counts);
iter++;
++iter;
}
// Add in the values for this map
@ -691,7 +738,7 @@ namespace
while (iter != endArray())
{ // Add values for all items held in the array
Impl::calcStats((*iter), type_counts, share_counts);
iter++;
++iter;
}
// Add in the values for this array
@ -729,6 +776,16 @@ void LLSD::Impl::reset(Impl*& var, Impl* impl)
var = impl;
}
void LLSD::Impl::move(Impl*& var, Impl*& impl)
{
if (var && var->mUseCount != STATIC_USAGE_COUNT && --var->mUseCount == 0)
{
delete var; // destroy var if usage falls to 0 and not static
}
var = impl; // Steal impl to var without incrementing use since this is a move
impl = nullptr; // null out old-impl pointer
}
LLSD::Impl& LLSD::Impl::safe(Impl* impl)
{
static Impl theUndefined(STATIC_USAGE_COUNT);
@ -782,6 +839,11 @@ void LLSD::Impl::assign(Impl*& var, LLSD::Real v)
reset(var, new ImplReal(v));
}
void LLSD::Impl::assign(Impl*& var, const char* v)
{
reset(var, new ImplString(v));
}
void LLSD::Impl::assign(Impl*& var, const LLSD::String& v)
{
reset(var, new ImplString(v));
@ -807,6 +869,31 @@ void LLSD::Impl::assign(Impl*& var, const LLSD::Binary& v)
reset(var, new ImplBinary(v));
}
void LLSD::Impl::assign(Impl*& var, LLSD::String&& v)
{
reset(var, new ImplString(std::move(v)));
}
void LLSD::Impl::assign(Impl*& var, LLSD::UUID&& v)
{
reset(var, new ImplUUID(std::move(v)));
}
void LLSD::Impl::assign(Impl*& var, LLSD::Date&& v)
{
reset(var, new ImplDate(std::move(v)));
}
void LLSD::Impl::assign(Impl*& var, LLSD::URI&& v)
{
reset(var, new ImplURI(std::move(v)));
}
void LLSD::Impl::assign(Impl*& var, LLSD::Binary&& v)
{
reset(var, new ImplBinary(std::move(v)));
}
const LLSD& LLSD::Impl::undef()
{
@ -879,6 +966,9 @@ LLSD::~LLSD() { FREE_LLSD_OBJECT; Impl::reset(impl, 0)
LLSD::LLSD(const LLSD& other) : impl(0) { ALLOC_LLSD_OBJECT; assign(other); }
void LLSD::assign(const LLSD& other) { Impl::assign(impl, other.impl); }
LLSD::LLSD(LLSD&& other) noexcept : impl(nullptr) { ALLOC_LLSD_OBJECT; Impl::move(impl, other.impl); }
void LLSD::assign(LLSD&& other) { Impl::move(impl, other.impl); }
LLSD& LLSD::operator=(LLSD&& other) noexcept { Impl::move(impl, other.impl); return *this; }
void LLSD::clear() { Impl::assignUndefined(impl); }
@ -893,6 +983,11 @@ LLSD::LLSD(const String& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
LLSD::LLSD(const Date& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
LLSD::LLSD(const URI& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
LLSD::LLSD(const Binary& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
LLSD::LLSD(UUID&& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(std::move(v)); }
LLSD::LLSD(String&& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(std::move(v)); }
LLSD::LLSD(Date&& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(std::move(v)); }
LLSD::LLSD(URI&& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(std::move(v)); }
LLSD::LLSD(Binary&& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(std::move(v)); }
// Scalar Assignment
void LLSD::assign(Boolean v) { safe(impl).assign(impl, v); }
@ -903,6 +998,11 @@ void LLSD::assign(const UUID& v) { safe(impl).assign(impl, v); }
void LLSD::assign(const Date& v) { safe(impl).assign(impl, v); }
void LLSD::assign(const URI& v) { safe(impl).assign(impl, v); }
void LLSD::assign(const Binary& v) { safe(impl).assign(impl, v); }
void LLSD::assign(String&& v) { safe(impl).assign(impl, std::move(v)); }
void LLSD::assign(UUID&& v) { safe(impl).assign(impl, std::move(v)); }
void LLSD::assign(Date&& v) { safe(impl).assign(impl, std::move(v)); }
void LLSD::assign(URI&& v) { safe(impl).assign(impl, std::move(v)); }
void LLSD::assign(Binary&& v) { safe(impl).assign(impl, std::move(v)); }
// Scalar Accessors
LLSD::Boolean LLSD::asBoolean() const { return safe(impl).asBoolean(); }
@ -1069,7 +1169,7 @@ bool LLSD::fromXMLRPCValue(TreeNode* node)
LLSD::LLSD(const char* v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
void LLSD::assign(const char* v)
{
if(v) assign(std::string(v));
if(v) safe(impl).assign(impl, v);
else assign(std::string());
}
@ -1081,24 +1181,24 @@ LLSD LLSD::emptyMap()
return v;
}
bool LLSD::has(const String& k) const { return safe(impl).has(k); }
LLSD LLSD::get(const String& k) const { return safe(impl).get(k); }
bool LLSD::has(const std::string_view k) const { return safe(impl).has(k); }
LLSD LLSD::get(const std::string_view k) const { return safe(impl).get(k); }
LLSD LLSD::getKeys() const { return safe(impl).getKeys(); }
void LLSD::insert(const String& k, const LLSD& v) { makeMap(impl).insert(k, v); }
void LLSD::insert(std::string_view k, const LLSD& v) { makeMap(impl).insert(k, v); }
LLSD& LLSD::with(const String& k, const LLSD& v)
LLSD& LLSD::with(std::string_view k, const LLSD& v)
{
makeMap(impl).insert(k, v);
return *this;
}
void LLSD::erase(const String& k) { makeMap(impl).erase(k); }
LLSD& LLSD::operator[](const String& k)
LLSD& LLSD::operator[](const std::string_view k)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD;
return makeMap(impl).ref(k);
}
const LLSD& LLSD::operator[](const String& k) const
const LLSD& LLSD::operator[](const std::string_view k) const
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD;
return safe(impl).ref(k);

View File

@ -161,6 +161,13 @@ public:
//@}
/** @name Movable */
//@{
LLSD(LLSD&& other) noexcept;
void assign(LLSD&& other);
LLSD& operator=(LLSD&& other) noexcept;
//@}
void clear(); ///< resets to Undefined
@ -188,6 +195,11 @@ public:
LLSD(const Date&);
LLSD(const URI&);
LLSD(const Binary&);
LLSD(String&&);
LLSD(UUID&&);
LLSD(Date&&);
LLSD(URI&&);
LLSD(Binary&&);
//@}
/** @name Convenience Constructors */
@ -215,6 +227,11 @@ public:
void assign(const Date&);
void assign(const URI&);
void assign(const Binary&);
void assign(String&&);
void assign(UUID&&);
void assign(Date&&);
void assign(URI&&);
void assign(Binary&&);
LLSD& operator=(Boolean v) { assign(v); return *this; }
LLSD& operator=(Integer v) { assign(v); return *this; }
@ -224,6 +241,11 @@ public:
LLSD& operator=(const Date& v) { assign(v); return *this; }
LLSD& operator=(const URI& v) { assign(v); return *this; }
LLSD& operator=(const Binary& v) { assign(v); return *this; }
LLSD& operator=(String&& v) { assign(std::move(v)); return *this; }
LLSD& operator=(UUID&& v) { assign(std::move(v)); return *this; }
LLSD& operator=(Date&& v) { assign(std::move(v)); return *this; }
LLSD& operator=(URI&& v) { assign(std::move(v)); return *this; }
LLSD& operator=(Binary&& v) { assign(std::move(v)); return *this; }
//@}
/**
@ -306,24 +328,22 @@ public:
//@{
static LLSD emptyMap();
bool has(const String&) const;
LLSD get(const String&) const;
bool has(const std::string_view) const;
LLSD get(const std::string_view) const;
LLSD getKeys() const; // Return an LLSD array with keys as strings
void insert(const String&, const LLSD&);
void insert(std::string_view, const LLSD&);
void erase(const String&);
LLSD& with(const String&, const LLSD&);
LLSD& with(std::string_view, const LLSD&);
LLSD& operator[](const String&);
LLSD& operator[](const std::string_view);
LLSD& operator[](const char* c)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD;
return (*this)[String(c)];
return c ? (*this)[std::string_view(c)] : *this;
}
const LLSD& operator[](const String&) const;
const LLSD& operator[](const std::string_view) const;
const LLSD& operator[](const char* c) const
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD;
return (*this)[String(c)];
return c ? (*this)[std::string_view(c)] : *this;
}
//@}

View File

@ -57,7 +57,7 @@
// U32
LLSD ll_sd_from_U32(const U32 val)
{
std::vector<U8> v;
LLSD::Binary v;
U32 net_order = htonl(val);
v.resize(4);
@ -69,7 +69,7 @@ LLSD ll_sd_from_U32(const U32 val)
U32 ll_U32_from_sd(const LLSD& sd)
{
U32 ret;
std::vector<U8> v = sd.asBinary();
const LLSD::Binary& v = sd.asBinary();
if (v.size() < 4)
{
return 0;
@ -82,7 +82,7 @@ U32 ll_U32_from_sd(const LLSD& sd)
//U64
LLSD ll_sd_from_U64(const U64 val)
{
std::vector<U8> v;
LLSD::Binary v;
U32 high, low;
high = (U32)(val >> 32);
@ -100,7 +100,7 @@ LLSD ll_sd_from_U64(const U64 val)
U64 ll_U64_from_sd(const LLSD& sd)
{
U32 high, low;
std::vector<U8> v = sd.asBinary();
const LLSD::Binary& v = sd.asBinary();
if (v.size() < 8)
{
@ -118,7 +118,7 @@ U64 ll_U64_from_sd(const LLSD& sd)
// IP Address (stored in net order in a U32, so don't need swizzling)
LLSD ll_sd_from_ipaddr(const U32 val)
{
std::vector<U8> v;
LLSD::Binary v;
v.resize(4);
memcpy(&(v[0]), &val, 4); /* Flawfinder: ignore */
@ -129,7 +129,7 @@ LLSD ll_sd_from_ipaddr(const U32 val)
U32 ll_ipaddr_from_sd(const LLSD& sd)
{
U32 ret;
std::vector<U8> v = sd.asBinary();
const LLSD::Binary& v = sd.asBinary();
if (v.size() < 4)
{
return 0;
@ -141,17 +141,17 @@ U32 ll_ipaddr_from_sd(const LLSD& sd)
// Converts an LLSD binary to an LLSD string
LLSD ll_string_from_binary(const LLSD& sd)
{
std::vector<U8> value = sd.asBinary();
const LLSD::Binary& value = sd.asBinary();
std::string str;
str.resize(value.size());
memcpy(&str[0], &value[0], value.size());
memcpy(&str[0], value.data(), value.size());
return str;
}
// Converts an LLSD string to an LLSD binary
LLSD ll_binary_from_string(const LLSD& sd)
{
std::vector<U8> binary_value;
LLSD::Binary binary_value;
std::string string_value = sd.asString();
for (const U8 c : string_value)
@ -996,8 +996,7 @@ LLSD llsd_clone(LLSD value, LLSD filter)
case LLSD::TypeBinary:
{
LLSD::Binary bin(value.asBinary().begin(), value.asBinary().end());
clone = LLSD::Binary(bin);
clone = LLSD::Binary(value.asBinary().begin(), value.asBinary().end());
break;
}
default:

View File

@ -2365,11 +2365,11 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl)
continue;
}
LLSD::Binary pos = mdl[i]["Position"];
LLSD::Binary norm = mdl[i]["Normal"];
LLSD::Binary tangent = mdl[i]["Tangent"];
LLSD::Binary tc = mdl[i]["TexCoord0"];
LLSD::Binary idx = mdl[i]["TriangleList"];
const LLSD::Binary& pos = mdl[i]["Position"].asBinary();
const LLSD::Binary& norm = mdl[i]["Normal"].asBinary();
const LLSD::Binary& tangent = mdl[i]["Tangent"].asBinary();
const LLSD::Binary& tc = mdl[i]["TexCoord0"].asBinary();
const LLSD::Binary& idx = mdl[i]["TriangleList"].asBinary();
//copy out indices
auto num_indices = idx.size() / 2;
@ -2558,7 +2558,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl)
continue;
}
LLSD::Binary weights = mdl[i]["Weights"];
const LLSD::Binary& weights = mdl[i]["Weights"].asBinary();
U32 idx = 0;

View File

@ -523,7 +523,7 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore::
bas >> std::noskipws;
data.assign(std::istream_iterator<U8>(bas), std::istream_iterator<U8>());
result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = data;
result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = std::move(data);
#else
// This is disabled because it's dangerous. See the other case for an

View File

@ -44,7 +44,7 @@ void LLTemplateMessageDispatcher::dispatch(const std::string& msg_name,
const LLSD& message,
LLHTTPNode::ResponsePtr responsep)
{
std::vector<U8> data = message["body"]["binary-template-data"].asBinary();
const LLSD::Binary& data = message["body"]["binary-template-data"].asBinary();
auto size = data.size();
if(size == 0)
{
@ -54,16 +54,20 @@ void LLTemplateMessageDispatcher::dispatch(const std::string& msg_name,
LLHost host;
host = gMessageSystem->getSender();
bool validate_message = mTemplateMessageReader.validateMessage(&(data[0]), static_cast<S32>(size), host, true);
bool validate_message = mTemplateMessageReader.validateMessage(data.data(), static_cast<S32>(size), host, true);
if (validate_message)
{
// <FS:ND> Handle invalid packets by throwing an exception and a graceful continue
// mTemplateMessageReader.readMessage(&(data[0]),host);
try{ mTemplateMessageReader.readMessage(&(data[0]),host); }
catch( nd::exceptions::xran &ex ) { LL_WARNS() << ex.what() << LL_ENDL; }
// mTemplateMessageReader.readMessage(data.data(),host);
try
{
mTemplateMessageReader.readMessage(data.data(),host);
}
catch (nd::exceptions::xran& ex)
{
LL_WARNS() << ex.what() << LL_ENDL;
}
// </FS:ND>
}
else

View File

@ -136,7 +136,7 @@ LLSD LLMaterialID::asLLSD() const
materialIDBinary.resize(MATERIAL_ID_SIZE * sizeof(U8));
memcpy(materialIDBinary.data(), mID, MATERIAL_ID_SIZE * sizeof(U8));
LLSD materialID = materialIDBinary;
LLSD materialID = std::move(materialIDBinary);
return materialID;
}

View File

@ -50,6 +50,7 @@ void check_framebuffer_status()
}
}
bool LLRenderTarget::sInitFailed = false;
bool LLRenderTarget::sUseFBO = false;
U32 LLRenderTarget::sCurFBO = 0;
@ -352,6 +353,9 @@ void LLRenderTarget::release()
LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
llassert(!isBoundInStack());
if (sInitFailed)
return;
if (mDepth)
{
LLImageGL::deleteTextures(1, &mDepth);

View File

@ -61,7 +61,9 @@
class LLRenderTarget
{
public:
//whether or not to use FBO implementation
// Whether app initialization failed
static bool sInitFailed;
// Whether or not to use FBO implementation
static bool sUseFBO;
static U32 sBytesAllocated;
static U32 sCurFBO;

View File

@ -862,7 +862,7 @@ void LLNotification::init(const std::string& template_name, const LLSD& form_ele
for (LLStringUtil::format_map_t::const_iterator iter = default_args.begin();
iter != default_args.end(); ++iter)
{
mSubstitutions[iter->first] = iter->second;
mSubstitutions[std::string(iter->first)] = iter->second;
}
mSubstitutions["_URL"] = getURL();
mSubstitutions["_NAME"] = template_name;

View File

@ -80,8 +80,8 @@ S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type)
}
S32 result = 0;
#if LL_MESA_HEADLESS // !!! *FIX: (?)
LL_WARNS() << "OSMessageBox: " << text << LL_ENDL;
#if LL_MESA_HEADLESS // !!! *FIX: (?)
return OSBTN_OK;
#elif LL_WINDOWS
result = OSMessageBoxWin32(text, caption, type);

View File

@ -2980,7 +2980,7 @@ void FSPanelSearchWeb::loadURL(const SearchQuery &p)
if (!LLGridManager::getInstance()->isInSecondLife())
{
// work out the subdir to use based on the requested category
LLSD subs = LLSD().with("CATEGORY", (mCategoryPaths.has(p.category) ? mCategoryPaths[p.category].asString() : mCategoryPaths["all"].asString()));
LLSD subs = LLSD().with("CATEGORY", (mCategoryPaths.has(p.category()) ? mCategoryPaths[p.category()].asString() : mCategoryPaths["all"].asString()));
}
// add the search query string
@ -3045,7 +3045,7 @@ void FSPanelSearchWeb::loadURL(const SearchQuery &p)
// add the maturity and category variables to the new Second Life search URL
if (LLGridManager::getInstance()->isInSecondLife())
{
url = LFSimFeatureHandler::instance().searchURL() + "&maturity=" + maturity + "&" + mCategoryPaths[p.category].asString();
url = LFSimFeatureHandler::instance().searchURL() + "&maturity=" + maturity + "&" + mCategoryPaths[p.category()].asString();
}
// for OpenSim, do the same as in earlier versions
else

View File

@ -370,24 +370,24 @@ F32 gLogoutMaxTime = LOGOUT_REQUEST_TIME;
S32 gPendingMetricsUploads = 0;
bool gDisconnected = false;
bool gDisconnected = false;
// used to restore texture state after a mode switch
LLFrameTimer gRestoreGLTimer;
bool gRestoreGL = false;
bool gUseWireframe = false;
// Used to restore texture state after a mode switch
LLFrameTimer gRestoreGLTimer;
bool gRestoreGL = false;
bool gUseWireframe = false;
LLMemoryInfo gSysMemory;
U64Bytes gMemoryAllocated(0); // updated in display_stats() in llviewerdisplay.cpp
std::string gLastVersionChannel;
LLVector3 gWindVec(3.0, 3.0, 0.0);
LLVector3 gRelativeWindVec(0.0, 0.0, 0.0);
LLVector3 gWindVec(3.0, 3.0, 0.0);
LLVector3 gRelativeWindVec(0.0, 0.0, 0.0);
U32 gPacketsIn = 0;
U32 gPacketsIn = 0;
bool gPrintMessagesThisFrame = false;
bool gPrintMessagesThisFrame = false;
bool gRandomizeFramerate = false;
bool gPeriodicSlowFrame = false;
@ -806,6 +806,19 @@ public:
bool LLAppViewer::init()
{
struct ResultHandler
{
bool success = false; // Should be set in case of successful result
~ResultHandler()
{
if (!success)
{
// Mark critical flags in case of unsuccessful initialization
LLRenderTarget::sInitFailed = true;
}
}
} result_handler;
setupErrorHandling(mSecondInstance);
nd::octree::debug::setOctreeLogFilename( gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "octree.log" ) ); // <FS:ND/> Filename to log octree options to.
@ -924,7 +937,10 @@ bool LLAppViewer::init()
// inits from settings.xml and from strings.xml
if (!initConfiguration())
{
LL_WARNS("InitInfo") << "initConfiguration() failed." << LL_ENDL;
return false;
}
LL_INFOS("InitInfo") << "Configuration initialized." << LL_ENDL ;
//set the max heap size.
@ -954,14 +970,12 @@ bool LLAppViewer::init()
LLMachineID::init();
if (gSavedSettings.getBOOL("QAModeMetrics"))
{
if (gSavedSettings.getBOOL("QAModeMetrics"))
{
app_metrics_qa_mode = true;
app_metrics_interval = METRICS_INTERVAL_QA;
}
LLViewerAssetStatsFF::init();
app_metrics_qa_mode = true;
app_metrics_interval = METRICS_INTERVAL_QA;
}
LLViewerAssetStatsFF::init();
initThreads();
LL_INFOS("InitInfo") << "Threads initialized." << LL_ENDL ;
@ -1096,8 +1110,9 @@ bool LLAppViewer::init()
// do any necessary set-up for accepting incoming SLURLs from apps
initSLURLHandler();
if(false == initHardwareTest())
if (!initHardwareTest())
{
LL_WARNS("InitInfo") << "initHardwareTest() failed." << LL_ENDL;
// Early out from user choice.
return false;
}
@ -1117,7 +1132,7 @@ bool LLAppViewer::init()
std::ostringstream msg;
msg << LLTrans::getString("MBUnableToAccessFile");
OSMessageBox(msg.str(),LLStringUtil::null,OSMB_OK);
return 0;
return false;
}
LL_INFOS("InitInfo") << "Cache initialization is done." << LL_ENDL ;
@ -1154,8 +1169,9 @@ bool LLAppViewer::init()
// If we don't have the right GL requirements, exit.
if (!gGLManager.mHasRequirements)
{
LL_WARNS("InitInfo") << "gGLManager.mHasRequirements is false." << LL_ENDL;
// already handled with a MBVideoDrvErr
return 0;
return false;
}
// Without SSE2 support we will crash almost immediately, warn here.
@ -1167,11 +1183,11 @@ bool LLAppViewer::init()
LLNotifications::instance().getGlobalString("UnsupportedCPUSSE2"),
LLStringUtil::null,
OSMB_OK);
return 0;
return false;
}
// alert the user if they are using unsupported hardware
if(gSavedSettings.getBOOL("FSUseLegacyUnsupportedHardwareChecks") && !gSavedSettings.getBOOL("AlertedUnsupportedHardware"))
if (gSavedSettings.getBOOL("FSUseLegacyUnsupportedHardwareChecks") && !gSavedSettings.getBOOL("AlertedUnsupportedHardware"))
{
bool unsupported = false;
LLSD args;
@ -1187,19 +1203,19 @@ bool LLAppViewer::init()
U64Bytes minRAM;
minRAMString >> minRAM;
if(!LLFeatureManager::getInstance()->isGPUSupported() && LLFeatureManager::getInstance()->getGPUClass() != GPU_CLASS_UNKNOWN)
if (!LLFeatureManager::getInstance()->isGPUSupported() && LLFeatureManager::getInstance()->getGPUClass() != GPU_CLASS_UNKNOWN)
{
minSpecs += LLNotifications::instance().getGlobalString("UnsupportedGPU");
minSpecs += "\n";
unsupported = true;
}
if(gSysCPU.getMHz() < minCPU)
if (gSysCPU.getMHz() < minCPU)
{
minSpecs += LLNotifications::instance().getGlobalString("UnsupportedCPU");
minSpecs += "\n";
unsupported = true;
}
if(gSysMemory.getPhysicalMemoryKB() < minRAM)
if (gSysMemory.getPhysicalMemoryKB() < minRAM)
{
minSpecs += LLNotifications::instance().getGlobalString("UnsupportedRAM");
minSpecs += "\n";
@ -1211,15 +1227,14 @@ bool LLAppViewer::init()
LLNotificationsUtil::add("UnknownGPU");
}
if(unsupported)
if (unsupported)
{
if(!gSavedSettings.controlExists("WarnUnsupportedHardware")
if (!gSavedSettings.controlExists("WarnUnsupportedHardware")
|| gSavedSettings.getBOOL("WarnUnsupportedHardware"))
{
args["MINSPECS"] = minSpecs;
LLNotificationsUtil::add("UnsupportedHardware", args );
}
}
}
@ -1311,14 +1326,15 @@ bool LLAppViewer::init()
LLViewerJoystick::getInstance()->init(false);
}
try {
try
{
initializeSecHandler();
}
catch (LLProtectedDataException& ex)
{
// <FS:Ansariel> Write exception message to log
LL_WARNS() << "Error initializing SecHandlers: " << ex.what() << LL_ENDL;
LLNotificationsUtil::add("CorruptedProtectedDataStore");
LL_WARNS() << "Error initializing SecHandlers: " << ex.what() << LL_ENDL;
LLNotificationsUtil::add("CorruptedProtectedDataStore");
}
gGLActive = false;
@ -1427,7 +1443,7 @@ bool LLAppViewer::init()
//datetime formatting functions didn't support some parameters such as "weekday".
//Names for days and months localized in xml are also useful for Polish locale(STORM-107).
std::string language = gSavedSettings.getString("Language");
if(language == "ja" || language == "pl")
if (language == "ja" || language == "pl")
{
LLStringOps::setupWeekDaysNames(LLTrans::getString("dateTimeWeekdaysNames"));
LLStringOps::setupWeekDaysShortNames(LLTrans::getString("dateTimeWeekdaysShortNames"));
@ -1493,6 +1509,8 @@ bool LLAppViewer::init()
}
#endif
result_handler.success = true;
return true;
}
@ -2938,7 +2956,7 @@ bool tempSetControl(const std::string& name, const std::string& value)
bool LLAppViewer::initConfiguration()
{
//Load settings files list
// Load settings files list
std::string settings_file_list = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "settings_files.xml");
LLXMLNodePtr root;
bool success = LLXMLNode::parseFile(settings_file_list, root, NULL);
@ -2985,7 +3003,7 @@ bool LLAppViewer::initConfiguration()
// - load defaults
bool set_defaults = true;
if(!loadSettingsFromDirectory("Default", set_defaults))
if (!loadSettingsFromDirectory("Default", set_defaults))
{
OSMessageBox(
"Unable to load default settings file. The installation may be corrupted.",
@ -3014,13 +3032,12 @@ bool LLAppViewer::initConfiguration()
#ifndef LL_RELEASE_FOR_DOWNLOAD
// provide developer build only overrides for these control variables that are not
// persisted to settings.xml
LLControlVariable* c = gSavedSettings.getControl("AllowMultipleViewers");
if (c)
if (LLControlVariable* c = gSavedSettings.getControl("AllowMultipleViewers"))
{
c->setValue(true, false);
}
gSavedSettings.setBOOL("QAMode", true );
gSavedSettings.setBOOL("QAMode", true);
gSavedSettings.setS32("WatchdogEnabled", 0);
#endif
@ -3053,7 +3070,7 @@ bool LLAppViewer::initConfiguration()
clp.configure(cmd_line_config, &gSavedSettings);
if(!initParseCommandLine(clp))
if (!initParseCommandLine(clp))
{
handleCommandLineError(clp);
return false;
@ -3063,7 +3080,7 @@ bool LLAppViewer::initConfiguration()
// If the user has specified a alternate settings file name.
// Load it now before loading the user_settings/settings.xml
if(clp.hasOption("settings"))
if (clp.hasOption("settings"))
{
std::string user_settings_filename =
gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,
@ -3167,7 +3184,7 @@ bool LLAppViewer::initConfiguration()
nd::logging::setThrottleEnabled(gSavedSettings.getBOOL("FSEnableLogThrottle"));
// - apply command line settings
if (! clp.notify())
if (!clp.notify())
{
handleCommandLineError(clp);
return false;
@ -3176,7 +3193,7 @@ bool LLAppViewer::initConfiguration()
// Register the core crash option as soon as we can
// if we want gdb post-mortem on cores we need to be up and running
// ASAP or we might miss init issue etc.
if(gSavedSettings.getBOOL("DisableCrashLogger"))
if (gSavedSettings.getBOOL("DisableCrashLogger"))
{
LL_WARNS() << "Crashes will be handled by system, stack trace logs and crash logger are both disabled" << LL_ENDL;
disableCrashlogger();
@ -3190,7 +3207,7 @@ bool LLAppViewer::initConfiguration()
initConsole();
}
if(clp.hasOption("help"))
if (clp.hasOption("help"))
{
std::ostringstream msg;
msg << LLTrans::getString("MBCmdLineUsg") << "\n" << clp;
@ -3204,17 +3221,17 @@ bool LLAppViewer::initConfiguration()
return false;
}
if(clp.hasOption("set"))
if (clp.hasOption("set"))
{
const LLCommandLineParser::token_vector_t& set_values = clp.getOption("set");
if(0x1 & set_values.size())
if (0x1 & set_values.size())
{
LL_WARNS() << "Invalid '--set' parameter count." << LL_ENDL;
}
else
{
LLCommandLineParser::token_vector_t::const_iterator itr = set_values.begin();
for(; itr != set_values.end(); ++itr)
for (; itr != set_values.end(); ++itr)
{
const std::string& name = *itr;
const std::string& value = *(++itr);
@ -3226,12 +3243,13 @@ bool LLAppViewer::initConfiguration()
}
}
if (clp.hasOption("logevents")) {
if (clp.hasOption("logevents"))
{
LLViewerEventRecorder::instance().setEventLoggingOn();
}
std::string CmdLineChannel(gSavedSettings.getString("CmdLineChannel"));
if(! CmdLineChannel.empty())
if (!CmdLineChannel.empty())
{
LLVersionInfo::instance().resetChannel(CmdLineChannel);
}
@ -3246,7 +3264,7 @@ bool LLAppViewer::initConfiguration()
}
std::string test_name(gSavedSettings.getString("LogMetrics"));
if (! test_name.empty())
if (!test_name.empty())
{
LLTrace::BlockTimer::sMetricLog = true;
// '--logmetrics' is specified with a named test metric argument so the data gathering is done only on that test
@ -3303,7 +3321,7 @@ bool LLAppViewer::initConfiguration()
// </FS:TT>
const LLControlVariable* skinfolder = gSavedSettings.getControl("SkinCurrent");
if(skinfolder && LLStringUtil::null != skinfolder->getValue().asString())
if (skinfolder && LLStringUtil::null != skinfolder->getValue().asString())
{
// Examining "Language" may not suffice -- see LLUI::getLanguage()
// logic. Unfortunately LLUI::getLanguage() doesn't yet do us much
@ -3343,7 +3361,6 @@ bool LLAppViewer::initConfiguration()
llassert_always(!gSavedSettings.getBOOL("SLURLPassToOtherInstance"));
}
// Handle slurl use. NOTE: Don't let SL-55321 reappear.
// This initial-SLURL logic, up through the call to
// sendURLToOtherInstance(), must precede LLSplashScreen::show() --
@ -3369,14 +3386,14 @@ bool LLAppViewer::initConfiguration()
std::string starting_location;
std::string cmd_line_login_location(gSavedSettings.getString("CmdLineLoginLocation"));
if(! cmd_line_login_location.empty())
if (!cmd_line_login_location.empty())
{
starting_location = cmd_line_login_location;
}
else
{
std::string default_login_location(gSavedSettings.getString("DefaultLoginLocation"));
if (! default_login_location.empty())
if (!default_login_location.empty())
{
starting_location = default_login_location;
}
@ -3387,7 +3404,7 @@ bool LLAppViewer::initConfiguration()
// (currently at the top of startup STATE_AUDIO_INIT,
// but rather it belongs into the gridmanager)
LLSLURL start_slurl;
if (! starting_location.empty())
if (!starting_location.empty())
{
start_slurl = starting_location;
// <FS:Ansariel> FIRE-11586: Restore grid manager workaround (grid is still empty here!)
@ -3403,12 +3420,12 @@ bool LLAppViewer::initConfiguration()
// NextLoginLocation is set as a side effect of LLStartUp::setStartSLURL()
std::string nextLoginLocation = gSavedSettings.getString( "NextLoginLocation" );
if ( !nextLoginLocation.empty() )
if (!nextLoginLocation.empty())
{
LL_DEBUGS("AppInit")<<"set start from NextLoginLocation: "<<nextLoginLocation<<LL_ENDL;
LLStartUp::setStartSLURL(LLSLURL(nextLoginLocation));
}
else if ( ( clp.hasOption("login") || clp.hasOption("autologin"))
else if ((clp.hasOption("login") || clp.hasOption("autologin"))
&& gSavedSettings.getString("CmdLineLoginLocation").empty())
{
// If automatic login from command line with --login switch
@ -3481,7 +3498,7 @@ bool LLAppViewer::initConfiguration()
#endif
if (!gArgs.empty())
{
gWindowTitle += std::string(" ") + gArgs;
gWindowTitle += std::string(" ") + gArgs;
}
LLStringUtil::truncate(gWindowTitle, 255);
@ -3505,7 +3522,7 @@ bool LLAppViewer::initConfiguration()
// // This is the second instance of SL. Mute voice,
// // but make sure the setting is *not* persisted.
// LLControlVariable* enable_voice = gSavedSettings.getControl("EnableVoiceChat");
// if(enable_voice)
// if (enable_voice)
// {
// const bool DO_NOT_PERSIST = false;
// enable_voice->setValue(LLSD(false), DO_NOT_PERSIST);
@ -3744,8 +3761,8 @@ bool LLAppViewer::initWindow()
gSavedSettings.setBOOL("RenderInitError", false);
gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), true );
//If we have a startup crash, it's usually near GL initialization, so simulate that.
if(gCrashOnStartup)
// If we have a startup crash, it's usually near GL initialization, so simulate that.
if (gCrashOnStartup)
{
LLAppViewer::instance()->forceErrorLLError();
}
@ -4754,11 +4771,11 @@ void LLAppViewer::requestQuit()
LLViewerRegion* region = gAgent.getRegion();
if( (LLStartUp::getStartupState() < STATE_STARTED) || !region )
if ((LLStartUp::getStartupState() < STATE_STARTED) || !region)
{
// If we have a region, make some attempt to send a logout request first.
// This prevents the halfway-logged-in avatar from hanging around inworld for a couple minutes.
if(region)
if (region)
{
sendLogoutRequest();
}
@ -5922,9 +5939,6 @@ void LLAppViewer::idleShutdown()
return;
}
// ProductEngine: Try moving this code to where we shut down sTextureCache in cleanup()
// *TODO: ugly
static bool saved_teleport_history = false;
@ -5973,7 +5987,7 @@ void LLAppViewer::idleShutdown()
}
// All floaters are closed. Tell server we want to quit.
if( !logoutRequestSent() )
if (!logoutRequestSent())
{
sendLogoutRequest();
@ -5985,8 +5999,8 @@ void LLAppViewer::idleShutdown()
}
// Make sure that we quit if we haven't received a reply from the server.
if( logoutRequestSent()
&& gLogoutTimer.getElapsedTimeF32() > gLogoutMaxTime )
if (logoutRequestSent()
&& gLogoutTimer.getElapsedTimeF32() > gLogoutMaxTime)
{
forceQuit();
return;

View File

@ -283,7 +283,7 @@ bool create_app_mutex()
LPCWSTR unique_mutex_name = L"SecondLifeAppMutex";
HANDLE hMutex;
hMutex = CreateMutex(NULL, TRUE, unique_mutex_name);
if(GetLastError() == ERROR_ALREADY_EXISTS)
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
result = false;
}
@ -508,7 +508,7 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
gDebugInfo["FoundOtherInstanceAtStartup"] = LLSD::Boolean(found_other_instance);
bool ok = viewer_app_ptr->init();
if(!ok)
if (!ok)
{
LL_WARNS() << "Application init failed." << LL_ENDL;
return -1;