mirror of https://gitlab.com/pamhyr/pamhyr2
Merge branch 'dev_dylan' into scenarios
commit
c44597dfbd
|
|
@ -34,6 +34,7 @@ class StudyStatus(object):
|
|||
self._status = Status.EDIT
|
||||
self._scenario = scenario
|
||||
self._saved = True
|
||||
self._loading = False
|
||||
|
||||
@property
|
||||
def scenario_id(self):
|
||||
|
|
@ -86,6 +87,15 @@ class StudyStatus(object):
|
|||
def is_saved(self):
|
||||
return self._saved
|
||||
|
||||
def is_loading(self):
|
||||
return self._loading
|
||||
|
||||
def start_loading(self):
|
||||
self._loading = True
|
||||
|
||||
def stop_loading(self):
|
||||
self._loading = False
|
||||
|
||||
def save(self):
|
||||
logger.debug("model status set as saved")
|
||||
self._saved = True
|
||||
|
|
@ -97,6 +107,9 @@ class StudyStatus(object):
|
|||
self._saved = True
|
||||
|
||||
def modified(self):
|
||||
if self._loading:
|
||||
return
|
||||
|
||||
if self._saved:
|
||||
self.version += 1
|
||||
|
||||
|
|
|
|||
|
|
@ -573,16 +573,20 @@ class Study(SQLModel):
|
|||
"scenario": scenario
|
||||
}
|
||||
|
||||
# Load river data
|
||||
river = River._db_load(
|
||||
sql_exec, data=data
|
||||
)
|
||||
data["study"] = self
|
||||
river._db_load_results(sql_exec, data=data)
|
||||
self.status.start_loading()
|
||||
try:
|
||||
# Load river data
|
||||
river = River._db_load(
|
||||
sql_exec, data=data
|
||||
)
|
||||
data["study"] = self
|
||||
river._db_load_results(sql_exec, data=data)
|
||||
finally:
|
||||
self.status.stop_loading()
|
||||
self.status.scenario = old_scenario
|
||||
|
||||
# FIXME: Disable scenario cache to save memory usage
|
||||
# self._river_scenario_cache[scenario] = river
|
||||
self.status.scenario = old_scenario
|
||||
|
||||
return river
|
||||
|
||||
|
|
|
|||
|
|
@ -202,6 +202,8 @@ class SQLSubModel(PamhyrID):
|
|||
"""
|
||||
if self._status is None:
|
||||
return
|
||||
if self._status.is_loading():
|
||||
return
|
||||
|
||||
self._owner_scenario = self._status.scenario_id
|
||||
self._status.modified()
|
||||
|
|
@ -218,6 +220,8 @@ class SQLSubModel(PamhyrID):
|
|||
"""
|
||||
if self._status is None:
|
||||
return
|
||||
if self._status.is_loading():
|
||||
return
|
||||
|
||||
self._owner_scenario = self._status.scenario_id
|
||||
self._status.modified()
|
||||
|
|
|
|||
Loading…
Reference in New Issue