Book a Demo

Author Topic: EA crashes when I try to use ShowInProjectView()  (Read 14834 times)

ingeniero

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
EA crashes when I try to use ShowInProjectView()
« on: October 27, 2015, 08:08:21 pm »
Hi everyone,

I've created a very simple EA project with 3 actors and 3 use cases (see image attached). I'm trying to select an use case in the project browser when EA_OnContextItemDoubleClicked() method is called but EA crash when i do double click on an actor or an use case.

This is the simplified code:

Code: [Select]
public bool EA_OnContextItemDoubleClicked(EA.Repository Repository, String GUID, EA.ObjectType ot)
{
            var element = Repository.GetElementByID(13);  // 13: use case2 id
            Repository.ShowInProjectView(element);

            return true;
}


Project browser: http://es.zimagez.com/zimage/projectbrowser.php


Does somebody know why this error happens?

Thanks,
Javier

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: EA crashes when I try to use ShowInProjectView
« Reply #1 on: October 27, 2015, 08:45:13 pm »
What happens if you return false?

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: EA crashes when I try to use ShowInProjectView
« Reply #2 on: October 27, 2015, 08:46:47 pm »
Also, why do you define element as a var?

Why not EA.Element?

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: EA crashes when I try to use ShowInProjectView
« Reply #3 on: October 27, 2015, 09:20:21 pm »
Hi Javier,


If you return true out of EA_OnContextItemDoubleClicked(), you're telling EA that you have taken over handling of the event and EA should now stop processing it. If you return false, you allow EA to continue processing the event, which in most cases means opening the properties dialog.

It is probably a good idea to return false in this case.

As to why EA crashes, before you call Repository.ShowInprojectView(), make sure that element isn't null. If for instance you have deleted and recreated the use case, element ID 13 will never be reused and so Repository.GetElementByID() will return null.

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

ingeniero

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: EA crashes when I try to use ShowInProjectView
« Reply #4 on: October 27, 2015, 09:26:55 pm »
With true or false, var or EA.Element I had the same error.

ingeniero

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: EA crashes when I try to use ShowInProjectView
« Reply #5 on: October 27, 2015, 09:28:39 pm »
The project browser is expanded and the element is selected but then crash EA.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: EA crashes when I try to use ShowInProjectView
« Reply #6 on: October 27, 2015, 11:36:17 pm »
Weird, anything in the windows eventviewer?
Wich version and edition are you using?

Geert

ingeniero

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: EA crashes when I try to use ShowInProjectView
« Reply #7 on: October 27, 2015, 11:57:34 pm »
Enterprise Architect 12.0.1214 (Build: 1214)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: EA crashes when I try to use ShowInProjectView
« Reply #8 on: October 28, 2015, 12:18:09 am »
Well, by calling ShowInProjectView() you are in fact changing the context item -- right in the middle of EA's processing of a context item change event.

I wouldn't be entirely surprised if EA finds this difficult to deal with.

/U
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: EA crashes when I try to use ShowInProjectView
« Reply #9 on: October 28, 2015, 12:57:33 am »
Quote
Enterprise Architect 12.0.1214 (Build: 1214)
Lite, Full, or Trial edition?

Geert

ingeniero

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: EA crashes when I try to use ShowInProjectView
« Reply #10 on: October 28, 2015, 01:01:51 am »
Full

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: EA crashes when I try to use ShowInProjectView
« Reply #11 on: October 28, 2015, 01:08:38 am »
Quote
Full

In that case I'm all out of ideas.
Best to try Sparx support I think.

Geert

ingeniero

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: EA crashes when I try to use ShowInProjectView
« Reply #12 on: October 28, 2015, 01:27:18 am »
Ok, thanks anyway.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: EA crashes when I try to use ShowInProjectView
« Reply #13 on: October 28, 2015, 11:06:53 am »
Maybe try this instead.  Worked fine for me.

Code: [Select]
public System.Object EA_OnContextItemDoubleClicked(EA.Repository repository, string sGUID, EA.ObjectType otype)
{
      if (otype == EA.ObjectType.otElement)
      {
            EA.Element theElement = repository.GetElementByGuid(sGUID);
            if (theElement != null)
            {
                  repository.ShowInProjectView(theElement);
            }
      }
      return null;
}

Note: returning null will proceed with default EA handling and also still allow other add-ins to override double-click behavior to show custom properties dialogs if necessary.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: EA crashes when I try to use ShowInProjectView
« Reply #14 on: October 28, 2015, 06:16:06 pm »
Hi Aaron,


What you're doing there is selecting the element that triggered the event. I think the OP is trying to select a different element from the one that triggered the event.

I'm thinking that might shove EA into a tailspin, because it changes the context item while the context item change event is being processed.

But I might be woofing up the inappropriate woody plant.


/Uffe
My theories are always correct, just apply them to the right reality.