Core: Fixed a bug where an empty document disappears (#20554)

* Core: Fixed a bug where an empty document disappears

Created a flag named autoCreated to distinguish an autoCreated
document created in the startup from a manually document.
Implemented a setter and a getter for this new flag.
Added a codition that verifies if a document is autoCreated
when opening another document to close it in the correct case.
Implemented unit tests for theses cases. Fixes #19868.

Signed-off-by: João Neves <joao.antonio.neves@tecnico.ulisboa.pt>

* Tests: Fix failing auto-created document tests

Signed-off-by: João Neves <joao.antonio.neves@tecnico.ulisboa.pt>

* Tests: moved created tests to the existing Document test framework.

Signed-off-by: João Neves <joao.antonio.neves@tecnico.ulisboa.pt>

---------

Signed-off-by: João Neves <joao.antonio.neves@tecnico.ulisboa.pt>
This commit is contained in:
João Neves
2025-04-28 16:46:52 +01:00
committed by GitHub
parent 1d2fd7fe6c
commit 05f0c606d5
7 changed files with 94 additions and 1 deletions

View File

@@ -660,6 +660,27 @@ PyObject* DocumentPy::isClosable(PyObject* args)
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject *DocumentPy::setAutoCreated(PyObject *args)
{
PyObject *autoCreated;
if (!PyArg_ParseTuple(args, "O!", &PyBool_Type, &autoCreated)) {
return nullptr;
}
bool value = (autoCreated == Py_True);
getDocumentPtr()->setAutoCreated(value);
Py_RETURN_NONE;
}
PyObject *DocumentPy::isAutoCreated(PyObject *args)
{
if (!PyArg_ParseTuple(args, "")) {
return nullptr;
}
bool ok = getDocumentPtr()->isAutoCreated();
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* DocumentPy::recompute(PyObject* args)
{
PyObject* pyobjs = Py_None;