summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaianakproductengine <daianakproductengine@lindenlab.com>2017-05-24 16:33:39 +0300
committerdaianakproductengine <daianakproductengine@lindenlab.com>2017-05-24 16:33:39 +0300
commitf82785a9b275b78b47cdebaf2ccfc8aa9407c405 (patch)
tree3cd0b01a8e6b552708ef936d6855cd0602bd2ebf
parenta6cda1ee06ee422d39b8bc9ba9369e14ec3f1251 (diff)
MAINT-4375 Viewer saves an empty snapshots if disk is full
-rw-r--r--indra/newview/llpanelsnapshotlocal.cpp1
-rw-r--r--indra/newview/llsnapshotlivepreview.cpp38
-rw-r--r--indra/newview/llsnapshotlivepreview.h1
-rw-r--r--indra/newview/llviewermenufile.cpp2
-rw-r--r--indra/newview/llviewerwindow.cpp11
-rw-r--r--indra/newview/llviewerwindow.h1
-rw-r--r--indra/newview/skins/default/xui/en/notifications.xml5
7 files changed, 57 insertions, 2 deletions
diff --git a/indra/newview/llpanelsnapshotlocal.cpp b/indra/newview/llpanelsnapshotlocal.cpp
index 51ec964ace..77378f8092 100644
--- a/indra/newview/llpanelsnapshotlocal.cpp
+++ b/indra/newview/llpanelsnapshotlocal.cpp
@@ -172,6 +172,7 @@ void LLPanelSnapshotLocal::onSaveFlyoutCommit(LLUICtrl* ctrl)
}
else
{
+ cancel();
floater->notify(LLSD().with("set-finished", LLSD().with("ok", false).with("msg", "local")));
}
}
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;
+}
diff --git a/indra/newview/llsnapshotlivepreview.h b/indra/newview/llsnapshotlivepreview.h
index b689c50320..4ea8d25a5a 100644
--- a/indra/newview/llsnapshotlivepreview.h
+++ b/indra/newview/llsnapshotlivepreview.h
@@ -41,6 +41,7 @@ class LLSnapshotLivePreview : public LLView
LOG_CLASS(LLSnapshotLivePreview);
public:
+ static BOOL saveLocal(LLPointer<LLImageFormatted>);
struct Params : public LLInitParam::Block<Params, LLView::Params>
{
Params()
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index d46bb0199b..8d0c5af314 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -583,7 +583,7 @@ class LLFileTakeSnapshotToDisk : public view_listener_t
formatted->enableOverSize() ;
formatted->encode(raw, 0);
formatted->disableOverSize() ;
- gViewerWindow->saveImageNumbered(formatted);
+ LLSnapshotLivePreview::saveLocal(formatted);
}
return true;
}
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 2d3b48bab3..45ea0f8e02 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -33,6 +33,7 @@
#include <iostream>
#include <fstream>
#include <algorithm>
+#include <boost/filesystem.hpp>
#include <boost/lambda/core.hpp>
#include <boost/regex.hpp>
@@ -4398,6 +4399,16 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image, bool force_picke
LLViewerWindow::sSnapshotDir = gDirUtilp->getDirName(filepath);
}
+// Check if there is enough free space to save snapshot
+#ifdef LL_WINDOWS
+ boost::filesystem::space_info b_space = boost::filesystem::space(utf8str_to_utf16str(sSnapshotDir));
+#else
+ boost::filesystem::space_info b_space = boost::filesystem::space(sSnapshotDir);
+#endif
+ if (b_space.free < image->getDataSize())
+ {
+ return FALSE;
+ }
// Look for an unused file name
std::string filepath;
S32 i = 1;
diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h
index a134dfaaa9..5d7076178a 100644
--- a/indra/newview/llviewerwindow.h
+++ b/indra/newview/llviewerwindow.h
@@ -419,6 +419,7 @@ public:
bool getSystemUIScaleFactorChanged() { return mSystemUIScaleFactorChanged; }
static void showSystemUIScaleFactorChanged();
+ static std::string getLastSnapshotDir() { return sSnapshotDir; }
private:
bool shouldShowToolTipFor(LLMouseHandler *mh);
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 91f3b7456f..b413720bc9 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -8533,6 +8533,11 @@ Appearance has been saved to XML to [PATH]
Failed to save appearance to XML.
</notification>
+ <notification icon="notifytip.tga"
+ name="SnapshotToComputerFailed" type="notifytip">
+Failed to save snapshot to [PATH]: Not enough memory. [NEED_MEMORY]KB is required but only [FREE_MEMORY]KB is free.
+ </notification>
+
<notification
icon="notifytip.tga"
name="PresetNotSaved"