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:
@@ -840,6 +840,7 @@ Document::Document(const char* documentName)
|
||||
// So, we must increment only if the interpreter gets a reference.
|
||||
// Remark: We force the document Python object to own the DocumentPy instance, thus we don't
|
||||
// have to care about ref counting any more.
|
||||
setAutoCreated(false);
|
||||
d = new DocumentP;
|
||||
Base::PyGILStateLocker lock;
|
||||
d->DocumentPythonObject = Py::Object(new DocumentPy(this), true);
|
||||
@@ -2505,6 +2506,14 @@ std::string Document::getFullName() const
|
||||
return myName;
|
||||
}
|
||||
|
||||
void Document::setAutoCreated(bool value) {
|
||||
autoCreated = value;
|
||||
}
|
||||
|
||||
bool Document::isAutoCreated() const {
|
||||
return autoCreated;
|
||||
}
|
||||
|
||||
const char* Document::getProgramVersion() const
|
||||
{
|
||||
return d->programVersion.c_str();
|
||||
|
||||
Reference in New Issue
Block a user