summaryrefslogtreecommitdiff
path: root/indra/newview/llsnapshotlivepreview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llsnapshotlivepreview.cpp')
-rw-r--r--indra/newview/llsnapshotlivepreview.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp
index 58e48480c1..c6f8c414fa 100644
--- a/indra/newview/llsnapshotlivepreview.cpp
+++ b/indra/newview/llsnapshotlivepreview.cpp
@@ -45,6 +45,7 @@
#include "llimagepng.h"
#include "lllandmarkactions.h"
#include "lllocalcliprect.h"
+#include "llresmgr.h"
#include "llnotificationsutil.h"
#include "llslurl.h"
#include "llsnapshotlivepreview.h"
@@ -56,6 +57,7 @@
#include "llvfs.h"
#include "llwindow.h"
#include "llworld.h"
+#include <boost/filesystem.hpp>
const F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f;
@@ -1069,7 +1071,7 @@ BOOL LLSnapshotLivePreview::saveLocal()
getFormattedImage();
// Save the formatted image
- BOOL success = gViewerWindow->saveImageNumbered(mFormattedImage);
+ BOOL success = saveLocal(mFormattedImage);
if(success)
{
@@ -1078,3 +1080,37 @@ BOOL LLSnapshotLivePreview::saveLocal()
return success;
}
+//Check if failed due to insuficient memory
+BOOL LLSnapshotLivePreview::saveLocal(LLPointer<LLImageFormatted> mFormattedImage)
+{
+ BOOL success = gViewerWindow->saveImageNumbered(mFormattedImage);
+
+ if (!success)
+ {
+ std::string lastSnapshotDir = LLViewerWindow::getLastSnapshotDir();
+
+#ifdef LL_WINDOWS
+ boost::filesystem::path b_path(utf8str_to_utf16str(lastSnapshotDir));
+#else
+ boost::filesystem::path b_path(lastSnapshotDir);
+#endif
+ boost::filesystem::space_info b_space = boost::filesystem::space(b_path);
+ if (b_space.free < mFormattedImage->getDataSize())
+ {
+ LLSD args;
+ args["PATH"] = lastSnapshotDir;
+
+ std::string needM_bytes_string;
+ LLResMgr::getInstance()->getIntegerString(needM_bytes_string, (mFormattedImage->getDataSize()) >> 10);
+ args["NEED_MEMORY"] = needM_bytes_string;
+
+ std::string freeM_bytes_string;
+ LLResMgr::getInstance()->getIntegerString(freeM_bytes_string, (b_space.free) >> 10);
+ args["FREE_MEMORY"] = freeM_bytes_string;
+
+ LLNotificationsUtil::add("SnapshotToComputerFailed", args);
+ return false;
+ }
+ }
+ return success;
+}