+ 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:
wmayer
2015-09-19 18:59:22 +02:00
parent 55916175d3
commit eb05da7cd7
6 changed files with 90 additions and 20 deletions

View File

@@ -52,11 +52,22 @@ std::string DocumentPy::representation(void) const
PyObject* DocumentPy::save(PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
return NULL; // NULL triggers exception
if (!getDocumentPtr()->save()) {
PyErr_Format(PyExc_ValueError, "Object attribute 'FileName' is not set");
return NULL;
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
return NULL; // NULL triggers exception
try {
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();
@@ -72,11 +83,22 @@ PyObject* DocumentPy::save(PyObject * args)
PyObject* DocumentPy::saveAs(PyObject * args)
{
char* fn;
if (!PyArg_ParseTuple(args, "s", &fn)) // convert args: Python->C
return NULL; // NULL triggers exception
if (!getDocumentPtr()->saveAs(fn)) {
PyErr_Format(PyExc_ValueError, "Object attribute 'FileName' is not set");
return NULL;
if (!PyArg_ParseTuple(args, "s", &fn)) // convert args: Python->C
return NULL; // NULL triggers exception
try {
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);