Bug 543303 - [OpenModel]Opens a Papyrus Model can throw Cannot modify resource set without a write transaction
Summary: [OpenModel]Opens a Papyrus Model can throw Cannot modify resource set without...
Status: NEW
Alias: None
Product: Papyrus
Classification: Modeling
Component: Core (show other bugs)
Version: 4.2.0   Edit
Hardware: PC Windows 7
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: Confirmed
Keywords: helpwanted
Depends on: 543489 544168 537905
Blocks:
  Show dependency tree
 
Reported: 2019-01-09 08:18 EST by Vincent Lorenzo CLA
Modified: 2019-03-25 05:57 EDT (History)
1 user (show)

See Also:


Attachments
A model to reproduce the bug (6.45 KB, application/octet-stream)
2019-02-06 03:45 EST, Vincent Lorenzo CLA
no flags Details
stackTrace (12.91 KB, application/octet-stream)
2019-02-06 03:47 EST, Vincent Lorenzo CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Lorenzo CLA 2019-01-09 08:18:27 EST
Steps to reproduce:
    1. Create a profile with a stereotype Ste1 extending Class.
    2. On the Extension_End set lower to 1 (or on Extension, set Required to true, (but it seems bugged too in Papyrus).
    3. Create a new model, apply the profile previously created.
    4. Create a new Class  Class1. The stereotype Ste1, will be applied automatically on it (due to the lower value set to 1 in the Extension_End object.
    5. Close the model
    6. Open the uml file with the Ecore Editor
    7. Destroy the stereotype application, save and close
    8. Reopen the papyrus model. 
   -> you will get an exception, because UML2 try to apply the required Stereotype Ste1 to the class Class1 outside of a transaction.
  

So, in this case, we are editing the model during the load. 
It is a good or a bad pratice ? No Idea...

I have no idea how is possible to get a model in this state, but it already appears (see Bug 537905)
Comment 1 Vincent Lorenzo CLA 2019-01-10 03:46:33 EST
This problem should appears when the user creates sub Papyrus model. 
Depending of the order of the profile application and submodel creation. it should be possible to obtain a state where the profile containing required stereotype is unknown from the submodel. In this case, editing the submodel, the stereotype won't be applied, but required from the point of view of the main model.
Comment 2 Vincent Lorenzo CLA 2019-02-06 03:45:19 EST
Created attachment 277464 [details]
A model to reproduce the bug
Comment 3 Vincent Lorenzo CLA 2019-02-06 03:47:43 EST
Created attachment 277465 [details]
stackTrace
Comment 4 Vincent Lorenzo CLA 2019-02-06 03:56:19 EST
In the attached model, there are : 
	- a profile with a required stereotype for Class element
	- a model (bug543303.di file). This model contains a subpackage with a class where the required stereotype is not applied. This subpackage is in a controlled resource
	- a submodel Package4.di. This model contains the class which is not stereotyped but which must be stereotyped.
	I obtained this model, corrupting it with in a text editor. This case can appears naturally with Papyrus, due to bugs with Control Mode. 
	
During the load of the root model, the UMLSnippet registers the adapter ModelListenerManager on the resource. This action seems require to load all the model and submodel. During this load UML2 notices than required stereotypes are missing and decides to apply them. This application generates an exception (see attached stacktrace). 

I already tried to attache the listener using a RecordingCommand, using GMFUnsafe, using a Runnable... each time I get the exception... So I have no more idea how to fix it. 

I notices too than missing required stereotypes are not a problem when there are in the main resource and not in a sub resource. In this case, there is no exception, but missing stereotypes are not applied too.