+ fixes #0001237: the project file is not saved when the /tmp directory is full, but the user is not aware of it
This commit is contained in:
parent
bd1fc886fe
commit
7d09444dd9
|
@ -1075,6 +1075,10 @@ bool Document::save (void)
|
||||||
// write additional files
|
// write additional files
|
||||||
writer.writeFiles();
|
writer.writeFiles();
|
||||||
|
|
||||||
|
if (writer.hasErrors()) {
|
||||||
|
throw Base::FileException("Failed to write all data to file", tmp);
|
||||||
|
}
|
||||||
|
|
||||||
GetApplication().signalSaveDocument(*this);
|
GetApplication().signalSaveDocument(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,11 +52,22 @@ std::string DocumentPy::representation(void) const
|
||||||
|
|
||||||
PyObject* DocumentPy::save(PyObject * args)
|
PyObject* DocumentPy::save(PyObject * args)
|
||||||
{
|
{
|
||||||
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
|
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
|
||||||
return NULL; // NULL triggers exception
|
return NULL; // NULL triggers exception
|
||||||
if (!getDocumentPtr()->save()) {
|
|
||||||
PyErr_Format(PyExc_ValueError, "Object attribute 'FileName' is not set");
|
try {
|
||||||
return NULL;
|
if (!getDocumentPtr()->save()) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "Object attribute 'FileName' is not set");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const Base::FileException& e) {
|
||||||
|
PyErr_SetString(PyExc_IOError, e.what());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
catch (const Base::Exception& e) {
|
||||||
|
PyErr_SetString(PyExc_RuntimeError, e.what());
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* filename = getDocumentPtr()->FileName.getValue();
|
const char* filename = getDocumentPtr()->FileName.getValue();
|
||||||
|
@ -72,11 +83,22 @@ PyObject* DocumentPy::save(PyObject * args)
|
||||||
PyObject* DocumentPy::saveAs(PyObject * args)
|
PyObject* DocumentPy::saveAs(PyObject * args)
|
||||||
{
|
{
|
||||||
char* fn;
|
char* fn;
|
||||||
if (!PyArg_ParseTuple(args, "s", &fn)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args, "s", &fn)) // convert args: Python->C
|
||||||
return NULL; // NULL triggers exception
|
return NULL; // NULL triggers exception
|
||||||
if (!getDocumentPtr()->saveAs(fn)) {
|
|
||||||
PyErr_Format(PyExc_ValueError, "Object attribute 'FileName' is not set");
|
try {
|
||||||
return NULL;
|
if (!getDocumentPtr()->saveAs(fn)) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "Object attribute 'FileName' is not set");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const Base::FileException& e) {
|
||||||
|
PyErr_SetString(PyExc_IOError, e.what());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
catch (const Base::Exception& e) {
|
||||||
|
PyErr_SetString(PyExc_RuntimeError, e.what());
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Base::FileInfo fi(fn);
|
Base::FileInfo fi(fn);
|
||||||
|
|
|
@ -141,6 +141,26 @@ void Writer::clearModes()
|
||||||
Modes.clear();
|
Modes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Writer::addError(const std::string& msg)
|
||||||
|
{
|
||||||
|
Errors.push_back(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Writer::hasErrors() const
|
||||||
|
{
|
||||||
|
return (!Errors.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Writer::clearErrors()
|
||||||
|
{
|
||||||
|
Errors.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> Writer::getErrors() const
|
||||||
|
{
|
||||||
|
return Errors;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Writer::addFile(const char* Name,const Base::Persistence *Object)
|
std::string Writer::addFile(const char* Name,const Base::Persistence *Object)
|
||||||
{
|
{
|
||||||
// always check isForceXML() before requesting a file!
|
// always check isForceXML() before requesting a file!
|
||||||
|
|
|
@ -95,6 +95,14 @@ public:
|
||||||
void clearModes();
|
void clearModes();
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
/** @name Error handling */
|
||||||
|
//@{
|
||||||
|
void addError(const std::string&);
|
||||||
|
bool hasErrors() const;
|
||||||
|
void clearErrors();
|
||||||
|
std::vector<std::string> getErrors() const;
|
||||||
|
//@}
|
||||||
|
|
||||||
/** @name pretty formating for XML */
|
/** @name pretty formating for XML */
|
||||||
//@{
|
//@{
|
||||||
/// get the current indentation
|
/// get the current indentation
|
||||||
|
@ -118,6 +126,7 @@ protected:
|
||||||
};
|
};
|
||||||
std::vector<FileEntry> FileList;
|
std::vector<FileEntry> FileList;
|
||||||
std::vector<std::string> FileNames;
|
std::vector<std::string> FileNames;
|
||||||
|
std::vector<std::string> Errors;
|
||||||
std::set<std::string> Modes;
|
std::set<std::string> Modes;
|
||||||
|
|
||||||
short indent;
|
short indent;
|
||||||
|
|
|
@ -605,10 +605,16 @@ App::Document* Document::getDocument(void) const
|
||||||
bool Document::save(void)
|
bool Document::save(void)
|
||||||
{
|
{
|
||||||
if (d->_pcDocument->isSaved()) {
|
if (d->_pcDocument->isSaved()) {
|
||||||
Gui::WaitCursor wc;
|
try {
|
||||||
Command::doCommand(Command::Doc,"App.getDocument(\"%s\").save()"
|
Gui::WaitCursor wc;
|
||||||
,d->_pcDocument->getName());
|
Command::doCommand(Command::Doc,"App.getDocument(\"%s\").save()"
|
||||||
setModified(false);
|
,d->_pcDocument->getName());
|
||||||
|
setModified(false);
|
||||||
|
}
|
||||||
|
catch (const Base::Exception& e) {
|
||||||
|
QMessageBox::critical(getMainWindow(), QObject::tr("Saving document failed"),
|
||||||
|
QString::fromLatin1(e.what()));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -631,12 +637,17 @@ bool Document::saveAs(void)
|
||||||
const char * DocName = App::GetApplication().getDocumentName(getDocument());
|
const char * DocName = App::GetApplication().getDocumentName(getDocument());
|
||||||
|
|
||||||
// save as new file name
|
// save as new file name
|
||||||
Gui::WaitCursor wc;
|
try {
|
||||||
Command::doCommand(Command::Doc,"App.getDocument(\"%s\").saveAs(\"%s\")"
|
Gui::WaitCursor wc;
|
||||||
, DocName, (const char*)fn.toUtf8());
|
Command::doCommand(Command::Doc,"App.getDocument(\"%s\").saveAs(\"%s\")"
|
||||||
setModified(false);
|
, DocName, (const char*)fn.toUtf8());
|
||||||
|
setModified(false);
|
||||||
getMainWindow()->appendRecentFile(fi.filePath());
|
getMainWindow()->appendRecentFile(fi.filePath());
|
||||||
|
}
|
||||||
|
catch (const Base::Exception& e) {
|
||||||
|
QMessageBox::critical(getMainWindow(), QObject::tr("Saving document failed"),
|
||||||
|
QString::fromLatin1(e.what()));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -294,6 +294,10 @@ void PropertyPartShape::SaveDocFile (Base::Writer &writer) const
|
||||||
else {
|
else {
|
||||||
Base::Console().Error("Cannot save BRep file '%s'\n", fi.filePath().c_str());
|
Base::Console().Error("Cannot save BRep file '%s'\n", fi.filePath().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Cannot save BRep file '" << fi.filePath() << "'";
|
||||||
|
writer.addError(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
Base::ifstream file(fi, std::ios::in | std::ios::binary);
|
Base::ifstream file(fi, std::ios::in | std::ios::binary);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user