diff --git a/src/ChmModel.cpp b/src/ChmModel.cpp index fef8a2c445e..509287cd00a 100644 --- a/src/ChmModel.cpp +++ b/src/ChmModel.cpp @@ -19,6 +19,8 @@ #include "GlobalPrefs.h" #include "ChmModel.h" +#include "utils/Log.h" + static IPageDestination* NewChmNamedDest(const char* url, int pageNo) { if (!url) { return nullptr; @@ -223,7 +225,11 @@ void ChmModel::ScrollTo(int, RectF, float) { } bool ChmModel::HandleLink(IPageDestination* link, ILinkHandler*) { - CrashIf(link->GetKind() != kindDestinationScrollTo); + Kind k = link->GetKind(); + if (k != kindDestinationScrollTo) { + logf("ChmModel::HandleLink: unsupported kind '%s'\n", k); + ReportIfQuick(link->GetKind() != kindDestinationScrollTo); + } char* url = PageDestGetName(link); if (DisplayPage(url)) { return true; diff --git a/src/CrashHandler.cpp b/src/CrashHandler.cpp index 87bb7b8dd4d..25228f38e4f 100644 --- a/src/CrashHandler.cpp +++ b/src/CrashHandler.cpp @@ -132,10 +132,15 @@ static bool GetModules(str::Str& s, bool additionalOnly) { return isWine; } -static char* BuildCrashInfoText(bool forCrash, bool noCallstack) { +// if reportCond this is building for ReportIf() / ReportIfQuick() +// otherwise this is a crsah +static char* BuildCrashInfoText(const char* reportCond, bool noCallstack) { str::Str s(16 * 1024, gCrashHandlerAllocator); - if (!forCrash) { + if (reportCond) { s.Append("Type: debug report (not crash)\n"); + s.Append("Cond: "); + s.Append(reportCond); + s.Append("\n"); } if (gSystemInfo) { s.Append(gSystemInfo); @@ -144,16 +149,18 @@ static char* BuildCrashInfoText(bool forCrash, bool noCallstack) { GetStressTestInfo(&s); s.Append("\n"); - if (forCrash) { - dbghelp::GetExceptionInfo(s, gMei.ExceptionPointers); - } else { + if (reportCond) { // this is not a crash but debug report, we don't have an exception if (noCallstack) { - s.Append("\r\nCrashed thread:\r\n"); + // dummy line so that we don't have to + s.Append("\nCrashed thread:\n"); + s.Append("00007FF79239E91A 01:000000000001D91A dummy!quick report\n"); } else { - s.Append("\r\nCrashed thread:\r\n"); + s.Append("\nCrashed thread:\n"); dbghelp::GetCurrentThreadCallstack(s); } + } else { + dbghelp::GetExceptionInfo(s, gMei.ExceptionPointers); } if (!noCallstack) { @@ -308,13 +315,14 @@ bool CrashHandlerDownloadSymbols() { // like crash report, but can be triggered without a crash void _uploadDebugReport(const char* condStr, bool noCallstack) { // we want to avoid submitting multiple reports for the same - // condition. I'm too lazy to implement tracking this granuarly - // so only allow once submition in a given session + // condition. I'm too lazy to implement tracking this granularly + // so only allow once submission in a given session static bool didSubmitDebugReport = false; if (didSubmitDebugReport) { return; } + didSubmitDebugReport = true; // don't send report if this is me debugging if (IsDebuggerPresent()) { @@ -347,7 +355,7 @@ void _uploadDebugReport(const char* condStr, bool noCallstack) { } } - auto s = BuildCrashInfoText(false, noCallstack); + auto s = BuildCrashInfoText(condStr, noCallstack); if (str::IsEmpty(s)) { log("_uploadDebugReport(): skipping because !BuildCrashInfoText()\n"); return; @@ -377,7 +385,7 @@ void TryUploadCrashReport() { log("TryUploadCrashReport(): CrashHandlerDownloadSymbols() failed\n"); } - char* sv = BuildCrashInfoText(true, true); + char* sv = BuildCrashInfoText(nullptr, true); if (str::IsEmpty(sv)) { log("TryUploadCrashReport(): skipping because !BuildCrashInfoText()\n"); return; diff --git a/src/SumatraPDF.cpp b/src/SumatraPDF.cpp index 7b7328583ac..9232673b7e3 100644 --- a/src/SumatraPDF.cpp +++ b/src/SumatraPDF.cpp @@ -3294,8 +3294,8 @@ static TempWStr GetFileFilterTemp() { } fileFilter.Append(_TRA("All files")); fileFilter.Append("\1*.*\1"); - str::TransCharsInPlace(fileFilter.Get(), "\1", "\0"); - return ToWStrTemp(fileFilter.CStr()); + str::TransCharsInPlace(fileFilter.CStr(), "\1", "\0"); + return ToWStrTemp(fileFilter); } static void OpenFile(MainWindow* win) { diff --git a/src/utils/BaseUtil.h b/src/utils/BaseUtil.h index 1641bed798f..1e2aa9331e1 100644 --- a/src/utils/BaseUtil.h +++ b/src/utils/BaseUtil.h @@ -272,21 +272,21 @@ inline void CrashIfFunc(bool cond) { } \ } while (0) -#define ReportIf(cond) \ - __analysis_assume(!(cond)); \ - do { \ - if (cond) { \ - _uploadDebugReport(#cond, true); \ - } \ - } while (0) - -#define ReportIfQuick(cond) \ +#define ReportIf(cond) \ + __analysis_assume(!(cond)); \ do { \ if (cond) { \ _uploadDebugReport(#cond, false); \ } \ } while (0) +#define ReportIfQuick(cond) \ + do { \ + if (cond) { \ + _uploadDebugReport(#cond, true); \ + } \ + } while (0) + void* AllocZero(size_t count, size_t size); template