summaryrefslogtreecommitdiff
path: root/indra/newview/llappviewerwin32.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2018-05-17 15:02:26 -0400
committerNat Goodspeed <nat@lindenlab.com>2018-05-17 15:02:26 -0400
commit800b47ec230d1d2a6781dce5ba9816d10a37e91e (patch)
treec17d9ff6b769944a5312fcda0657e906d28f50af /indra/newview/llappviewerwin32.cpp
parentcd21556aef547dbb031e363d3a9b9f1893be4d08 (diff)
SL-821: Use classic-C BugSplat callback and static dumb pointer.
BugSplat has no business introducing a new C++ API based on classic-C function pointers without even a generic pass-through user data pointer!
Diffstat (limited to 'indra/newview/llappviewerwin32.cpp')
-rw-r--r--indra/newview/llappviewerwin32.cpp65
1 files changed, 38 insertions, 27 deletions
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index 91c6f08000..5f3bf14bc2 100644
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -74,14 +74,43 @@
#ifdef LL_BUGSPLAT
#include "BugSplat.h"
-// FIXME: need a production BugSplat database name
-static const wchar_t *bugdb_name = L"second_life_callum_test";
-
-// MiniDmpSender's constructor is defined to accept __wchar_t* instead of
-// plain wchar_t*.
-inline std::basic_string<__wchar_t> wunder(const std::wstring& str)
+namespace
{
- return { str.begin(), str.end() };
+ // FIXME: need a production BugSplat database name
+ static const wchar_t *bugdb_name = L"second_life_callum_test";
+
+ // MiniDmpSender's constructor is defined to accept __wchar_t* instead of
+ // plain wchar_t*.
+ inline std::basic_string<__wchar_t> wunder(const std::wstring& str)
+ {
+ return { str.begin(), str.end() };
+ }
+
+ // Irritatingly, MiniDmpSender::setCallback() is defined to accept a
+ // classic-C function pointer instead of an arbitrary C++ callable. In the
+ // latter case, we could pass a lambda that binds our MiniDmpSender
+ // pointer. As things stand, we must define an actual function and store
+ // the pointer statically.
+ static MiniDmpSender *sBugSplatSender = nullptr;
+
+ bool bugsplatSendLog(UINT nCode, LPVOID lpVal1, LPVOID lpVal2)
+ {
+ // If we haven't yet initialized LLDir, don't bother trying to
+ // find our log file.
+ // Alternatively -- if we might encounter trouble trying to query
+ // LLDir during crash cleanup -- consider making gDirUtilp an
+ // LLPounceable, and attach a callback that stores the pathname to
+ // the log file here.
+ if (nCode == MDSCB_EXCEPTIONCODE && gDirUtilp)
+ {
+ // send the main viewer log file
+ // widen to wstring, convert to __wchar_t, then pass c_str()
+ sBugSplatSender->sendAdditionalFile(
+ wunder(wstringize(gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "SecondLife.log"))).c_str());
+ }
+
+ return false;
+ }
}
#endif // LL_BUGSPLAT
@@ -526,30 +555,12 @@ bool LLAppViewerWin32::init()
LL_VIEWER_VERSION_BUILD));
// have to convert normal wide strings to strings of __wchar_t
- auto sender = new MiniDmpSender(
+ sBugSplatSender = new MiniDmpSender(
wunder(bugdb_name).c_str(),
wunder(LL_TO_WSTRING(LL_VIEWER_CHANNEL)).c_str(),
wunder(version_string).c_str(),
nullptr);
- sender->setCallback(
- [sender](unsigned int nCode, void* lpVal1, void* lpVal2)
- {
- // If we haven't yet initialized LLDir, don't bother trying to
- // find our log file.
- // Alternatively -- if we might encounter trouble trying to query
- // LLDir during crash cleanup -- consider making gDirUtilp an
- // LLPounceable, and attach a callback that stores the pathname to
- // the log file here.
- if (nCode == MDSCB_EXCEPTIONCODE && gDirUtilp)
- {
- // send the main viewer log file
- // widen to wstring, convert to __wchar_t, then pass c_str()
- sender->sendAdditionalFile(
- wunder(wstringize(gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "SecondLife.log"))).c_str());
- }
-
- return false;
- });
+ sBugSplatSender->setCallback(bugsplatSendLog);
// engage stringize() overload that converts from wstring
LL_INFOS() << "Engaged BugSplat(" << LL_TO_STRING(LL_VIEWER_CHANNEL)