Skip to content

Commit e8c59d9

Browse files
committed
Merge branch 'develop' into marchcat/c-develop
# Conflicts: # indra/newview/lltexturefetch.cpp # indra/newview/lltexturefetch.h # indra/newview/llviewertexture.cpp
2 parents f062a5b + a14d9fe commit e8c59d9

File tree

73 files changed

+1113
-512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1113
-512
lines changed

indra/llcommon/lua_function.cpp

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,34 @@ int lua_metaipair(lua_State* L)
764764

765765
} // anonymous namespace
766766

767+
int LuaState::push_debug_traceback()
768+
{
769+
// Push debug.traceback() onto the stack as lua_pcall()'s error
770+
// handler function. On error, lua_pcall() calls the specified error
771+
// handler function with the original error message; the message
772+
// returned by the error handler is then returned by lua_pcall().
773+
// Luau's debug.traceback() is called with a message to prepend to the
774+
// returned traceback string. Almost as if they'd been designed to
775+
// work together...
776+
lua_getglobal(mState, "debug");
777+
if (!lua_istable(mState, -1))
778+
{
779+
lua_pop(mState, 1);
780+
LL_WARNS("Lua") << "'debug' table not found" << LL_ENDL;
781+
return 0;
782+
}
783+
lua_getfield(mState, -1, "traceback");
784+
if (!lua_isfunction(mState, -1))
785+
{
786+
lua_pop(mState, 2);
787+
LL_WARNS("Lua") << "'traceback' func not found" << LL_ENDL;
788+
return 0;
789+
}
790+
// ditch "debug"
791+
lua_remove(mState, -2);
792+
return lua_gettop(mState);
793+
}
794+
767795
LuaState::~LuaState()
768796
{
769797
// If we're unwinding the stack due to an exception, don't bother trying
@@ -784,6 +812,8 @@ LuaState::~LuaState()
784812
// stack contains Registry.atexit
785813
if (lua_istable(mState, -1))
786814
{
815+
int atexit = lua_gettop(mState);
816+
787817
// We happen to know that Registry.atexit is built by appending array
788818
// entries using table.insert(). That's important because it means
789819
// there are no holes, and therefore lua_objlen() should be correct.
@@ -793,36 +823,25 @@ LuaState::~LuaState()
793823
LL_DEBUGS("Lua") << LLCoros::getName() << ": Registry.atexit is a table with "
794824
<< len << " entries" << LL_ENDL;
795825

796-
// Push debug.traceback() onto the stack as lua_pcall()'s error
797-
// handler function. On error, lua_pcall() calls the specified error
798-
// handler function with the original error message; the message
799-
// returned by the error handler is then returned by lua_pcall().
800-
// Luau's debug.traceback() is called with a message to prepend to the
801-
// returned traceback string. Almost as if they'd been designed to
802-
// work together...
803-
lua_getglobal(mState, "debug");
804-
lua_getfield(mState, -1, "traceback");
805-
// ditch "debug"
806-
lua_remove(mState, -2);
807-
// stack now contains atexit, debug.traceback()
808-
826+
// TODO: 'debug' global shouldn't be overwritten and should be accessible at this stage
827+
S32 debug_traceback_idx = push_debug_traceback();
828+
// if debug_traceback is true, stack now contains atexit, /debug.traceback()/
829+
// otherwise just atexit
809830
for (int i(len); i >= 1; --i)
810831
{
811832
lua_pushinteger(mState, i);
812-
// stack contains Registry.atexit, debug.traceback(), i
813-
lua_gettable(mState, -3);
814-
// stack contains Registry.atexit, debug.traceback(), atexit[i]
833+
// stack contains Registry.atexit, /debug.traceback()/, i
834+
lua_gettable(mState, atexit);
835+
// stack contains Registry.atexit, /debug.traceback()/, atexit[i]
815836
// Call atexit[i](), no args, no return values.
816837
// Use lua_pcall() because errors in any one atexit() function
817838
// shouldn't cancel the rest of them. Pass debug.traceback() as
818839
// the error handler function.
819-
LL_DEBUGS("Lua") << LLCoros::getName()
820-
<< ": calling atexit(" << i << ")" << LL_ENDL;
821-
if (lua_pcall(mState, 0, 0, -2) != LUA_OK)
840+
LL_DEBUGS("Lua") << LLCoros::getName() << ": calling atexit(" << i << ")" << LL_ENDL;
841+
if (lua_pcall(mState, 0, 0, debug_traceback_idx) != LUA_OK)
822842
{
823843
auto error{ lua_tostdstring(mState, -1) };
824-
LL_WARNS("Lua") << LLCoros::getName()
825-
<< ": atexit(" << i << ") error: " << error << LL_ENDL;
844+
LL_WARNS("Lua") << LLCoros::getName() << ": atexit(" << i << ") error: " << error << LL_ENDL;
826845
// pop error message
827846
lua_pop(mState, 1);
828847
}
@@ -831,7 +850,8 @@ LuaState::~LuaState()
831850
// stack contains atexit, debug.traceback()
832851
}
833852
// pop debug.traceback()
834-
lua_pop(mState, 1);
853+
if (debug_traceback_idx)
854+
lua_remove(mState, debug_traceback_idx);
835855
}
836856
// pop Registry.atexit (either table or nil)
837857
lua_pop(mState, 1);

indra/llcommon/lua_function.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ class LuaState
122122
void set_interrupts_counter(S32 counter);
123123
void check_interrupts_counter();
124124

125+
int push_debug_traceback();
126+
125127
private:
126128
/*---------------------------- feature flag ----------------------------*/
127129
bool mFeature{ false };

indra/llcommon/stdtypes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ class narrow
164164
FROM mValue;
165165

166166
public:
167-
narrow(FROM value): mValue(value) {}
167+
constexpr narrow(FROM value): mValue(value) {}
168168

169169
/*---------------------- Narrowing unsigned to signed ----------------------*/
170170
template <typename TO,
171171
typename std::enable_if<std::is_unsigned<FROM>::value &&
172172
std::is_signed<TO>::value,
173173
bool>::type = true>
174-
inline
174+
constexpr
175175
operator TO() const
176176
{
177177
// The reason we skip the
@@ -189,7 +189,7 @@ class narrow
189189
typename std::enable_if<! (std::is_unsigned<FROM>::value &&
190190
std::is_signed<TO>::value),
191191
bool>::type = true>
192-
inline
192+
constexpr
193193
operator TO() const
194194
{
195195
// two different assert()s so we can tell which condition failed

indra/llcorehttp/httpcommon.cpp

Lines changed: 53 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "linden_common.h" // Modifies curl/curl.h interfaces
2828
#include "httpcommon.h"
29+
#include "llhttpconstants.h"
2930
#include "llmutex.h"
3031
#include "llthread.h"
3132
#include <curl/curl.h>
@@ -62,7 +63,7 @@ std::string HttpStatus::toHex() const
6263

6364
std::string HttpStatus::toString() const
6465
{
65-
static const char * llcore_errors[] =
66+
static const std::vector<std::string> llcore_errors =
6667
{
6768
"",
6869
"HTTP error reply status",
@@ -76,64 +77,57 @@ std::string HttpStatus::toString() const
7677
"Invalid HTTP status code received from server",
7778
"Could not allocate required resource"
7879
};
79-
static const int llcore_errors_count(sizeof(llcore_errors) / sizeof(llcore_errors[0]));
8080

81-
static const struct
82-
{
83-
type_enum_t mCode;
84-
const char * mText;
85-
}
86-
http_errors[] =
81+
static const std::map<type_enum_t, std::string> http_errors =
8782
{
88-
// Keep sorted by mCode, we binary search this list.
89-
{ 100, "Continue" },
90-
{ 101, "Switching Protocols" },
91-
{ 200, "OK" },
92-
{ 201, "Created" },
93-
{ 202, "Accepted" },
94-
{ 203, "Non-Authoritative Information" },
95-
{ 204, "No Content" },
96-
{ 205, "Reset Content" },
97-
{ 206, "Partial Content" },
98-
{ 300, "Multiple Choices" },
99-
{ 301, "Moved Permanently" },
100-
{ 302, "Found" },
101-
{ 303, "See Other" },
102-
{ 304, "Not Modified" },
103-
{ 305, "Use Proxy" },
104-
{ 307, "Temporary Redirect" },
105-
{ 400, "Bad Request" },
106-
{ 401, "Unauthorized" },
107-
{ 402, "Payment Required" },
108-
{ 403, "Forbidden" },
109-
{ 404, "Not Found" },
110-
{ 405, "Method Not Allowed" },
111-
{ 406, "Not Acceptable" },
112-
{ 407, "Proxy Authentication Required" },
113-
{ 408, "Request Time-out" },
114-
{ 409, "Conflict" },
115-
{ 410, "Gone" },
116-
{ 411, "Length Required" },
117-
{ 412, "Precondition Failed" },
118-
{ 413, "Request Entity Too Large" },
119-
{ 414, "Request-URI Too Large" },
120-
{ 415, "Unsupported Media Type" },
121-
{ 416, "Requested range not satisfiable" },
122-
{ 417, "Expectation Failed" },
123-
{ 499, "Linden Catch-All" },
124-
{ 500, "Internal Server Error" },
125-
{ 501, "Not Implemented" },
126-
{ 502, "Bad Gateway" },
127-
{ 503, "Service Unavailable" },
128-
{ 504, "Gateway Time-out" },
129-
{ 505, "HTTP Version not supported" }
83+
{ HTTP_CONTINUE, "Continue" },
84+
{ HTTP_SWITCHING_PROTOCOLS, "Switching Protocols" },
85+
{ HTTP_OK, "OK" },
86+
{ HTTP_CREATED, "Created" },
87+
{ HTTP_ACCEPTED, "Accepted" },
88+
{ HTTP_NON_AUTHORITATIVE_INFORMATION, "Non-Authoritative Information" },
89+
{ HTTP_NO_CONTENT, "No Content" },
90+
{ HTTP_RESET_CONTENT, "Reset Content" },
91+
{ HTTP_PARTIAL_CONTENT, "Partial Content" },
92+
{ HTTP_MULTIPLE_CHOICES, "Multiple Choices" },
93+
{ HTTP_MOVED_PERMANENTLY, "Moved Permanently" },
94+
{ HTTP_FOUND, "Found" },
95+
{ HTTP_SEE_OTHER, "See Other" },
96+
{ HTTP_NOT_MODIFIED, "Not Modified" },
97+
{ HTTP_USE_PROXY, "Use Proxy" },
98+
{ HTTP_TEMPORARY_REDIRECT, "Temporary Redirect" },
99+
{ HTTP_BAD_REQUEST, "Bad Request" },
100+
{ HTTP_UNAUTHORIZED, "Unauthorized" },
101+
{ HTTP_PAYMENT_REQUIRED, "Payment Required" },
102+
{ HTTP_FORBIDDEN, "Forbidden" },
103+
{ HTTP_NOT_FOUND, "Not Found" },
104+
{ HTTP_METHOD_NOT_ALLOWED, "Method Not Allowed" },
105+
{ HTTP_NOT_ACCEPTABLE, "Not Acceptable" },
106+
{ HTTP_PROXY_AUTHENTICATION_REQUIRED, "Proxy Authentication Required" },
107+
{ HTTP_REQUEST_TIME_OUT, "Request Time-out" },
108+
{ HTTP_CONFLICT, "Conflict" },
109+
{ HTTP_GONE, "Gone" },
110+
{ HTTP_LENGTH_REQUIRED, "Length Required" },
111+
{ HTTP_PRECONDITION_FAILED, "Precondition Failed" },
112+
{ HTTP_REQUEST_ENTITY_TOO_LARGE, "Request Entity Too Large" },
113+
{ HTTP_REQUEST_URI_TOO_LARGE, "Request-URI Too Large" },
114+
{ HTTP_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type" },
115+
{ HTTP_REQUESTED_RANGE_NOT_SATISFIABLE, "Requested range not satisfiable" },
116+
{ HTTP_EXPECTATION_FAILED, "Expectation Failed" },
117+
{ 499, "Linden Catch-All" },
118+
{ HTTP_INTERNAL_SERVER_ERROR, "Internal Server Error" },
119+
{ HTTP_NOT_IMPLEMENTED, "Not Implemented" },
120+
{ HTTP_BAD_GATEWAY, "Bad Gateway" },
121+
{ HTTP_SERVICE_UNAVAILABLE, "Service Unavailable" },
122+
{ HTTP_GATEWAY_TIME_OUT, "Gateway Time-out" },
123+
{ HTTP_VERSION_NOT_SUPPORTED, "HTTP Version not supported" }
130124
};
131-
static const int http_errors_count(sizeof(http_errors) / sizeof(http_errors[0]));
132125

133126
if (*this)
134127
{
135-
return std::string("");
128+
return LLStringUtil::null;
136129
}
130+
137131
switch (getType())
138132
{
139133
case EXT_CURL_EASY:
@@ -143,9 +137,9 @@ std::string HttpStatus::toString() const
143137
return std::string(curl_multi_strerror(CURLMcode(getStatus())));
144138

145139
case LLCORE:
146-
if (getStatus() >= 0 && getStatus() < llcore_errors_count)
140+
if (getStatus() >= 0 && std::size_t(getStatus()) < llcore_errors.size())
147141
{
148-
return std::string(llcore_errors[getStatus()]);
142+
return llcore_errors[getStatus()];
149143
}
150144
break;
151145

@@ -156,32 +150,16 @@ std::string HttpStatus::toString() const
156150
if ((getType() == 499) && (!getMessage().empty()))
157151
return getMessage();
158152

159-
// Binary search for the error code and string
160-
int bottom(0), top(http_errors_count);
161-
while (true)
153+
auto it = http_errors.find(getType());
154+
if (it != http_errors.end())
162155
{
163-
int at((bottom + top) / 2);
164-
if (getType() == http_errors[at].mCode)
165-
{
166-
return std::string(http_errors[at].mText);
167-
}
168-
if (at == bottom)
169-
{
170-
break;
171-
}
172-
else if (getType() < http_errors[at].mCode)
173-
{
174-
top = at;
175-
}
176-
else
177-
{
178-
bottom = at;
179-
}
156+
return it->second;
180157
}
181158
}
182159
break;
183160
}
184-
return std::string("Unknown error");
161+
162+
return "Unknown error";
185163
}
186164

187165

indra/llinventory/llsettingssky.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,14 @@ F32 LLSettingsSky::getTonemapMix() const
20642064
return mTonemapMix;
20652065
}
20662066

2067+
void LLSettingsSky::setTonemapMix(F32 mix)
2068+
{
2069+
if (mCanAutoAdjust)
2070+
return;
2071+
2072+
mTonemapMix = mix;
2073+
}
2074+
20672075
void LLSettingsSky::setGamma(F32 val)
20682076
{
20692077
mGamma = val;

indra/llinventory/llsettingssky.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class LLSettingsSky: public LLSettingsBase
213213
F32 getHDRMax() const;
214214
F32 getHDROffset() const;
215215
F32 getTonemapMix() const;
216+
void setTonemapMix(F32 mix);
216217

217218
void setGamma(F32 val);
218219

0 commit comments

Comments
 (0)