Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI: call G_gisinit when forms are run standalone (e.g. from parser) #2489

Merged
merged 5 commits into from
Feb 12, 2023

Conversation

marisn
Copy link
Contributor

@marisn marisn commented Jul 21, 2022

Repeated calls to G_gisinit are safe; When forms.py are loaded as a part of other code, one can assume that
G_gisinit has already been (or will be) called.

See #2484 for discussion.

Repeated calls to G_gisinit are safe;
When forms.py are loaded as a part of other code, one can assume that
G_gisinit has already been called.

See OSGeo#2484 for discussion.
@marisn marisn added GUI wxGUI related Python Related code is in Python labels Jul 21, 2022
@marisn marisn requested a review from wenzeslaus July 21, 2022 11:50
@marisn marisn linked an issue Jul 21, 2022 that may be closed by this pull request
@@ -79,6 +79,9 @@

# needed when started from command line and for testing
if __name__ == "__main__":
from grass.lib.gis import G_gisinit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import here is too soon. The other GRASS-related imports are only later. (This needs a fix with GRASS Python libs just being installed in the system and rest of the code can just assume they are there, but the current situation is that the code can't assume that.)

All ctypes imports need to be in try-except ImportError block as e.g. in gui/wxpython/nviz/wxnviz.py. The idea is that the GUI components start and work even if ctypes are broken for some reason. Only the parts which need to work can fail, ideally gracefully. (Standalone NVIZ does not have to work, but main GUI should.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a better version – import is done only before use. As G_gisinit("") is safe to call after initialization has been already done, calling it one more time wouldn't harm.
When a separate C module for signature file handling will be made, this code will have to change. In the meantime – it is better than failing GUI.

@wenzeslaus wenzeslaus added this to the 8.4.0 milestone Jul 26, 2022
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. You could also do that in _append_mapset_signatures because after calling that function, items can be already empty anyway. Interfacing with C would be then limited to _append_mapset_signatures only.

@marisn
Copy link
Contributor Author

marisn commented Dec 24, 2022

Is it better now?

@wenzeslaus wenzeslaus added the blocker Blocking a release label Feb 10, 2023
@wenzeslaus wenzeslaus self-requested a review February 10, 2023 16:22
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing the review! I merged the main branch just to run the test with latest code. (The last run was old and failed for unrelated reason.)

@wenzeslaus wenzeslaus added the bug Something isn't working label Feb 10, 2023
@marisn marisn merged commit 5b7be39 into OSGeo:main Feb 12, 2023
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
…SGeo#2489)

* GUI: call G_gisinit when forms are run standalone (e.g. from parser)
Repeated calls to G_gisinit are safe;
When forms.py are loaded as a part of other code, one can assume that
G_gisinit has already been called.

See OSGeo#2484 for discussion.
@marisn marisn deleted the forms_init branch October 22, 2023 09:57
neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
…SGeo#2489)

* GUI: call G_gisinit when forms are run standalone (e.g. from parser)
Repeated calls to G_gisinit are safe;
When forms.py are loaded as a part of other code, one can assume that
G_gisinit has already been called.

See OSGeo#2484 for discussion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Blocking a release bug Something isn't working GUI wxGUI related Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Issue in C code any Python environment interplay
2 participants