NetLogo / NetLogo

turtles, patches, and links for kids, teachers, and scientists
http://ccl.northwestern.edu/netlogo/
1.01k stars 242 forks source link

Extensions with menu bar items cannot remove them on unload #2295

Open LaCuneta opened 1 month ago

LaCuneta commented 1 month ago

If an extension adds an item to the main menu bar on macOS in NetLogo 6.3 or 6.4, when the extension is unloaded by opening a new, blank model or a different model by any means, the extension's menu bar item will remain. This can cause duplicates if another model using the same extension is loaded. The only way to clear the menu items is to close and re-open NetLogo. This was originally opened as an issue in the SimpleR extension repository.

This issue only affects macOS, both ARM and x86. This affects the LevelSpace, SimpleR, and Python extensions, and maybe others if they use a similar technique. This is a regression from 6.2 to 6.3, as in 6.2.2 (in LevelSpace, at least), the menu item removal is respected.

My research:

It's super-weird that the add() method works fine, but the remove() does not, supposedly with the same JMenuBar component.

Possible ways forward:

I've run out of time to look further into this, hence why I'm opening this issue up here.

mac-app-6.2.2-6.3.0.patch.txt

ERSUCC commented 1 month ago

I tested the LevelSpace extension with the development version of NetLogo on my Mac, and the issue seems to be no longer present. To confirm that it wasn't just my system being strange, I tested on the same Mac with the released version of NetLogo, and the issue was present. I believe that I fixed the issue with pr #2286 (see MenuModel.scala). Could someone confirm that the issue is indeed fixed as it seems to be on my end?

brandesNW commented 1 month ago

Hi Isaac, I created a version of NetLogo that should be referenced in the LevelSpace build.sbt instead of the temporary version that Jason created. It is NetLogo 6.4.0-d2e6005https://cloudsmith.io/~netlogo/repos/netlogo/packages/?q=version%3A6.4.0-d2e6005. Can you make and test a PR for that. Once it is integrated I will update hexy to refer to the updated LevelSpace and then that update will be complete.

-- Aaron Brandes, Software Developer Center for Connected Learning and Computer-Based Modeling

From: Isaac Brown @.> Date: Sunday, August 11, 2024 at 8:40 PM To: NetLogo/NetLogo @.> Cc: Subscribed @.***> Subject: Re: [NetLogo/NetLogo] Extensions with menu bar items cannot remove them on unload (Issue #2295)

I tested the LevelSpace extension with the development version of NetLogo on my Mac, and the issue seems to be no longer present. To confirm that it wasn't just my system being strange, I tested on the same Mac with the released version of NetLogo, and the issue was present. I believe that I fixed the issue with pr #2286https://urldefense.com/v3/__https:/github.com/NetLogo/NetLogo/pull/2286__;!!Dq0X2DkFhyF93HkjWTBQKhk!UyMcgW1F9yMAhkrrF_Yq6YgE2XVyk6hTRvmHF6S9hPGJaf1TRVCC8PNkNevipmO--R9UlyU_UatwSJNRkdVSTWtJ4QvEeJ5YeQ$ (see MenuModel.scala). Could someone confirm that the issue is indeed fixed as it seems to be on my end?

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/NetLogo/NetLogo/issues/2295*issuecomment-2282955194__;Iw!!Dq0X2DkFhyF93HkjWTBQKhk!UyMcgW1F9yMAhkrrF_Yq6YgE2XVyk6hTRvmHF6S9hPGJaf1TRVCC8PNkNevipmO--R9UlyU_UatwSJNRkdVSTWtJ4QsDnrd1pg$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ANSUO2QKUHFKN2EXKIUAETTZQ7773AVCNFSM6AAAAABMG2OTWKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBSHE2TKMJZGQ__;!!Dq0X2DkFhyF93HkjWTBQKhk!UyMcgW1F9yMAhkrrF_Yq6YgE2XVyk6hTRvmHF6S9hPGJaf1TRVCC8PNkNevipmO--R9UlyU_UatwSJNRkdVSTWtJ4QsMVgJF7A$. You are receiving this because you are subscribed to this thread.Message ID: @.***>

ERSUCC commented 1 month ago

I made a PR, https://github.com/NetLogo/LevelSpace/pull/148.