From be452dd2f2d906061f9de5bfb46fa43bcdec40ed Mon Sep 17 00:00:00 2001 From: Krzysztof Kowalczyk Date: Tue, 28 May 2024 05:07:24 +0200 Subject: [PATCH] rename CrashIf() => ReportIf --- src/Accelerators.cpp | 10 +-- src/Annotation.cpp | 16 ++--- src/AppColors.cpp | 2 +- src/AppSettings.cpp | 10 +-- src/Canvas.cpp | 22 +++---- src/CanvasAboutUI.cpp | 2 +- src/ChmFile.cpp | 8 +-- src/ChmModel.cpp | 20 +++--- src/CommandPalette.cpp | 12 ++-- src/Commands.cpp | 2 +- src/CrashHandler.cpp | 2 +- src/DisplayMode.cpp | 4 +- src/DisplayModel.cpp | 86 ++++++++++++------------- src/DocController.h | 2 +- src/DocProperties.cpp | 4 +- src/EbookDoc.cpp | 12 ++-- src/EbookFormatter.cpp | 16 ++--- src/EditAnnotations.cpp | 32 +++++----- src/EngineBase.cpp | 6 +- src/EngineBase.h | 4 +- src/EngineCreate.cpp | 2 +- src/EngineDjVu.cpp | 22 +++---- src/EngineDump.cpp | 2 +- src/EngineEbook.cpp | 24 +++---- src/EngineImages.cpp | 26 ++++---- src/EngineMulti.cpp | 10 +-- src/EngineMupdf.cpp | 84 ++++++++++++------------ src/EnginePs.cpp | 2 +- src/ExternalViewers.cpp | 2 +- src/Favorites.cpp | 18 +++--- src/FileHistory.cpp | 8 +-- src/FileThumbnails.cpp | 4 +- src/Flags.cpp | 2 +- src/GlobalPrefs.cpp | 2 +- src/HomePage.cpp | 10 +-- src/HtmlFormatter.cpp | 58 ++++++++--------- src/HtmlFormatter.h | 2 +- src/Installer.cpp | 6 +- src/MainWindow.cpp | 22 +++---- src/Menu.cpp | 28 ++++---- src/MobiDoc.cpp | 28 ++++---- src/Notifications.cpp | 10 +-- src/PalmDbReader.cpp | 6 +- src/PdfCreator.cpp | 4 +- src/PdfSync.cpp | 6 +- src/RegistryInstaller.cpp | 2 +- src/RenderCache.cpp | 52 +++++++-------- src/Scratch.cpp | 10 +-- src/SearchAndDDE.cpp | 12 ++-- src/Selection.cpp | 16 ++--- src/StressTesting.cpp | 12 ++-- src/SumatraDialogs.cpp | 16 ++--- src/SumatraPDF.cpp | 109 +++++++++++++++++--------------- src/SumatraProperties.cpp | 14 ++-- src/SumatraStartup.cpp | 24 +++---- src/SvgIcons.cpp | 2 +- src/TableOfContents.cpp | 18 +++--- src/Tabs.cpp | 16 ++--- src/TextSearch.cpp | 2 +- src/TextSelection.cpp | 16 ++--- src/Theme.cpp | 2 +- src/Toolbar.cpp | 4 +- src/Translations.cpp | 16 ++--- src/Uninstaller.cpp | 2 +- src/UpdateCheck.cpp | 4 +- src/Widget.cpp | 2 +- src/WindowTab.cpp | 10 +-- src/ifilter/SearchFilterDll.cpp | 2 +- src/mui/Mui.cpp | 14 ++-- src/mui/TextRender.cpp | 38 +++++------ src/previewer/PdfPreviewDll.cpp | 2 +- src/regress/Regress.cpp | 4 +- src/regress/Regress03.cpp | 10 +-- src/scratch.txt | 2 +- src/testcode/TestApp.cpp | 4 +- src/testcode/test-app.cpp | 6 +- src/tools/MakeLzSA.cpp | 12 ++-- src/uia/DocumentProvider.cpp | 18 +++--- src/uia/PageProvider.cpp | 4 +- src/uia/Provider.cpp | 4 +- src/uia/StartPageProvider.cpp | 4 +- src/uia/TextRange.cpp | 14 ++-- src/utils/Archive.cpp | 16 ++--- src/utils/BaseUtil.cpp | 22 +++---- src/utils/BaseUtil.h | 6 +- src/utils/BitReader.cpp | 2 +- src/utils/ColorUtil.cpp | 2 +- src/utils/CryptoUtil.cpp | 20 +++--- src/utils/CssParser.cpp | 6 +- src/utils/DbgHelpDyn.cpp | 2 +- src/utils/Dict.cpp | 8 +-- src/utils/DirIter.cpp | 4 +- src/utils/Dpi.cpp | 2 +- src/utils/FileUtil.cpp | 8 +-- src/utils/FileWatcher.cpp | 16 ++--- src/utils/GdiPlusUtil.cpp | 20 +++--- src/utils/GeomUtil.cpp | 2 +- src/utils/GuessFileType.cpp | 2 +- src/utils/HtmlPrettyPrint.cpp | 2 +- src/utils/HtmlPullParser.cpp | 12 ++-- src/utils/HtmlWindow.cpp | 50 +++++++-------- src/utils/Log.cpp | 2 +- src/utils/ScopedWin.h | 8 +-- src/utils/SettingsUtil.cpp | 16 ++--- src/utils/SquareTreeParser.cpp | 2 +- src/utils/StrFormat.cpp | 28 ++++---- src/utils/StrQueue.cpp | 2 +- src/utils/StrUtil.cpp | 36 +++++------ src/utils/StrVec.cpp | 26 ++++---- src/utils/StrconvUtil.cpp | 4 +- src/utils/TempAllocator.cpp | 4 +- src/utils/TgaReader.cpp | 4 +- src/utils/ThreadUtil.cpp | 2 +- src/utils/TrivialHtmlParser.cpp | 6 +- src/utils/UITask.cpp | 4 +- src/utils/Vec.h | 30 ++++----- src/utils/WinUtil.cpp | 62 +++++++++--------- src/utils/ZipUtil.cpp | 14 ++-- src/utils/tests/Dict_ut.cpp | 4 +- src/utils/windrawlib.cpp | 2 +- src/wingui/FrameRateWnd.cpp | 4 +- src/wingui/Layout.cpp | 16 ++--- src/wingui/WinGui.cpp | 108 +++++++++++++++---------------- 123 files changed, 874 insertions(+), 871 deletions(-) diff --git a/src/Accelerators.cpp b/src/Accelerators.cpp index 49ef6136fa6..db482cb37bd 100644 --- a/src/Accelerators.cpp +++ b/src/Accelerators.cpp @@ -266,7 +266,7 @@ static WORD ParseVirtKey(const char* s) { if (idx < 0) { return 0; } - CrashIf(idx >= dimof(gVirtKeysIds)); + ReportIf(idx >= dimof(gVirtKeysIds)); WORD keyId = gVirtKeysIds[idx]; return keyId; } @@ -600,7 +600,7 @@ static HACCEL gAccelTables[3] = { /* returns a pointer to HACCEL so that we can update it and message loop will use the latest version */ static void CreateSumatraAcceleratorTable() { - CrashIf(gAccelTables[0] || gAccelTables[1] || gAccelTables[2]); + ReportIf(gAccelTables[0] || gAccelTables[1] || gAccelTables[2]); int nBuiltIn = (int)dimof(gBuiltInAccelerators); @@ -671,11 +671,11 @@ static void CreateSumatraAcceleratorTable() { gAccelsCount = nAccels; gAccelTables[0] = CreateAcceleratorTableW(gAccels, gAccelsCount); - CrashIf(gAccelTables[0] == nullptr); + ReportIf(gAccelTables[0] == nullptr); gAccelTables[1] = CreateAcceleratorTableW(editAccels, nEditAccels); - CrashIf(gAccelTables[1] == nullptr); + ReportIf(gAccelTables[1] == nullptr); gAccelTables[2] = CreateAcceleratorTableW(treeViewAccels, nTreeViewAccels); - CrashIf(gAccelTables[2] == nullptr); + ReportIf(gAccelTables[2] == nullptr); free(toFreeAccels); } diff --git a/src/Annotation.cpp b/src/Annotation.cpp index 836588d68ed..cfba5f4943a 100644 --- a/src/Annotation.cpp +++ b/src/Annotation.cpp @@ -109,12 +109,12 @@ static const char* gAnnotReadableNames = /* const char* AnnotationName(AnnotationType tp) { int n = (int)tp; - CrashIf(n < -1 || n > (int)AnnotationType::ThreeD); + ReportIf(n < -1 || n > (int)AnnotationType::ThreeD); if (n < 0) { return "Unknown"; } const char* s = seqstrings::IdxToStr(gAnnotNames, n); - CrashIf(!s); + ReportIf(!s); return s; } */ @@ -132,7 +132,7 @@ TempStr AnnotationReadableNameTemp(AnnotationType tp) { return (char*)"Unknown"; } char* s = (char*)seqstrings::IdxToStr(gAnnotReadableNames, n); - CrashIf(!s); + ReportIf(!s); return s; } @@ -144,12 +144,12 @@ bool IsAnnotationEq(Annotation* a1, Annotation* a2) { } AnnotationType Type(Annotation* annot) { - CrashIf((int)annot->type < 0); + ReportIf((int)annot->type < 0); return annot->type; } int PageNo(Annotation* annot) { - CrashIf(annot->pageNo < 1); + ReportIf(annot->pageNo < 1); return annot->pageNo; } @@ -246,7 +246,7 @@ bool SetQuadding(Annotation* annot, int newQuadding) { { auto ctx = e->Ctx(); ScopedCritSec cs(e->ctxAccess); - CrashIf(!IsValidQuadding(newQuadding)); + ReportIf(!IsValidQuadding(newQuadding)); bool didChange = Quadding(annot) != newQuadding; if (!didChange) { return false; @@ -513,7 +513,7 @@ static PdfColor PdfColorFromFloat(fz_context* ctx, int n, float color[4]) { } return MkPdfColorFromFloat(rgb[0], rgb[1], rgb[2]); } - CrashIf(true); + ReportIf(true); return 0; } @@ -872,7 +872,7 @@ void SetOpacity(Annotation* annot, int newOpacity) { { auto ctx = e->Ctx(); ScopedCritSec cs(e->ctxAccess); - CrashIf(newOpacity < 0 || newOpacity > 255); + ReportIf(newOpacity < 0 || newOpacity > 255); newOpacity = std::clamp(newOpacity, 0, 255); float fopacity = (float)newOpacity / 255.f; diff --git a/src/AppColors.cpp b/src/AppColors.cpp index 770f0ca46a9..a988b9fbbdb 100644 --- a/src/AppColors.cpp +++ b/src/AppColors.cpp @@ -28,6 +28,6 @@ #define ABOUT_BG_GRAY_COLOR RGB(0xF2, 0xF2, 0xF2) COLORREF GetAppColor(AppColor col) { - CrashIf(true); + ReportIf(true); return 0; } diff --git a/src/AppSettings.cpp b/src/AppSettings.cpp index 11d9eb0a983..2b90777e40f 100644 --- a/src/AppSettings.cpp +++ b/src/AppSettings.cpp @@ -61,7 +61,7 @@ static int GetWeekCount() { date20110101.wDay = 1; FILETIME origTime, currTime; BOOL ok = SystemTimeToFileTime(&date20110101, &origTime); - CrashIf(!ok); + ReportIf(!ok); GetSystemTimeAsFileTime(&currTime); return (currTime.dwHighDateTime - origTime.dwHighDateTime) / 1408; // 1408 == (10 * 1000 * 1000 * 60 * 60 * 24 * 7) / (1 << 32) @@ -96,7 +96,7 @@ static void setMinMax(int& i, int minVal, int maxVal) { /* Caller needs to CleanUpSettings() */ bool LoadSettings() { - CrashIf(gGlobalPrefs); + ReportIf(gGlobalPrefs); auto timeStart = TimeGet(); @@ -118,7 +118,7 @@ bool LoadSettings() { gprefs->lastPrefUpdate = file::GetModificationTime(settingsPath); gprefs->defaultDisplayModeEnum = DisplayModeFromString(gprefs->defaultDisplayMode, DisplayMode::Automatic); gprefs->defaultZoomFloat = ZoomFromString(gprefs->defaultZoom, kZoomActualSize); - CrashIf(!IsValidZoom(gprefs->defaultZoomFloat)); + ReportIf(!IsValidZoom(gprefs->defaultZoomFloat)); int weekDiff = GetWeekCount() - gprefs->openCountWeek; gprefs->openCountWeek = GetWeekCount(); @@ -272,7 +272,7 @@ bool SaveSettings() { str::Free(prevPrefs.data()); str::Free(prefs.data()); }; - CrashIf(prefs.empty()); + ReportIf(prefs.empty()); if (prefs.empty()) { return false; } @@ -371,7 +371,7 @@ void RegisterSettingsForFileChanges() { return; } - CrashIf(gWatchedSettingsFile); // only call me once + ReportIf(gWatchedSettingsFile); // only call me once TempStr path = GetSettingsPathTemp(); gWatchedSettingsFile = FileWatcherSubscribe(path, schedulePrefsReload); } diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 2b26191d436..471f2807875 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -89,7 +89,7 @@ void UpdateDeltaPerLine() { ///// methods needed for FixedPageUI canvases with document loaded ///// static void OnVScroll(MainWindow* win, WPARAM wp) { - CrashIf(!win->AsFixed()); + ReportIf(!win->AsFixed()); SCROLLINFO si{}; si.cbSize = sizeof(si); @@ -154,7 +154,7 @@ static void OnVScroll(MainWindow* win, WPARAM wp) { } static void OnHScroll(MainWindow* win, WPARAM wp) { - CrashIf(!win->AsFixed()); + ReportIf(!win->AsFixed()); SCROLLINFO si{}; si.cbSize = sizeof(si); @@ -307,7 +307,7 @@ static bool gShowAnnotationNotification = true; static void OnMouseMove(MainWindow* win, int x, int y, WPARAM) { DisplayModel* dm = win->AsFixed(); - CrashIf(!dm); + ReportIf(!dm); if (win->InPresentation()) { if (PM_BLACK_SCREEN == win->presentation || PM_WHITE_SCREEN == win->presentation) { @@ -471,7 +471,7 @@ static void OnMouseLeftButtonDown(MainWindow* win, int x, int y, WPARAM key) { if (isMoveableAnnot) { StartAnnotationDrag(win, annot, pt); } else { - CrashIf(win->linkOnLastButtonDown); + ReportIf(win->linkOnLastButtonDown); IPageElement* pageEl = dm->GetElementAtPos(pt, nullptr); if (pageEl) { if (pageEl->Is(kindPageElementDest)) { @@ -502,7 +502,7 @@ static void OnMouseLeftButtonDown(MainWindow* win, int x, int y, WPARAM key) { static void OnMouseLeftButtonUp(MainWindow* win, int x, int y, WPARAM key) { DisplayModel* dm = win->AsFixed(); - CrashIf(!dm); + ReportIf(!dm); auto ma = win->mouseAction; if (MouseAction::None == ma || IsRightDragging(win)) { return; @@ -691,7 +691,7 @@ static void OnMouseRightButtonDown(MainWindow* win, int x, int y) { } else if (win->mouseAction != MouseAction::None) { return; } - CrashIf(!win->AsFixed()); + ReportIf(!win->AsFixed()); SetFocus(win->hwndFrame); @@ -702,7 +702,7 @@ static void OnMouseRightButtonDown(MainWindow* win, int x, int y) { } static void OnMouseRightButtonUp(MainWindow* win, int x, int y, WPARAM key) { - CrashIf(!win->AsFixed()); + ReportIf(!win->AsFixed()); if (!IsRightDragging(win)) { return; } @@ -883,7 +883,7 @@ NO_INLINE static void PaintCurrentEditAnnotationMark(WindowTab* tab, HDC hdc, Di } static void DrawDocument(MainWindow* win, HDC hdc, RECT* rcArea) { - CrashIf(!win->AsFixed()); + ReportIf(!win->AsFixed()); if (!win->AsFixed()) { return; } @@ -970,7 +970,7 @@ static void DrawDocument(MainWindow* win, HDC hdc, RECT* rcArea) { if (!pageInfo || 0.0f == pageInfo->visibleRatio) { continue; } - CrashIf(!pageInfo->shown); + ReportIf(!pageInfo->shown); if (!pageInfo->shown) { continue; } @@ -1121,7 +1121,7 @@ static LRESULT OnSetCursorMouseNone(MainWindow* win, HWND hwnd) { } static LRESULT OnSetCursor(MainWindow* win, HWND hwnd) { - CrashIf(win->hwndCanvas != hwnd); + ReportIf(win->hwndCanvas != hwnd); if (win->mouseAction != MouseAction::None) { win->DeleteToolTip(); } @@ -1851,7 +1851,7 @@ LRESULT CALLBACK WndProcCanvas(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { MainWindow* win = FindMainWindowByHwnd(hwnd); switch (msg) { case WM_DROPFILES: - CrashIf(lp != 0 && lp != 1); + ReportIf(lp != 0 && lp != 1); OnDropFiles(win, (HDROP)wp, !lp); return 0; diff --git a/src/CanvasAboutUI.cpp b/src/CanvasAboutUI.cpp index e09cfe208e6..40fb7e29f9d 100644 --- a/src/CanvasAboutUI.cpp +++ b/src/CanvasAboutUI.cpp @@ -89,7 +89,7 @@ static void OnMouseLeftButtonUpAbout(MainWindow* win, int x, int y, WPARAM) { } else { // assume it's a thumbnail of a document auto path = url; - CrashIf(!path); + ReportIf(!path); LoadArgs args(path, win); // ctrl forces always opening args.activateExisting = !IsCtrlPressed(); diff --git a/src/ChmFile.cpp b/src/ChmFile.cpp index a9d8856b363..6ee23ee9361 100644 --- a/src/ChmFile.cpp +++ b/src/ChmFile.cpp @@ -96,7 +96,7 @@ static char* GetCharZ(const ByteSlice& d, size_t off) { if (off >= len) { return nullptr; } - CrashIf(!memchr(data + off, '\0', len - off + 1)); // data is zero-terminated + ReportIf(!memchr(data + off, '\0', len - off + 1)); // data is zero-terminated u8* str = data + off; if (str::IsEmpty((const char*)str)) { return nullptr; @@ -367,7 +367,7 @@ void ChmFile::GetAllPaths(StrVec* v) const { ... siblings ... */ static bool VisitChmTocItem(EbookTocVisitor* visitor, HtmlElement* el, uint cp, int level) { - CrashIf(el->tag != Tag_Object || level > 1 && (!el->up || el->up->tag != Tag_Li)); + ReportIf(el->tag != Tag_Object || level > 1 && (!el->up || el->up->tag != Tag_Li)); AutoFreeWStr name, local; for (el = el->GetChildByTag(Tag_Param); el; el = el->next) { @@ -416,7 +416,7 @@ static bool VisitChmTocItem(EbookTocVisitor* visitor, HtmlElement* el, uint cp, ... siblings ... */ static bool VisitChmIndexItem(EbookTocVisitor* visitor, HtmlElement* el, uint cp, int level) { - CrashIf(el->tag != Tag_Object || level > 1 && (!el->up || el->up->tag != Tag_Li)); + ReportIf(el->tag != Tag_Object || level > 1 && (!el->up || el->up->tag != Tag_Li)); StrVec references; AutoFreeWStr keyword, name; @@ -471,7 +471,7 @@ static bool VisitChmIndexItem(EbookTocVisitor* visitor, HtmlElement* el, uint cp } static void WalkChmTocOrIndex(EbookTocVisitor* visitor, HtmlElement* list, uint cp, bool isIndex, int level = 1) { - CrashIf(Tag_Ul != list->tag); + ReportIf(Tag_Ul != list->tag); // some broken ToCs wrap every
  • into its own