summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yaml4
-rw-r--r--indra/CMakeLists.txt3
-rw-r--r--indra/llappearance/lltexlayerparams.h1
-rw-r--r--indra/llcommon/CMakeLists.txt1
-rw-r--r--indra/llcommon/fsyspath.h56
-rw-r--r--indra/llcommon/llerror.h5
-rw-r--r--indra/llcommon/llkeybind.cpp16
-rwxr-xr-xindra/llcommon/llpointer.cpp26
-rw-r--r--indra/llcommon/llpointer.h280
-rw-r--r--indra/llcommon/llqueuedthread.cpp4
-rw-r--r--indra/llcommon/lua_function.cpp8
-rwxr-xr-xindra/llcommon/owning_ptr.h71
-rw-r--r--indra/llimage/llimage.h5
-rw-r--r--indra/llimagej2coj/llimagej2coj.cpp139
-rw-r--r--indra/llmath/llinterp.h4
-rw-r--r--indra/llmath/llmath.h7
-rw-r--r--indra/llmath/llvolume.cpp22
-rw-r--r--indra/llmath/llvolumemgr.cpp1
-rw-r--r--indra/llmath/raytrace.cpp2
-rw-r--r--indra/llrender/llimagegl.cpp2
-rw-r--r--indra/llui/llluafloater.cpp4
-rw-r--r--indra/llui/llnotifications.h1
-rw-r--r--indra/llwindow/llwindowmacosx.cpp8
-rw-r--r--indra/newview/gltfscenemanager.cpp2
-rw-r--r--indra/newview/llcylinder.cpp2
-rw-r--r--indra/newview/llluamanager.cpp8
-rw-r--r--indra/newview/llmeshrepository.cpp6
-rw-r--r--indra/newview/llmeshrepository.h4
-rw-r--r--indra/newview/llpanelemojicomplete.cpp2
-rw-r--r--indra/newview/llpanelprimmediacontrols.cpp2
-rw-r--r--indra/newview/llsky.cpp2
-rw-r--r--indra/newview/llsprite.cpp2
-rw-r--r--indra/newview/lltexturefetch.cpp6
-rw-r--r--indra/newview/llviewermedia.cpp4
-rw-r--r--indra/newview/llviewerwindow.cpp2
-rw-r--r--indra/newview/llvoicewebrtc.cpp20
-rw-r--r--indra/newview/llwatchdog.cpp1
-rw-r--r--indra/newview/llworldmipmap.cpp2
-rw-r--r--indra/newview/tests/llluamanager_test.cpp6
-rw-r--r--indra/viewer_components/login/lllogin.cpp3
40 files changed, 324 insertions, 420 deletions
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index fda6545e83..550dedb875 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -73,7 +73,7 @@ jobs:
# autobuild-package.xml.
AUTOBUILD_VCS_INFO: "true"
AUTOBUILD_VSVER: "170"
- DEVELOPER_DIR: "/Applications/Xcode_14.3.1.app/Contents/Developer"
+ DEVELOPER_DIR: "/Applications/Xcode_16.0.app/Contents/Developer"
# Ensure that Linden viewer builds engage Bugsplat.
BUGSPLAT_DB: ${{ needs.setup.outputs.bugsplat_db }}
build_coverity: false
@@ -251,7 +251,7 @@ jobs:
export viewer_channel="Second Life Test"
fi
fi
- echo "viewer_channel=$viewer_channel"
+ echo "::notice::$RUNNER_OS viewer_channel=$viewer_channel"
echo "viewer_channel=$viewer_channel" >> "$GITHUB_OUTPUT"
# On windows we need to point the build to the correct python
# as neither CMake's FindPython nor our custom Python.cmake module
diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt
index 3be8ebafa8..62ed631e06 100644
--- a/indra/CMakeLists.txt
+++ b/indra/CMakeLists.txt
@@ -29,6 +29,9 @@ else()
set( USE_AUTOBUILD_3P ON )
endif()
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
include(Variables)
include(BuildVersion)
diff --git a/indra/llappearance/lltexlayerparams.h b/indra/llappearance/lltexlayerparams.h
index 5e785e4f3e..116eb3bee0 100644
--- a/indra/llappearance/lltexlayerparams.h
+++ b/indra/llappearance/lltexlayerparams.h
@@ -30,6 +30,7 @@
#include "llpointer.h"
#include "v4color.h"
#include "llviewervisualparam.h"
+#include <atomic>
class LLAvatarAppearance;
class LLImageRaw;
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index 78bfaade55..aa8810f00b 100644
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -70,6 +70,7 @@ set(llcommon_SOURCE_FILES
llmetrics.cpp
llmortician.cpp
llmutex.cpp
+ llpointer.cpp
llpredicate.cpp
llprocess.cpp
llprocessor.cpp
diff --git a/indra/llcommon/fsyspath.h b/indra/llcommon/fsyspath.h
index 1b4aec09b4..f66970ed8f 100644
--- a/indra/llcommon/fsyspath.h
+++ b/indra/llcommon/fsyspath.h
@@ -12,7 +12,10 @@
#if ! defined(LL_FSYSPATH_H)
#define LL_FSYSPATH_H
+#include <boost/iterator/transform_iterator.hpp>
#include <filesystem>
+#include <string>
+#include <string_view>
// While std::filesystem::path can be directly constructed from std::string on
// both Posix and Windows, that's not what we want on Windows. Per
@@ -33,42 +36,55 @@
// char"), the "native narrow encoding" isn't UTF-8, so file paths containing
// non-ASCII characters get mangled.
//
-// Once we're building with C++20, we could pass a UTF-8 std::string through a
-// vector<char8_t> to engage std::filesystem::path's own UTF-8 conversion. But
-// sigh, as of 2024-04-03 we're not yet there.
-//
-// Anyway, encapsulating the important UTF-8 conversions in our own subclass
-// allows us to migrate forward to C++20 conventions without changing
-// referencing code.
+// Encapsulating the important UTF-8 conversions in our own subclass allows us
+// to migrate forward to C++20 conventions without changing referencing code.
class fsyspath: public std::filesystem::path
{
using super = std::filesystem::path;
+ // In C++20 (__cpp_lib_char8_t), std::filesystem::u8path() is deprecated.
+ // std::filesystem::path(iter, iter) performs UTF-8 conversions when the
+ // value_type of the iterators is char8_t. While we could copy into a
+ // temporary std::u8string and from there into std::filesystem::path, to
+ // minimize string copying we'll define a transform_iterator that accepts
+ // a std::string_view::iterator and dereferences to char8_t.
+ struct u8ify
+ {
+ char8_t operator()(char c) const { return char8_t(c); }
+ };
+ using u8iter = boost::transform_iterator<u8ify, std::string_view::iterator>;
+
public:
// default
fsyspath() {}
- // construct from UTF-8 encoded std::string
- fsyspath(const std::string& path): super(std::filesystem::u8path(path)) {}
- // construct from UTF-8 encoded const char*
- fsyspath(const char* path): super(std::filesystem::u8path(path)) {}
+ // construct from UTF-8 encoded string
+ fsyspath(const std::string& path): fsyspath(std::string_view(path)) {}
+ fsyspath(const char* path): fsyspath(std::string_view(path)) {}
+ fsyspath(std::string_view path):
+ super(u8iter(path.begin(), u8ify()), u8iter(path.end(), u8ify()))
+ {}
// construct from existing path
fsyspath(const super& path): super(path) {}
- fsyspath& operator=(const super& p) { super::operator=(p); return *this; }
- fsyspath& operator=(const std::string& p)
- {
- super::operator=(std::filesystem::u8path(p));
- return *this;
- }
- fsyspath& operator=(const char* p)
+ fsyspath& operator=(const super& p) { super::operator=(p); return *this; }
+ fsyspath& operator=(const std::string& p) { return (*this) = std::string_view(p); }
+ fsyspath& operator=(const char* p) { return (*this) = std::string_view(p); }
+ fsyspath& operator=(std::string_view p)
{
- super::operator=(std::filesystem::u8path(p));
+ assign(u8iter(p.begin(), u8ify()), u8iter(p.end(), u8ify()));
return *this;
}
// shadow base-class string() method with UTF-8 aware method
- std::string string() const { return super::u8string(); }
+ std::string string() const
+ {
+ // Short of forbidden type punning, I see no way to avoid copying this
+ // std::u8string to a std::string.
+ auto u8str{ super::u8string() };
+ // from https://github.com/tahonermann/char8_t-remediation/blob/master/char8_t-remediation.h#L180-L182
+ return { u8str.begin(), u8str.end() };
+ }
// On Posix systems, where value_type is already char, this operator
// std::string() method shadows the base class operator string_type()
// method. But on Windows, where value_type is wchar_t, the base class
diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h
index b17b9ff21e..b6d560a121 100644
--- a/indra/llcommon/llerror.h
+++ b/indra/llcommon/llerror.h
@@ -239,17 +239,12 @@ namespace LLError
~CallSite();
-#ifdef LL_LIBRARY_INCLUDE
- bool shouldLog();
-#else // LL_LIBRARY_INCLUDE
bool shouldLog()
{
return mCached
? mShouldLog
: Log::shouldLog(*this);
}
- // this member function needs to be in-line for efficiency
-#endif // LL_LIBRARY_INCLUDE
void invalidate();
diff --git a/indra/llcommon/llkeybind.cpp b/indra/llcommon/llkeybind.cpp
index 83c53d220d..73a207504e 100644
--- a/indra/llcommon/llkeybind.cpp
+++ b/indra/llcommon/llkeybind.cpp
@@ -125,20 +125,16 @@ LLKeyData& LLKeyData::operator=(const LLKeyData& rhs)
bool LLKeyData::operator==(const LLKeyData& rhs) const
{
- if (mMouse != rhs.mMouse) return false;
- if (mKey != rhs.mKey) return false;
- if (mMask != rhs.mMask) return false;
- if (mIgnoreMasks != rhs.mIgnoreMasks) return false;
- return true;
+ return
+ (mMouse == rhs.mMouse) &&
+ (mKey == rhs.mKey) &&
+ (mMask == rhs.mMask) &&
+ (mIgnoreMasks == rhs.mIgnoreMasks);
}
bool LLKeyData::operator!=(const LLKeyData& rhs) const
{
- if (mMouse != rhs.mMouse) return true;
- if (mKey != rhs.mKey) return true;
- if (mMask != rhs.mMask) return true;
- if (mIgnoreMasks != rhs.mIgnoreMasks) return true;
- return false;
+ return ! (*this == rhs);
}
bool LLKeyData::canHandle(const LLKeyData& data) const
diff --git a/indra/llcommon/llpointer.cpp b/indra/llcommon/llpointer.cpp
new file mode 100755
index 0000000000..adea447caa
--- /dev/null
+++ b/indra/llcommon/llpointer.cpp
@@ -0,0 +1,26 @@
+/**
+ * @file llpointer.cpp
+ * @author Nat Goodspeed
+ * @date 2024-09-26
+ * @brief Implementation for llpointer.
+ *
+ * $LicenseInfo:firstyear=2024&license=viewerlgpl$
+ * Copyright (c) 2024, Linden Research, Inc.
+ * $/LicenseInfo$
+ */
+
+// Precompiled header
+#include "linden_common.h"
+// associated header
+#include "llpointer.h"
+// STL headers
+// std headers
+// external library headers
+// other Linden headers
+#include "llerror.h"
+
+void LLPointerBase::wild_dtor(std::string_view msg)
+{
+// LL_WARNS() << msg << LL_ENDL;
+ llassert_msg(false, msg);
+}
diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h
index 048547e4cc..b53cfcdd1a 100644
--- a/indra/llcommon/llpointer.h
+++ b/indra/llcommon/llpointer.h
@@ -26,8 +26,9 @@
#ifndef LLPOINTER_H
#define LLPOINTER_H
-#include "llerror.h" // *TODO: consider eliminating this
-#include "llmutex.h"
+#include <boost/functional/hash.hpp>
+#include <string_view>
+#include <utility> // std::swap()
//----------------------------------------------------------------------------
// RefCount objects should generally only be accessed by way of LLPointer<>'s
@@ -42,8 +43,18 @@
//----------------------------------------------------------------------------
+class LLPointerBase
+{
+protected:
+ // alert the coder that a referenced type's destructor did something very
+ // strange -- this is in a non-template base class so we can hide the
+ // implementation in llpointer.cpp
+ static void wild_dtor(std::string_view msg);
+};
+
// Note: relies on Type having ref() and unref() methods
-template <class Type> class LLPointer
+template <class Type>
+class LLPointer: public LLPointerBase
{
public:
template<typename Subclass>
@@ -60,6 +71,13 @@ public:
ref();
}
+ // Even though the template constructors below accepting
+ // (const LLPointer<Subclass>&) and (LLPointer<Subclass>&&) appear to
+ // subsume these specific (const LLPointer<Type>&) and (LLPointer<Type>&&)
+ // constructors, the compiler recognizes these as The Copy Constructor and
+ // The Move Constructor, respectively. In other words, even in the
+ // presence of the LLPointer<Subclass> constructors, we still must specify
+ // the LLPointer<Type> constructors.
LLPointer(const LLPointer<Type>& ptr) :
mPointer(ptr.mPointer)
{
@@ -98,39 +116,52 @@ public:
const Type& operator*() const { return *mPointer; }
Type& operator*() { return *mPointer; }
- operator BOOL() const { return (mPointer != nullptr); }
operator bool() const { return (mPointer != nullptr); }
bool operator!() const { return (mPointer == nullptr); }
bool isNull() const { return (mPointer == nullptr); }
bool notNull() const { return (mPointer != nullptr); }
operator Type*() const { return mPointer; }
- bool operator !=(Type* ptr) const { return (mPointer != ptr); }
- bool operator ==(Type* ptr) const { return (mPointer == ptr); }
- bool operator ==(const LLPointer<Type>& ptr) const { return (mPointer == ptr.mPointer); }
- bool operator < (const LLPointer<Type>& ptr) const { return (mPointer < ptr.mPointer); }
- bool operator > (const LLPointer<Type>& ptr) const { return (mPointer > ptr.mPointer); }
+ template <typename Type1>
+ bool operator !=(Type1* ptr) const { return (mPointer != ptr); }
+ template <typename Type1>
+ bool operator ==(Type1* ptr) const { return (mPointer == ptr); }
+ template <typename Type1>
+ bool operator !=(const LLPointer<Type1>& ptr) const { return (mPointer != ptr.mPointer); }
+ template <typename Type1>
+ bool operator ==(const LLPointer<Type1>& ptr) const { return (mPointer == ptr.mPointer); }
+ bool operator < (const LLPointer<Type>& ptr) const { return (mPointer < ptr.mPointer); }
+ bool operator > (const LLPointer<Type>& ptr) const { return (mPointer > ptr.mPointer); }
LLPointer<Type>& operator =(Type* ptr)
{
- assign(ptr);
+ // copy-and-swap idiom, see http://gotw.ca/gotw/059.htm
+ LLPointer temp(ptr);
+ using std::swap; // per Swappable convention
+ swap(*this, temp);
return *this;
}
+ // Even though the template assignment operators below accepting
+ // (const LLPointer<Subclass>&) and (LLPointer<Subclass>&&) appear to
+ // subsume these specific (const LLPointer<Type>&) and (LLPointer<Type>&&)
+ // assignment operators, the compiler recognizes these as Copy Assignment
+ // and Move Assignment, respectively. In other words, even in the presence
+ // of the LLPointer<Subclass> assignment operators, we still must specify
+ // the LLPointer<Type> operators.
LLPointer<Type>& operator =(const LLPointer<Type>& ptr)
{
- assign(ptr);
+ LLPointer temp(ptr);
+ using std::swap; // per Swappable convention
+ swap(*this, temp);
return *this;
}
LLPointer<Type>& operator =(LLPointer<Type>&& ptr)
{
- if (mPointer != ptr.mPointer)
- {
- unref();
- mPointer = ptr.mPointer;
- ptr.mPointer = nullptr;
- }
+ LLPointer temp(std::move(ptr));
+ using std::swap; // per Swappable convention
+ swap(*this, temp);
return *this;
}
@@ -138,210 +169,35 @@ public:
template<typename Subclass>
LLPointer<Type>& operator =(const LLPointer<Subclass>& ptr)
{
- assign(ptr.get());
+ LLPointer temp(ptr);
+ using std::swap; // per Swappable convention
+ swap(*this, temp);
return *this;
}
template<typename Subclass>
LLPointer<Type>& operator =(LLPointer<Subclass>&& ptr)
{
- if (mPointer != ptr.mPointer)
- {
- unref();
- mPointer = ptr.mPointer;
- ptr.mPointer = nullptr;
- }
+ LLPointer temp(std::move(ptr));
+ using std::swap; // per Swappable convention
+ swap(*this, temp);
return *this;
}
// Just exchange the pointers, which will not change the reference counts.
static void swap(LLPointer<Type>& a, LLPointer<Type>& b)
{
- Type* temp = a.mPointer;
- a.mPointer = b.mPointer;
- b.mPointer = temp;
- }
-
-protected:
-#ifdef LL_LIBRARY_INCLUDE
- void ref();
- void unref();
-#else
- void ref()
- {
- if (mPointer)
- {
- mPointer->ref();
- }
- }
-
- void unref()
- {
- if (mPointer)
- {
- Type *temp = mPointer;
- mPointer = nullptr;
- temp->unref();
- if (mPointer != nullptr)
- {
- LL_WARNS() << "Unreference did assignment to non-NULL because of destructor" << LL_ENDL;
- unref();
- }
- }
- }
-#endif // LL_LIBRARY_INCLUDE
-
- void assign(const LLPointer<Type>& ptr)
- {
- if (mPointer != ptr.mPointer)
- {
- unref();
- mPointer = ptr.mPointer;
- ref();
- }
- }
-
-protected:
- Type* mPointer;
-};
-
-template <class Type> class LLConstPointer
-{
- template<typename Subclass>
- friend class LLConstPointer;
-public:
- LLConstPointer() :
- mPointer(nullptr)
- {
- }
-
- LLConstPointer(const Type* ptr) :
- mPointer(ptr)
- {
- ref();
- }
-
- LLConstPointer(const LLConstPointer<Type>& ptr) :
- mPointer(ptr.mPointer)
- {
- ref();
- }
-
- LLConstPointer(LLConstPointer<Type>&& ptr) noexcept
- {
- mPointer = ptr.mPointer;
- ptr.mPointer = nullptr;
- }
-
- // support conversion up the type hierarchy. See Item 45 in Effective C++, 3rd Ed.
- template<typename Subclass>
- LLConstPointer(const LLConstPointer<Subclass>& ptr) :
- mPointer(ptr.get())
- {
- ref();
- }
-
- template<typename Subclass>
- LLConstPointer(LLConstPointer<Subclass>&& ptr) noexcept :
- mPointer(ptr.get())
- {
- ptr.mPointer = nullptr;
- }
-
- ~LLConstPointer()
- {
- unref();
- }
-
- const Type* get() const { return mPointer; }
- const Type* operator->() const { return mPointer; }
- const Type& operator*() const { return *mPointer; }
-
- operator BOOL() const { return (mPointer != nullptr); }
- operator bool() const { return (mPointer != nullptr); }
- bool operator!() const { return (mPointer == nullptr); }
- bool isNull() const { return (mPointer == nullptr); }
- bool notNull() const { return (mPointer != nullptr); }
-
- operator const Type*() const { return mPointer; }
- bool operator !=(const Type* ptr) const { return (mPointer != ptr); }
- bool operator ==(const Type* ptr) const { return (mPointer == ptr); }
- bool operator ==(const LLConstPointer<Type>& ptr) const { return (mPointer == ptr.mPointer); }
- bool operator < (const LLConstPointer<Type>& ptr) const { return (mPointer < ptr.mPointer); }
- bool operator > (const LLConstPointer<Type>& ptr) const { return (mPointer > ptr.mPointer); }
-
- LLConstPointer<Type>& operator =(const Type* ptr)
- {
- if( mPointer != ptr )
- {
- unref();
- mPointer = ptr;
- ref();
- }
-
- return *this;
- }
-
- LLConstPointer<Type>& operator =(const LLConstPointer<Type>& ptr)
- {
- if( mPointer != ptr.mPointer )
- {
- unref();
- mPointer = ptr.mPointer;
- ref();
- }
- return *this;
- }
-
- LLConstPointer<Type>& operator =(LLConstPointer<Type>&& ptr)
- {
- if (mPointer != ptr.mPointer)
- {
- unref();
- mPointer = ptr.mPointer;
- ptr.mPointer = nullptr;
- }
- return *this;
- }
-
- // support assignment up the type hierarchy. See Item 45 in Effective C++, 3rd Ed.
- template<typename Subclass>
- LLConstPointer<Type>& operator =(const LLConstPointer<Subclass>& ptr)
- {
- if( mPointer != ptr.get() )
- {
- unref();
- mPointer = ptr.get();
- ref();
- }
- return *this;
- }
-
- template<typename Subclass>
- LLConstPointer<Type>& operator =(LLConstPointer<Subclass>&& ptr)
- {
- if (mPointer != ptr.mPointer)
- {
- unref();
- mPointer = ptr.mPointer;
- ptr.mPointer = nullptr;
- }
- return *this;
+ using std::swap; // per Swappable convention
+ swap(a.mPointer, b.mPointer);
}
- // Just exchange the pointers, which will not change the reference counts.
- static void swap(LLConstPointer<Type>& a, LLConstPointer<Type>& b)
+ // Put swap() overload in the global namespace, per Swappable convention
+ friend void swap(LLPointer<Type>& a, LLPointer<Type>& b)
{
- const Type* temp = a.mPointer;
- a.mPointer = b.mPointer;
- b.mPointer = temp;
+ LLPointer<Type>::swap(a, b);
}
protected:
-#ifdef LL_LIBRARY_INCLUDE
- void ref();
- void unref();
-#else // LL_LIBRARY_INCLUDE
void ref()
{
if (mPointer)
@@ -354,22 +210,24 @@ protected:
{
if (mPointer)
{
- const Type *temp = mPointer;
+ Type *temp = mPointer;
mPointer = nullptr;
temp->unref();
if (mPointer != nullptr)
{
- LL_WARNS() << "Unreference did assignment to non-NULL because of destructor" << LL_ENDL;
+ wild_dtor("Unreference did assignment to non-NULL because of destructor");
unref();
}
}
}
-#endif // LL_LIBRARY_INCLUDE
protected:
- const Type* mPointer;
+ Type* mPointer;
};
+template <typename Type>
+using LLConstPointer = LLPointer<const Type>;
+
template<typename Type>
class LLCopyOnWritePointer : public LLPointer<Type>
{
@@ -418,14 +276,14 @@ private:
bool mStayUnique;
};
-template<typename Type>
-bool operator!=(Type* lhs, const LLPointer<Type>& rhs)
+template<typename Type0, typename Type1>
+bool operator!=(Type0* lhs, const LLPointer<Type1>& rhs)
{
return (lhs != rhs.get());
}
-template<typename Type>
-bool operator==(Type* lhs, const LLPointer<Type>& rhs)
+template<typename Type0, typename Type1>
+bool operator==(Type0* lhs, const LLPointer<Type1>& rhs)
{
return (lhs == rhs.get());
}
diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp
index 1c4ac5a7bf..0196a24b18 100644
--- a/indra/llcommon/llqueuedthread.cpp
+++ b/indra/llcommon/llqueuedthread.cpp
@@ -146,7 +146,7 @@ size_t LLQueuedThread::updateQueue(F32 max_time_ms)
// schedule a call to threadedUpdate for every call to updateQueue
if (!isQuitting())
{
- mRequestQueue.post([=]()
+ mRequestQueue.post([=, this]()
{
LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qt - update");
mIdleThread = false;
@@ -474,7 +474,7 @@ void LLQueuedThread::processRequest(LLQueuedThread::QueuedRequest* req)
#else
using namespace std::chrono_literals;
auto retry_time = LL::WorkQueue::TimePoint::clock::now() + 16ms;
- mRequestQueue.post([=]
+ mRequestQueue.post([=, this]
{
LL_PROFILE_ZONE_NAMED("processRequest - retry");
if (LL::WorkQueue::TimePoint::clock::now() < retry_time)
diff --git a/indra/llcommon/lua_function.cpp b/indra/llcommon/lua_function.cpp
index 33666964f7..21a663a003 100644
--- a/indra/llcommon/lua_function.cpp
+++ b/indra/llcommon/lua_function.cpp
@@ -170,7 +170,7 @@ fsyspath source_path(lua_State* L)
{
lua_getinfo(L, i, "s", &ar);
}
- return ar.source;
+ return { ar.source };
}
} // namespace lluau
@@ -1108,7 +1108,7 @@ lua_function(source_path, "source_path(): return the source path of the running
{
lua_checkdelta(L, 1);
lluau_checkstack(L, 1);
- lua_pushstdstring(L, lluau::source_path(L).u8string());
+ lua_pushstdstring(L, lluau::source_path(L));
return 1;
}
@@ -1119,7 +1119,7 @@ lua_function(source_dir, "source_dir(): return the source directory of the runni
{
lua_checkdelta(L, 1);
lluau_checkstack(L, 1);
- lua_pushstdstring(L, lluau::source_path(L).parent_path().u8string());
+ lua_pushstdstring(L, fsyspath(lluau::source_path(L).parent_path()));
return 1;
}
@@ -1132,7 +1132,7 @@ lua_function(abspath, "abspath(path): "
lua_checkdelta(L);
auto path{ lua_tostdstring(L, 1) };
lua_pop(L, 1);
- lua_pushstdstring(L, (lluau::source_path(L).parent_path() / path).u8string());
+ lua_pushstdstring(L, fsyspath(lluau::source_path(L).parent_path() / path));
return 1;
}
diff --git a/indra/llcommon/owning_ptr.h b/indra/llcommon/owning_ptr.h
new file mode 100755
index 0000000000..7cf8d3f0ba
--- /dev/null
+++ b/indra/llcommon/owning_ptr.h
@@ -0,0 +1,71 @@
+/**
+ * @file owning_ptr.h
+ * @author Nat Goodspeed
+ * @date 2024-09-27
+ * @brief owning_ptr<T> is like std::unique_ptr<T>, but easier to integrate
+ *
+ * $LicenseInfo:firstyear=2024&license=viewerlgpl$
+ * Copyright (c) 2024, Linden Research, Inc.
+ * $/LicenseInfo$
+ */
+
+#if ! defined(LL_OWNING_PTR_H)
+#define LL_OWNING_PTR_H
+
+#include <functional>
+#include <memory>
+
+/**
+ * owning_ptr<T> adapts std::unique_ptr<T> to make it easier to adopt into
+ * older code using dumb pointers.
+ *
+ * Consider a class Outer with a member Thing* mThing. After the constructor,
+ * each time a method wants to assign to mThing, it must test for nullptr and
+ * destroy the previous Thing instance. During Outer's lifetime, mThing is
+ * passed to legacy domain-specific functions accepting plain Thing*. Finally
+ * the destructor must again test for nullptr and destroy the remaining Thing
+ * instance.
+ *
+ * Multiply that by several different Outer members of different types,
+ * possibly with different domain-specific destructor functions.
+ *
+ * Dropping std::unique_ptr<Thing> into Outer is cumbersome for a several
+ * reasons. First, if Thing requires a domain-specific destructor function,
+ * the unique_ptr declaration of mThing must explicitly state the type of that
+ * function (as a function pointer, for a typical legacy function). Second,
+ * every Thing* assignment to mThing must be changed to mThing.reset(). Third,
+ * every time we call a legacy domain-specific function, we must pass
+ * mThing.get().
+ *
+ * owning_ptr<T> is designed to drop into a situation like this. The domain-
+ * specific destructor function, if any, is passed to its constructor; it need
+ * not be encoded into the pointer type. owning_ptr<T> supports plain pointer
+ * assignment, internally calling std::unique_ptr<T>::reset(). It also
+ * supports implicit conversion to plain T*, to pass the owned pointer to
+ * legacy domain-specific functions.
+ *
+ * Obviously owning_ptr<T> must not be used in situations where ownership of
+ * the referenced object is passed on to another pointer: use std::unique_ptr
+ * for that. Similarly, it is not for shared ownership. It simplifies lifetime
+ * management for classes that currently store (and explicitly destroy) plain
+ * T* pointers.
+ */
+template <typename T>
+class owning_ptr
+{
+ using deleter = std::function<void(T*)>;
+public:
+ owning_ptr(T* p=nullptr, const deleter& d=std::default_delete<T>()):
+ mPtr(p, d)
+ {}
+ void reset(T* p=nullptr) { mPtr.reset(p); }
+ owning_ptr& operator=(T* p) { mPtr.reset(p); return *this; }
+ operator T*() const { return mPtr.get(); }
+ T& operator*() const { return *mPtr; }
+ T* operator->() const { return mPtr.operator->(); }
+
+private:
+ std::unique_ptr<T, deleter> mPtr;
+};
+
+#endif /* ! defined(LL_OWNING_PTR_H) */
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 6b14b68c78..1fb61673bd 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -27,10 +27,11 @@
#ifndef LL_LLIMAGE_H
#define LL_LLIMAGE_H
-#include "lluuid.h"
-#include "llstring.h"
+#include "llmutex.h"
#include "llpointer.h"
+#include "llstring.h"
#include "lltrace.h"
+#include "lluuid.h"
constexpr S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2
constexpr S32 MAX_IMAGE_MIP = 12; // 4096x4096
diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp
index 6037517103..d8f17561b3 100644
--- a/indra/llimagej2coj/llimagej2coj.cpp
+++ b/indra/llimagej2coj/llimagej2coj.cpp
@@ -31,6 +31,8 @@
#include "openjpeg.h"
#include "event.h"
#include "cio.h"
+#include "owning_ptr.h"
+#include <string>
#define MAX_ENCODED_DISCARD_LEVELS 5
@@ -231,33 +233,6 @@ public:
parameters.cp_reduce = discardLevel;
}
- ~JPEG2KDecode()
- {
- if (decoder)
- {
- opj_destroy_codec(decoder);
- }
- decoder = nullptr;
-
- if (image)
- {
- opj_image_destroy(image);
- }
- image = nullptr;
-
- if (stream)
- {
- opj_stream_destroy(stream);
- }
- stream = nullptr;
-
- if (codestream_info)
- {
- opj_destroy_cstr_info(&codestream_info);
- }
- codestream_info = nullptr;
- }
-
bool readHeader(
U8* data,
U32 dataSize,
@@ -275,11 +250,6 @@ public:
return false;
}
- if (stream)
- {
- opj_stream_destroy(stream);
- }
-
stream = opj_stream_create(dataSize, true);
if (!stream)
{
@@ -301,13 +271,14 @@ public:
opj_decoder_set_strict_mode(decoder, OPJ_FALSE);
/* Read the main header of the codestream and if necessary the JP2 boxes*/
- if (!opj_read_header((opj_stream_t*)stream, decoder, &image))
+ opj_image_t* img;
+ if (!opj_read_header(stream, decoder, &img))
{
return false;
}
+ image = img;
codestream_info = opj_get_cstr_info(decoder);
-
if (!codestream_info)
{
return false;
@@ -344,11 +315,6 @@ public:
opj_set_warning_handler(decoder, opj_warn, this);
opj_set_error_handler(decoder, opj_error, this);
- if (stream)
- {
- opj_stream_destroy(stream);
- }
-
stream = opj_stream_create(dataSize, true);
if (!stream)
{
@@ -366,11 +332,7 @@ public:
size = dataSize;
offset = 0;
- if (image)
- {
- opj_image_destroy(image);
- image = nullptr;
- }
+ image = nullptr;
// needs to happen before opj_read_header and opj_decode...
opj_set_decoded_resolution_factor(decoder, discard_level);
@@ -378,10 +340,12 @@ public:
// enable decoding partially loaded images
opj_decoder_set_strict_mode(decoder, OPJ_FALSE);
- if (!opj_read_header(stream, decoder, &image))
+ opj_image_t* img;
+ if (!opj_read_header(stream, decoder, &img))
{
return false;
}
+ image = img;
// needs to happen before decode which may fail
if (channels)
@@ -393,15 +357,9 @@ public:
// count was zero. The latter is just a sanity check before we
// dereference the array.
- if (!decoded || !image || !image->numcomps)
- {
- opj_end_decompress(decoder, stream);
- return false;
- }
-
+ bool result = (decoded && image && image->numcomps);
opj_end_decompress(decoder, stream);
-
- return true;
+ return result;
}
opj_image_t* getImage() { return image; }
@@ -409,10 +367,18 @@ public:
private:
opj_dparameters_t parameters;
opj_event_mgr_t event_mgr;
- opj_image_t* image = nullptr;
- opj_codec_t* decoder = nullptr;
- opj_stream_t* stream = nullptr;
- opj_codestream_info_v2_t* codestream_info = nullptr;
+ owning_ptr<opj_codestream_info_v2_t> codestream_info{
+ nullptr,
+ // opj_destroy_cstr_info(opj_codestream_info_v2_t**) requires a
+ // pointer to pointer, which is too bad because otherwise we could
+ // directly pass that function as the owning_ptr's deleter.
+ [](opj_codestream_info_v2_t* doomed)
+ {
+ opj_destroy_cstr_info(&doomed);
+ }};
+ owning_ptr<opj_stream_t> stream{ nullptr, opj_stream_destroy };
+ owning_ptr<opj_image_t> image{ nullptr, opj_image_destroy };
+ owning_ptr<opj_codec_t> decoder{ nullptr, opj_destroy_codec };
};
class JPEG2KEncode : public JPEG2KBase
@@ -447,43 +413,19 @@ public:
parameters.irreversible = 1;
}
- if (comment_text)
- {
- free(comment_text);
- }
- comment_text = comment_text_in ? strdup(comment_text_in) : nullptr;
+ comment_text.assign(comment_text_in? comment_text_in : "no comment");
- parameters.cp_comment = comment_text ? comment_text : (char*)"no comment";
+ // Because comment_text is a member declared before parameters,
+ // it will outlive parameters, so we can safely store in parameters a
+ // pointer into comment_text's data. Unfortunately cp_comment is
+ // declared as (non-const) char*. We just have to trust that this is
+ // legacy C style coding, rather than any intention to modify the
+ // comment string. (If there was actual modification, we could use a
+ // std::vector<char> instead, but let's only go there if we must.)
+ parameters.cp_comment = const_cast<char*>(comment_text.c_str());
llassert(parameters.cp_comment);
}
- ~JPEG2KEncode()
- {
- if (encoder)
- {
- opj_destroy_codec(encoder);
- }
- encoder = nullptr;
-
- if (image)
- {
- opj_image_destroy(image);
- }
- image = nullptr;
-
- if (stream)
- {
- opj_stream_destroy(stream);
- }
- stream = nullptr;
-
- if (comment_text)
- {
- free(comment_text);
- }
- comment_text = nullptr;
- }
-
bool encode(const LLImageRaw& rawImageIn, LLImageJ2C &compressedImageOut)
{
LLImageDataSharedLock lockIn(&rawImageIn);
@@ -561,11 +503,6 @@ public:
memset(buffer, 0, data_size_guess);
- if (stream)
- {
- opj_stream_destroy(stream);
- }
-
stream = opj_stream_create(data_size_guess, false);
if (!stream)
{
@@ -742,12 +679,12 @@ public:
opj_image_t* getImage() { return image; }
private:
- opj_cparameters_t parameters;
- opj_event_mgr_t event_mgr;
- opj_image_t* image = nullptr;
- opj_codec_t* encoder = nullptr;
- opj_stream_t* stream = nullptr;
- char* comment_text = nullptr;
+ std::string comment_text;
+ opj_cparameters_t parameters;
+ opj_event_mgr_t event_mgr;
+ owning_ptr<opj_stream_t> stream{ nullptr, opj_stream_destroy };
+ owning_ptr<opj_image_t> image{ nullptr, opj_image_destroy };
+ owning_ptr<opj_codec_t> encoder{ nullptr, opj_destroy_codec };
};
diff --git a/indra/llmath/llinterp.h b/indra/llmath/llinterp.h
index ef6a5e638d..336539fb2e 100644
--- a/indra/llmath/llinterp.h
+++ b/indra/llmath/llinterp.h
@@ -29,11 +29,11 @@
#if defined(LL_WINDOWS)
// macro definitions for common math constants (e.g. M_PI) are declared under the _USE_MATH_DEFINES
// on Windows system.
-// So, let's define _USE_MATH_DEFINES before including math.h
+// So, let's define _USE_MATH_DEFINES before including cmath
#define _USE_MATH_DEFINES
#endif
-#include "math.h"
+#include <cmath>
// Class from which different types of interpolators can be derived
diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h
index fa315291a3..0348dad8fe 100644
--- a/indra/llmath/llmath.h
+++ b/indra/llmath/llmath.h
@@ -358,10 +358,7 @@ inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs)
return new_foo;
}
-inline F32 lerp(F32 a, F32 b, F32 u)
-{
- return a + ((b - a) * u);
-}
+using std::lerp;
inline F32 lerp2d(F32 x00, F32 x01, F32 x10, F32 x11, F32 u, F32 v)
{
@@ -486,7 +483,7 @@ inline U32 get_next_power_two(U32 val, U32 max_power_two)
//get the gaussian value given the linear distance from axis x and guassian value o
inline F32 llgaussian(F32 x, F32 o)
{
- return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2*o*o));
+ return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2.f*o*o));
}
//helper function for removing outliers
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 700e61467b..00a56edf68 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1294,9 +1294,9 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en
c = cos(ang)*lerp(radius_start, radius_end, t);
- pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s)
+ pt->mPos.set(0 + lerp(0.f,params.getShear().mV[0],s)
+ lerp(-skew ,skew, t) * 0.5f,
- c + lerp(0,params.getShear().mV[1],s),
+ c + lerp(0.f,params.getShear().mV[1],s),
s);
pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t),
hole_y * lerp(taper_y_begin, taper_y_end, t),
@@ -1327,9 +1327,9 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en
c = cos(ang)*lerp(radius_start, radius_end, t);
s = sin(ang)*lerp(radius_start, radius_end, t);
- pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s)
+ pt->mPos.set(0 + lerp(0.f,params.getShear().mV[0],s)
+ lerp(-skew ,skew, t) * 0.5f,
- c + lerp(0,params.getShear().mV[1],s),
+ c + lerp(0.f,params.getShear().mV[1],s),
s);
pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t),
@@ -1354,9 +1354,9 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en
c = cos(ang)*lerp(radius_start, radius_end, t);
s = sin(ang)*lerp(radius_start, radius_end, t);
- pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s)
+ pt->mPos.set(0 + lerp(0.f,params.getShear().mV[0],s)
+ lerp(-skew ,skew, t) * 0.5f,
- c + lerp(0,params.getShear().mV[1],s),
+ c + lerp(0.f,params.getShear().mV[1],s),
s);
pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t),
hole_y * lerp(taper_y_begin, taper_y_end, t),
@@ -1494,8 +1494,8 @@ bool LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
for (S32 i=0;i<np;i++)
{
F32 t = lerp(params.getBegin(),params.getEnd(),(F32)i * mStep);
- mPath[i].mPos.set(lerp(0,params.getShear().mV[0],t),
- lerp(0,params.getShear().mV[1],t),
+ mPath[i].mPos.set(lerp(0.f,params.getShear().mV[0],t),
+ lerp(0.f,params.getShear().mV[1],t),
t - 0.5f);
LLQuaternion quat;
quat.setQuat(lerp(F_PI * params.getTwistBegin(),F_PI * params.getTwist(),t),0,0,1);
@@ -1559,10 +1559,10 @@ bool LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
{
F32 t = (F32)i * mStep;
mPath[i].mPos.set(0,
- lerp(0, -sin(F_PI*params.getTwist()*t)*0.5f,t),
+ lerp(0.f, -sin(F_PI*params.getTwist()*t)*0.5f,t),
lerp(-0.5f, cos(F_PI*params.getTwist()*t)*0.5f,t));
- mPath[i].mScale.set(lerp(1,params.getScale().mV[0],t),
- lerp(1,params.getScale().mV[1],t), 0,1);
+ mPath[i].mScale.set(lerp(1.f,params.getScale().mV[0],t),
+ lerp(1.f,params.getScale().mV[1],t), 0.f, 1.f);
mPath[i].mTexT = t;
LLQuaternion quat;
quat.setQuat(F_PI * params.getTwist() * t,1,0,0);
diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp
index bb0c94d513..d8f649140f 100644
--- a/indra/llmath/llvolumemgr.cpp
+++ b/indra/llmath/llvolumemgr.cpp
@@ -25,6 +25,7 @@
#include "linden_common.h"
+#include "llmutex.h"
#include "llvolumemgr.h"
#include "llvolume.h"
diff --git a/indra/llmath/raytrace.cpp b/indra/llmath/raytrace.cpp
index c0b5f48f2d..465e56b6f3 100644
--- a/indra/llmath/raytrace.cpp
+++ b/indra/llmath/raytrace.cpp
@@ -26,7 +26,7 @@
#include "linden_common.h"
-#include "math.h"
+#include <cmath>
#include "v3math.h"
#include "llquaternion.h"
#include "m3math.h"
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 67b4ada62f..ba77c6f1a4 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1777,7 +1777,7 @@ void LLImageGL::syncToMainThread(LLGLuint new_tex_name)
ref();
LL::WorkQueue::postMaybe(
mMainQueue,
- [=]()
+ [=, this]()
{
LL_PROFILE_ZONE_NAMED("cglt - delete callback");
syncTexName(new_tex_name);
diff --git a/indra/llui/llluafloater.cpp b/indra/llui/llluafloater.cpp
index ccdadc6ae0..91c0cfeec9 100644
--- a/indra/llui/llluafloater.cpp
+++ b/indra/llui/llluafloater.cpp
@@ -301,11 +301,11 @@ void LLLuaFloater::postEvent(LLSD data, const std::string &event_name)
void LLLuaFloater::showLuaFloater(const LLSD &data)
{
fsyspath fs_path(data["xml_path"].asString());
- std::string path = fs_path.lexically_normal().u8string();
+ fsyspath path = fs_path.lexically_normal();
if (!fs_path.is_absolute())
{
std::string lib_path = gDirUtilp->getExpandedFilename(LL_PATH_SCRIPTS, "lua");
- path = (fsyspath(lib_path) / path).u8string();
+ path = fsyspath(fsyspath(lib_path) / path);
}
LLLuaFloater *floater = new LLLuaFloater(data);
diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h
index ef0762fc17..eca13cbb3c 100644
--- a/indra/llui/llnotifications.h
+++ b/indra/llui/llnotifications.h
@@ -94,6 +94,7 @@
#include "llinitparam.h"
#include "llinstancetracker.h"
#include "llmortician.h"
+#include "llmutex.h"
#include "llnotificationptr.h"
#include "llpointer.h"
#include "llrefcount.h"
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index 1883c6c9c1..b90e85d911 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -1037,7 +1037,7 @@ F32 LLWindowMacOSX::getGamma() const
&greenGamma,
&blueMin,
&blueMax,
- &blueGamma) == noErr)
+ &blueGamma) == static_cast<CGError>(noErr))
{
// So many choices...
// Let's just return the green channel gamma for now.
@@ -1088,7 +1088,7 @@ bool LLWindowMacOSX::setGamma(const F32 gamma)
&greenGamma,
&blueMin,
&blueMax,
- &blueGamma) != noErr)
+ &blueGamma) != static_cast<CGError>(noErr))
{
return false;
}
@@ -1103,7 +1103,7 @@ bool LLWindowMacOSX::setGamma(const F32 gamma)
gamma,
blueMin,
blueMax,
- gamma) != noErr)
+ gamma) != static_cast<CGError>(noErr))
{
return false;
}
@@ -1155,7 +1155,7 @@ bool LLWindowMacOSX::setCursorPosition(const LLCoordWindow position)
newPosition.y = screen_pos.mY;
CGSetLocalEventsSuppressionInterval(0.0);
- if(CGWarpMouseCursorPosition(newPosition) == noErr)
+ if(CGWarpMouseCursorPosition(newPosition) == static_cast<CGError>(noErr))
{
result = true;
}
diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp
index ed66753267..f596ce04f8 100644
--- a/indra/newview/gltfscenemanager.cpp
+++ b/indra/newview/gltfscenemanager.cpp
@@ -500,7 +500,7 @@ void GLTFSceneManager::update()
LLNewBufferedResourceUploadInfo::uploadFinish_f finish = [this, buffer](LLUUID assetId, LLSD response)
{
LLAppViewer::instance()->postToMainCoro(
- [=]()
+ [=, this]()
{
if (mUploadingAsset)
{
diff --git a/indra/newview/llcylinder.cpp b/indra/newview/llcylinder.cpp
index c347d3e1be..d5f1e25151 100644
--- a/indra/newview/llcylinder.cpp
+++ b/indra/newview/llcylinder.cpp
@@ -29,7 +29,7 @@
#include "llcylinder.h"
#include "llerror.h"
-#include "math.h"
+#include <cmath>
#include "llmath.h"
#include "noise.h"
#include "v3math.h"
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp
index 7fe5c1ece0..322717fbb9 100644
--- a/indra/newview/llluamanager.cpp
+++ b/indra/newview/llluamanager.cpp
@@ -317,7 +317,7 @@ LLRequireResolver::LLRequireResolver(lua_State *L, const std::string& path) :
void LLRequireResolver::findModule()
{
// If mPathToResolve is absolute, this replaces mSourceDir.
- auto absolutePath = (mSourceDir / mPathToResolve).u8string();
+ fsyspath absolutePath(mSourceDir / mPathToResolve);
// Push _MODULES table on stack for checking and saving to the cache
luaL_findtable(L, LUA_REGISTRYINDEX, "_MODULES", 1);
@@ -333,7 +333,7 @@ void LLRequireResolver::findModule()
// not already cached - prep error message just in case
auto fail{
- [L=L, path=mPathToResolve.u8string()]()
+ [L=L, path=mPathToResolve.string()]()
{ luaL_error(L, "could not find require('%s')", path.data()); }};
if (mPathToResolve.is_absolute())
@@ -348,10 +348,10 @@ void LLRequireResolver::findModule()
{
// if path is already absolute, operator/() preserves it
auto abspath(fsyspath(gDirUtilp->getAppRODataDir()) / path.asString());
- std::string absolutePathOpt = (abspath / mPathToResolve).u8string();
+ fsyspath absolutePathOpt = (abspath / mPathToResolve);
if (absolutePathOpt.empty())
- luaL_error(L, "error requiring module '%s'", mPathToResolve.u8string().data());
+ luaL_error(L, "error requiring module '%s'", mPathToResolve.string().data());
if (findModuleImpl(absolutePathOpt))
return;
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 5fc49b32ea..e4e70b02f9 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -548,8 +548,8 @@ LLViewerFetchedTexture* LLMeshUploadThread::FindViewerTexture(const LLImportMate
return ppTex ? (*ppTex).get() : NULL;
}
-volatile S32 LLMeshRepoThread::sActiveHeaderRequests = 0;
-volatile S32 LLMeshRepoThread::sActiveLODRequests = 0;
+std::atomic<S32> LLMeshRepoThread::sActiveHeaderRequests = 0;
+std::atomic<S32> LLMeshRepoThread::sActiveLODRequests = 0;
U32 LLMeshRepoThread::sMaxConcurrentRequests = 1;
S32 LLMeshRepoThread::sRequestLowWater = REQUEST2_LOW_WATER_MIN;
S32 LLMeshRepoThread::sRequestHighWater = REQUEST2_HIGH_WATER_MIN;
@@ -3959,7 +3959,7 @@ void LLMeshRepository::notifyLoadedMeshes()
}
// erase from background thread
- mThread->mWorkQueue.post([=]()
+ mThread->mWorkQueue.post([=, this]()
{
mThread->mSkinMap.erase(id);
});
diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h
index d864a07615..c7572c9cbf 100644
--- a/indra/newview/llmeshrepository.h
+++ b/indra/newview/llmeshrepository.h
@@ -256,8 +256,8 @@ class LLMeshRepoThread : public LLThread
{
public:
- volatile static S32 sActiveHeaderRequests;
- volatile static S32 sActiveLODRequests;
+ static std::atomic<S32> sActiveHeaderRequests;
+ static std::atomic<S32> sActiveLODRequests;
static U32 sMaxConcurrentRequests;
static S32 sRequestLowWater;
static S32 sRequestHighWater;
diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp
index 0d6ca1cb94..2d659cd19d 100644
--- a/indra/newview/llpanelemojicomplete.cpp
+++ b/indra/newview/llpanelemojicomplete.cpp
@@ -440,7 +440,7 @@ void LLPanelEmojiComplete::updateConstraints()
{
mRenderRect = getLocalRect();
- mEmojiWidth = (U16)(mIconFont->getWidthF32(u8"\U0001F431") + mPadding * 2);
+ mEmojiWidth = (U16)(mIconFont->getWidthF32(LLWString(1, 0x1F431).c_str()) + mPadding * 2);
if (mVertical)
{
mEmojiHeight = mIconFont->getLineHeight() + mPadding * 2;
diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp
index 1af585708e..955b5e7730 100644
--- a/indra/newview/llpanelprimmediacontrols.cpp
+++ b/indra/newview/llpanelprimmediacontrols.cpp
@@ -777,7 +777,7 @@ void LLPanelPrimMediaControls::draw()
else if(mFadeTimer.getStarted())
{
F32 time = mFadeTimer.getElapsedTimeF32();
- alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f);
+ alpha *= llmax(lerp(1.0f, 0.0f, time / mControlFadeTime), 0.0f);
if(time >= mControlFadeTime)
{
diff --git a/indra/newview/llsky.cpp b/indra/newview/llsky.cpp
index 82caa14433..66fbe0029a 100644
--- a/indra/newview/llsky.cpp
+++ b/indra/newview/llsky.cpp
@@ -39,7 +39,7 @@
// linden library includes
#include "llerror.h"
#include "llmath.h"
-#include "math.h"
+#include <cmath>
#include "v4color.h"
#include "llviewerobjectlist.h"
diff --git a/indra/newview/llsprite.cpp b/indra/newview/llsprite.cpp
index e51aeb6080..09c57eaf1d 100644
--- a/indra/newview/llsprite.cpp
+++ b/indra/newview/llsprite.cpp
@@ -37,7 +37,7 @@
#include "llsprite.h"
-#include "math.h"
+#include <cmath>
#include "lldrawable.h"
#include "llface.h"
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 69c40066b4..ee98728ff1 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -2832,7 +2832,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority)
{
LL_PROFILE_ZONE_SCOPED;
- mRequestQueue.tryPost([=]()
+ mRequestQueue.tryPost([=, this]()
{
LLTextureFetchWorker* worker = getWorker(id);
if (worker)
@@ -3523,8 +3523,8 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
//if (! gViewerAssetStatsThread1)
// return true;
- static volatile bool reporting_started(false);
- static volatile S32 report_sequence(0);
+ static std::atomic<bool> reporting_started(false);
+ static std::atomic<S32> report_sequence(0);
// In mStatsSD, we have a copy we own of the LLSD representation
// of the asset stats. Add some additional fields and ship it off.
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 92db598410..9633e54f29 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -2903,14 +2903,14 @@ void LLViewerMediaImpl::update()
media_tex->ref();
main_queue->postTo(
mTexUpdateQueue, // Worker thread queue
- [=]() // work done on update worker thread
+ [=, this]() // work done on update worker thread
{
#if LL_IMAGEGL_THREAD_CHECK
media_tex->getGLTexture()->mActiveThread = LLThread::currentID();
#endif
doMediaTexUpdate(media_tex, data, data_width, data_height, x_pos, y_pos, width, height, true);
},
- [=]() // callback to main thread
+ [=, this]() // callback to main thread
{
#if LL_IMAGEGL_THREAD_CHECK
media_tex->getGLTexture()->mActiveThread = LLThread::currentID();
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index c747319940..7a4cf7c85c 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1330,7 +1330,7 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi
// Check the whitelist, if there's media (otherwise just show it)
if (te->getMediaData() == NULL || te->getMediaData()->checkCandidateUrl(url))
{
- if ( obj != mDragHoveredObject)
+ if (obj != mDragHoveredObject)
{
// Highlight the dragged object
LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject);
diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp
index 7161f5af5e..4da348d090 100644
--- a/indra/newview/llvoicewebrtc.cpp
+++ b/indra/newview/llvoicewebrtc.cpp
@@ -551,7 +551,7 @@ void LLWebRTCVoiceClient::voiceConnectionCoro()
}
}
LL::WorkQueue::postMaybe(mMainQueue,
- [=] {
+ [=, this] {
if (sShuttingDown)
{
return;
@@ -669,7 +669,7 @@ void LLWebRTCVoiceClient::OnDevicesChanged(const llwebrtc::LLWebRTCVoiceDeviceLi
{
LL::WorkQueue::postMaybe(mMainQueue,
- [=]
+ [=, this]
{
OnDevicesChangedImpl(render_devices, capture_devices);
});
@@ -2205,7 +2205,7 @@ LLVoiceWebRTCConnection::~LLVoiceWebRTCConnection()
void LLVoiceWebRTCConnection::OnIceGatheringState(llwebrtc::LLWebRTCSignalingObserver::EIceGatheringState state)
{
LL::WorkQueue::postMaybe(mMainQueue,
- [=] {
+ [=, this] {
LL_DEBUGS("Voice") << "Ice Gathering voice account. " << state << LL_ENDL;
switch (state)
@@ -2228,7 +2228,7 @@ void LLVoiceWebRTCConnection::OnIceGatheringState(llwebrtc::LLWebRTCSignalingObs
// callback from llwebrtc
void LLVoiceWebRTCConnection::OnIceCandidate(const llwebrtc::LLWebRTCIceCandidate& candidate)
{
- LL::WorkQueue::postMaybe(mMainQueue, [=] { mIceCandidates.push_back(candidate); });
+ LL::WorkQueue::postMaybe(mMainQueue, [=, this] { mIceCandidates.push_back(candidate); });
}
void LLVoiceWebRTCConnection::processIceUpdates()
@@ -2346,7 +2346,7 @@ void LLVoiceWebRTCConnection::processIceUpdatesCoro(connectionPtr_t connection)
void LLVoiceWebRTCConnection::OnOfferAvailable(const std::string &sdp)
{
LL::WorkQueue::postMaybe(mMainQueue,
- [=] {
+ [=, this] {
if (mShutDown)
{
return;
@@ -2373,7 +2373,7 @@ void LLVoiceWebRTCConnection::OnOfferAvailable(const std::string &sdp)
void LLVoiceWebRTCConnection::OnAudioEstablished(llwebrtc::LLWebRTCAudioInterface* audio_interface)
{
LL::WorkQueue::postMaybe(mMainQueue,
- [=] {
+ [=, this] {
if (mShutDown)
{
return;
@@ -2395,7 +2395,7 @@ void LLVoiceWebRTCConnection::OnAudioEstablished(llwebrtc::LLWebRTCAudioInterfac
void LLVoiceWebRTCConnection::OnRenegotiationNeeded()
{
LL::WorkQueue::postMaybe(mMainQueue,
- [=] {
+ [=, this] {
LL_DEBUGS("Voice") << "Voice channel requires renegotiation." << LL_ENDL;
if (!mShutDown)
{
@@ -2409,7 +2409,7 @@ void LLVoiceWebRTCConnection::OnRenegotiationNeeded()
void LLVoiceWebRTCConnection::OnPeerConnectionClosed()
{
LL::WorkQueue::postMaybe(mMainQueue,
- [=] {
+ [=, this] {
LL_DEBUGS("Voice") << "Peer connection has closed." << LL_ENDL;
if (mVoiceConnectionState == VOICE_STATE_WAIT_FOR_CLOSE)
{
@@ -2881,7 +2881,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
// llwebrtc callback
void LLVoiceWebRTCConnection::OnDataReceived(const std::string& data, bool binary)
{
- LL::WorkQueue::postMaybe(mMainQueue, [=] { LLVoiceWebRTCConnection::OnDataReceivedImpl(data, binary); });
+ LL::WorkQueue::postMaybe(mMainQueue, [=, this] { LLVoiceWebRTCConnection::OnDataReceivedImpl(data, binary); });
}
//
@@ -3037,7 +3037,7 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b
void LLVoiceWebRTCConnection::OnDataChannelReady(llwebrtc::LLWebRTCDataInterface *data_interface)
{
LL::WorkQueue::postMaybe(mMainQueue,
- [=] {
+ [=, this] {
if (mShutDown)
{
return;
diff --git a/indra/newview/llwatchdog.cpp b/indra/newview/llwatchdog.cpp
index bf171fe954..d9fcd5811d 100644
--- a/indra/newview/llwatchdog.cpp
+++ b/indra/newview/llwatchdog.cpp
@@ -27,6 +27,7 @@
#include "llviewerprecompiledheaders.h"
#include "llwatchdog.h"
+#include "llmutex.h"
#include "llthread.h"
constexpr U32 WATCHDOG_SLEEP_TIME_USEC = 1000000U;
diff --git a/indra/newview/llworldmipmap.cpp b/indra/newview/llworldmipmap.cpp
index d8ea2b884f..d198f7a33b 100644
--- a/indra/newview/llworldmipmap.cpp
+++ b/indra/newview/llworldmipmap.cpp
@@ -30,7 +30,7 @@
#include "llviewercontrol.h" // LLControlGroup
#include "llviewertexturelist.h"
-#include "math.h" // log()
+#include <cmath> // log()
// Turn this on to output tile stats in the standard output
#define DEBUG_TILES_STAT 0
diff --git a/indra/newview/tests/llluamanager_test.cpp b/indra/newview/tests/llluamanager_test.cpp
index f0a1b32eed..9687b68451 100644
--- a/indra/newview/tests/llluamanager_test.cpp
+++ b/indra/newview/tests/llluamanager_test.cpp
@@ -55,14 +55,14 @@ namespace tut
// indra/newview/tests/llluamanager_test.cpp =>
// indra/newview
auto newview{ fsyspath(__FILE__).parent_path().parent_path() };
- auto settings{ newview / "app_settings" / "settings.xml" };
+ fsyspath settings{ newview / "app_settings" / "settings.xml" };
// true suppresses implicit declare; implicit declare requires
// that every variable in settings.xml has a Comment, which many don't.
- gSavedSettings.loadFromFile(settings.u8string(), true);
+ gSavedSettings.loadFromFile(settings, true);
// At test time, since we don't have the app bundle available,
// extend LuaRequirePath to include the require directory in the
// source tree.
- auto require{ (newview / "scripts" / "lua" / "require").u8string() };
+ std::string require{ fsyspath(newview / "scripts" / "lua" / "require") };
auto paths{ gSavedSettings.getLLSD("LuaRequirePath") };
bool found = false;
for (const auto& path : llsd::inArray(paths))
diff --git a/indra/viewer_components/login/lllogin.cpp b/indra/viewer_components/login/lllogin.cpp
index bdabab70e0..cb330eba9b 100644
--- a/indra/viewer_components/login/lllogin.cpp
+++ b/indra/viewer_components/login/lllogin.cpp
@@ -129,8 +129,7 @@ void LLLogin::Impl::connect(const std::string& uri, const LLSD& login_params)
// Launch a coroutine with our login_() method. Run the coroutine until
// its first wait; at that point, return here.
- std::string coroname =
- LLCoros::instance().launch("LLLogin::Impl::login_", [=]() { loginCoro(uri, login_params); });
+ std::string coroname = LLCoros::instance().launch("LLLogin::Impl::login_", [=, this]() { loginCoro(uri, login_params); });
LL_DEBUGS("LLLogin") << " connected with uri '" << uri << "', login_params " << login_params << LL_ENDL;
}