From 5e905cf80d472c433875452a2baaa179ceb0fe71 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 9 Jun 2017 18:16:58 +0300 Subject: MAINT-7477 FIXED [viewer-neko] Viewer crashes when saving snapshot to disk and closing file picker window --- indra/newview/llsnapshotlivepreview.cpp | 7 ++++--- indra/newview/llviewerwindow.cpp | 5 ++++- indra/newview/llviewerwindow.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index c6f8c414fa..ee8b2d79c0 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -1080,12 +1080,13 @@ BOOL LLSnapshotLivePreview::saveLocal() return success; } -//Check if failed due to insuficient memory +//Check if failed due to insufficient memory BOOL LLSnapshotLivePreview::saveLocal(LLPointer mFormattedImage) { - BOOL success = gViewerWindow->saveImageNumbered(mFormattedImage); + BOOL insufficient_memory; + BOOL success = gViewerWindow->saveImageNumbered(mFormattedImage, FALSE, insufficient_memory); - if (!success) + if (insufficient_memory) { std::string lastSnapshotDir = LLViewerWindow::getLastSnapshotDir(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 45ea0f8e02..a2c5fa2630 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4354,8 +4354,10 @@ BOOL LLViewerWindow::mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d } // Saves an image to the harddrive as "SnapshotX" where X >= 1. -BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image, bool force_picker) +BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image, BOOL force_picker, BOOL& insufficient_memory) { + insufficient_memory = FALSE; + if (!image) { LL_WARNS() << "No image to save" << LL_ENDL; @@ -4407,6 +4409,7 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image, bool force_picke #endif if (b_space.free < image->getDataSize()) { + insufficient_memory = TRUE; return FALSE; } // Look for an unused file name diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 5d7076178a..38178fa910 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -352,7 +352,7 @@ public: BOOL thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type); BOOL isSnapshotLocSet() const { return ! sSnapshotDir.empty(); } void resetSnapshotLoc() const { sSnapshotDir.clear(); } - BOOL saveImageNumbered(LLImageFormatted *image, bool force_picker = false); + BOOL saveImageNumbered(LLImageFormatted *image, BOOL force_picker, BOOL& insufficient_memory); // Reset the directory where snapshots are saved. // Client will open directory picker on next snapshot save. -- cgit v1.2.3