Commit Graph

17 Commits

Author SHA1 Message Date
luz.paz
b36b21247c follow-up source typos 2018-05-11 10:02:56 -03:00
wmayer
ca77c54d10 rename status bit 'Delete' to 'Remove' as it fits better for its purpose, add new bit 'Destroy' 2017-09-13 15:47:48 +02:00
Stefan Tröger
3355942966 Prevent error messages when restoring a origin 2017-09-09 16:55:55 +02:00
Stefan Tröger
7829849104 Fix deleting a Part 2017-09-09 16:55:55 +02:00
Stefan Tröger
2939f290ad Groups: Handle add and remove object correctly 2017-06-19 15:37:09 +02:00
Stefan Tröger
fd62ef30f3 Unify and fix group handling in geofeaturegroups 2017-06-19 15:37:09 +02:00
Abdullah Tahiri
b4e942c08b Checking for Document Restoring when extension has a null property
==================================================================

The problem:

OriginGroupExtension::OriginGroupExtension () {

    initExtensionType(OriginGroupExtension::getExtensionClassTypeId());

    EXTENSION_ADD_PROPERTY_TYPE ( Origin, (0), 0, App::Prop_Hidden, "Origin linked to the group" );
}

initializes the Origin property to null.

Then Document::Restore => readObjects => addObject => slotNewObject => ViewProviderDocumentObject::updateView => ViewProviderBody::updateData => ViewProviderGeometryObject::updateData =>
ViewProviderDocumentObject::updateData => ViewProvider::updateData => ViewProviderOriginGroupExtension::extensionUpdateData => updateOriginSize() => OriginGroupExtension::getOrigin,

the latter throws an exception because the origin property is null.

Afterwards, the origin property is initialized during Document::Restore => readObjects => ExtensionContainer::Restore() => PropertyContainer::Restore() => App::PropertyLink::Restore()
=> App::PropertyLink::setValue() => Property::hasSetValue, which triggers an onChange: Body::onChanged => BodyBase::onChanged => Feature::onChanged => DocumentObject::onChanged =>
Document::onChangedProperty => Document::slotChangedObject => ViewProviderOriginGroupExtension::slotChangedObjectGui => ViewProviderOriginGroupExtension::updateOriginSize =>
OriginGroupExtension::getOrigin,

now, the latter that is the same that was throwing the exception and generating the error message above, does not throw anymore because Origin has been initialized.

When creating a new object, isNew==true; whereas when loading a file, isNew==false. Therefore, when loading a file setupObject is not executed. SetupObject, effectively initializes
the extension via: Body::setupObject => DocumentObject::setupObject => OriginGroupExtension::onExtendedSetupObject.

DocumentObject * Document::addObject(const char* sType, const char* pObjectName, bool isNew)
{
    [more code here]
    // Call the object-specific initialization
    if (!d->undoing && !d->rollback && isNew) {
        pcObject->setupObject ();
    }
    [more code here]

As DocumentObject code is generic for all objects (workbenches), by design it was chosen to initialize the object only if new. Therefore a object or an extension of a object being restored,
between the addition (addObject) and the restoring of the properties, must by design expect it not to be initialized.

The solution:

Making use of the Restore flag at document level (the one at object level is not sufficient), no exception regarding the null property is reported during document restoring.

Ticket:
https://freecadweb.org/tracker/view.php?id=2530

fixes #2530
2017-05-30 13:01:45 +02:00
wmayer
fb7094bf31 use specialized exception classes 2017-04-28 18:49:11 +02:00
Stefan Tröger
ea73e55eb6 Extensions: Fix GeoFeatureGroup drag&drop 2017-01-04 16:01:58 +01:00
Stefan Tröger
a025a20bed Extensions: GeoFeatureGroup only for GeoFeature 2017-01-04 16:01:58 +01:00
wmayer
f1127dd2f4 Fix issues:
+ improve formatting
+ remove superfluous semicolons
+ comment unused parameters
+ rename Initialisation to Initialization
+ rename Deinitialisation to Finalization
+ remove spaces
2016-10-08 12:48:34 +02:00
Stefan Tröger
0ae9346b3c Extenions: Drop virtual inheritance
Due to problems onthe windows platform the virtual inheritance approach must be dropped. NExt to the already reimplemented proeprty interface the Type interface is reimplemented too. This change allows to revert some earlier changes.
2016-10-08 12:48:34 +02:00
Stefan Tröger
89bbb81521 Extension: Fix order-of-initialisation crash
FreeCADs property system utilises some pointer math to calculate the offset between
property and base class. Due to virtual inheritance of th ePropertyContainer the memory
layout has been changed to rather random, which has lead to crashes dependend on the
order of object initialisation.

The solution is to not make PropertyContaner virtual but a class below, Base::Persitance.
Then the memory layout is random for Persistance, but it is perfectly aligned for the
base class chains from PropertyContainer onwards as well as from Extension onwards.
Hence the proeprty system was changed to take the offset always from those two.
2016-10-08 12:48:34 +02:00
Stefan Tröger
3e1ba47d61 Extensions: Handle new dynamic_cast's 2016-10-08 12:48:34 +02:00
Stefan Tröger
1b150a86c3 Extensions: Add ViewProvider extension python types 2016-10-08 12:48:34 +02:00
Stefan Tröger
6e1a029996 Extension: Port ViewProvider of Part 2016-10-08 12:48:34 +02:00
Stefan Tröger
fedcfd9407 Extension: Port ViewProvider of OriginGroup 2016-10-08 12:48:34 +02:00