Closed cstaelin closed 3 months ago
I have verified that this bug occurs in NetLogo and NetLogo3D.
The obvious workaround is to save the model.
Hi Charles, I have verified the bug, and noted it in issue 1832. Thanks for pointing this out.
Aaron
-- Aaron Brandes, Software Developer Center for Connected Learning and Computer-Based Modeling
From: cstaelin notifications@github.com Reply-To: NetLogo/NetLogo reply@reply.github.com Date: Monday, April 6, 2020 at 10:21 PM To: NetLogo/NetLogo NetLogo@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [NetLogo/NetLogo] Bug on closing NetLogo Window? (#1832)
In NetLogo 6.1.1 running under Windows 10, I believe there is a bug in both NetLogo and NetLogo3D that occurs when there are included .nls files AND the NetLogo window is closed without first saving the model. If a change has been made to an .nls file and the window is closed, “x’ed” out of, NetLogo asks if you wish to save the altered .nls file(s), and proceeds to do so if you so indicate. However, if you have changed a variable on the Interface tab of the model, but not the code on the primary code tab, then the .nlogo or .nlogo3D file is not saved and any changes to the variables on the interface tab are lost. Apparently changing a variable on the Interface tab does not prompt NetLogo to flag the .nlogo (.nlogo3D) file as having been updated, and thus needful of being saved.
I've attached the files that I've tested this out on. If you change something in extra-code and the value of chooser-test, then close the window, extra-code.nls is saved, by not SaveTest.nlogo.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/NetLogo/NetLogo/issues/1832__;!!Dq0X2DkFhyF93HkjWTBQKhk!GfY2NcGJ3da-49MK9A-VtM3rYzCCr0_OBEd60CZyocvHixvKjs64oHUQquzc-6ybKZk9oP27lA$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ANSUO2WICTSDPVJYC3YGS4TRLKE33ANCNFSM4MCX5FMA__;!!Dq0X2DkFhyF93HkjWTBQKhk!GfY2NcGJ3da-49MK9A-VtM3rYzCCr0_OBEd60CZyocvHixvKjs64oHUQquzc-6ybKZkfC55ICw$.
This note breaks out the bug into three manifestations, which I have verified. Aaron IncludedFileBug.zip
I'm sorry, my first message mixed two different issues. Here I separate them.
-------- Forwarded Message -------- Subject: Unexpected behavior: included files Date: Thu, 30 Apr 2020 19:30:45 -0700 From: Steve Railsback Steve@LangRailsback.com To:
Hi--
I have been having trouble understanding why changes to an included code file seem to get reversed, and think I understand what is going on. Here are two behaviors that seem dubious.
(I am using NetLogo 6.0.4, but did not see anything about these issues in the release notes for subsequent versions.)
1) When I open an included file, make a change in it, then go to the Interface or code tab, then go back to the included file's code tab, NetLogo lets me close the included file without asking whether I want to save its changes. So it's easy to close the included file without saving changes to it.
2) When I open an included file, use the procedure in it in a model run, then make a change to the included file, save that included file with the change, close it, and then go to the Interface again, the model still uses the original--not changed--code from the included file.
To see this behavior, with the two files I attach:
a. Open Test.nlogo and click it's "Test" button. It correctly reads a parameter value from the included file set-parameters.nls and shows its value as "Hi".
b. From the code tab, open set-parameters.nls. Edit it so param-a is set to "Bye" instead of "Hi". Then save and close set-parameters.nls.
c. Go back to the Interface and click "Test" again. The result in the Command Center is still "Hi", not "Bye" as the revised and saved copy of set-parameters.nls says it should be.
d. You can even re-open the included file, then go back to the Interface, hit "Test", and it still reports "Hi", in conflict with the open copy of set-parameters.nls.
It appears that saving and closing an included file, and even re-opening it, does not always cause NetLogo to update the copy of the included code that it executes.
3) Similarly, when I open and use an included file, then make and use a change to the included file, then close the included file without saving the change, and then re-open the included file, the model uses the changed, not original, code from the included file.
To see this behavior, with the two files I attach:
a. Open Test.nlogo and click it's "Test" button. It correctly reads a parameter value from the included file set-parameters.nls and shows its value as "Hi".
b. From the code tab, open set-parameters.nls. Edit it so param-a is set to "Bye" instead of "Hi". Then go back to the Interface and click "Test" again. The result in the Command Center is now "Bye", as it should be.
c. Now go back to the code tab for set-parameters.nls and close it without saving it. Then re-open that file; it will still have the statement to set param-a to "Hi".
d. Now, back to the Interface, hit test, and the result is "Bye". So the code is using its stored copy of the included file, not the copy that we have open in the code editor.
I find myself having to close the entire model and re-open it to get it to use revisions made in an included file.
Thank you,
Steve R.
-- Steve Railsback Lang Railsback & Associates Arcata, California Our agent-based modeling textbook: https://urldefense.com/v3/__https://press.princeton.edu/books/paperback/9780691190839/agent-based-and-individual-based-modeling__;!!Dq0X2DkFhyF93HkjWTBQKhk!G7FA9jW71jDEt66Zv3y3QoDTNASUCqPcuBWI8VmqMOD2kYvx1ZE54lXHO7drZCSRq5oWbZsDcQ$ Our new book on behavior in individual-based models: https://urldefense.com/v3/__https://press.princeton.edu/books/paperback/9780691195285/modeling-populations-of-adaptive-individuals__;!!Dq0X2DkFhyF93HkjWTBQKhk!G7FA9jW71jDEt66Zv3y3QoDTNASUCqPcuBWI8VmqMOD2kYvx1ZE54lXHO7drZCSRq5rrzF93cA$
Hi @cstaelin, this is not actually related to included files. NetLogo does not mark the model as dirty (needing a save) when the value of a widget is changed outside of the Edit dialog, regardless of whether the model contains included files or not. I made a fix for this issue, see pull request #2278.
In NetLogo 6.1.1 running under Windows 10, I believe there is a bug in both NetLogo and NetLogo3D that occurs when there are included .nls files AND the NetLogo window is closed without first saving the model. If a change has been made to an .nls file and the window is closed, “x’ed” out of, NetLogo asks if you wish to save the altered .nls file(s), and proceeds to do so if you so indicate. However, if you have changed a variable on the Interface tab of the model, but not the code on the primary code tab, then the .nlogo or .nlogo3D file is not saved and any changes to the variables on the interface tab are lost. Apparently changing a variable on the Interface tab does not prompt NetLogo to flag the .nlogo (.nlogo3D) file as having been updated, and thus needful of being saved.
I've attached the files that I've tested this out on. If you change something in
extra-code
and the value ofchooser-test
, then close the window, extra-code.nls is saved, by not SaveTest.nlogo.SaveTest.zip