Skip to content

check if QGIS restart is required #1443

@jakimowb

Description

@jakimowb

To ensure that all python packages are loaded right, an updates of the EnMAP-Box plugin requires to restart QGIS.
If this has not been done, errors may occur due to the following problem

  1. QGIS start
  2. QGIS load EnMAP-Box version N
  3. import enmapbox.classXYZ loads classXYZ
  4. QGIS updates EnMAP-Box version N+1
  5. import enmapbox.classXYZ is called, but since it was already loaded before, Python will use the outdated version of classXYZ.
  6. error occurs when using classXYZ with old definition

A solution could be to enforce a reloading of all imports:

# Source - https://stackoverflow.com/a/437591
# Posted by cdleary, modified by community. See post 'Timeline' for change history
# Retrieved 2026-02-02, License - CC BY-SA 4.0

from importlib import reload  # Python 3.4+
import foo

while True:
    # Do some things.
    if is_changed(foo):
        foo = reload(foo)

but this would required to add an reload for every possible package import. Instead it's probably easier to show a "QGIS restart required" warning if the EnMAP-Box plugin hash (enmapbox.vershion_sha ) has been updated

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions