Skip to content

Commit

Permalink
Fixes #273 by removing a condition in cycle update
Browse files Browse the repository at this point in the history
A condition had been added to updateStatus() in ExperimentAgent, which is not accurate/useful anymore and causes the behavior described in #273. It is removed in this commit.
  • Loading branch information
AlexisDrogoul committed Sep 2, 2024
1 parent eeaf9fc commit 7a4fcee
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,9 @@ public IPopulation<? extends IAgent> getPopulationFor(final ISpecies species) {
*/
private void informStatus() {
// TODO: should we keep that condition as we have specific IStatusDisplayer implementations ?
if (isHeadless() || isBatch() || getSimulation() == null) return;
// Condition on the null simulation removed because of #273
if (isHeadless() || isBatch() /** || getSimulation() == null **/
) return;
ownScope.getGui().getStatus().informStatus(ownScope, null, "overlays/status.clock");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ public boolean init(final IScope scope) {
final boolean result = super.init(scope);
updateDisplayOutputsName(scope.getSimulation());
scope.getGui().getStatus().informStatus(scope, null, "overlays/status.clock");
// scope.getGui().getStatus().informStatus(scope, " " + scope.getRoot().getName() + " ready");
return result;
}

Expand Down
50 changes: 22 additions & 28 deletions gama.ui.shared/src/gama/ui/shared/utils/ThreadedUpdater.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************************************
*
* ThreadedUpdater.java, in gama.ui.shared.shared, is part of the source code of the
* GAMA modeling and simulation platform .
* ThreadedUpdater.java, in gama.ui.shared.shared, is part of the source code of the GAMA modeling and simulation
* platform .
*
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
*
********************************************************************************************************/
package gama.ui.shared.utils;

Expand All @@ -18,6 +18,7 @@
import gama.core.common.interfaces.IDisplaySurface;
import gama.core.common.interfaces.IUpdaterMessage;
import gama.core.common.interfaces.IUpdaterTarget;
import gama.dev.DEBUG;

/**
* Class ThreadedUpdater.
Expand All @@ -28,69 +29,62 @@
*/
public class ThreadedUpdater<Message extends IUpdaterMessage> extends UIJob implements IUpdaterTarget<Message> {

static {
DEBUG.ON();
}

/** The message. */
Message message = null;

/** The control. */
private IUpdaterTarget<Message> control;

/**
* Instantiates a new threaded updater.
*
* @param name the name
* @param name
* the name
*/
public ThreadedUpdater(final String name) {
super(WorkbenchHelper.getDisplay(), name);
setPriority(DECORATE);
}

@Override
public boolean isDisposed() {
return control.isDisposed();
}
public boolean isDisposed() { return control.isDisposed(); }

@Override
public boolean isVisible() {
return control.isVisible();
}
public boolean isVisible() { return control.isVisible(); }

@Override
public void updateWith(final Message m) {
if (isDisposed() || !isVisible() || isBusy() || m == null) {
return;
}
if (isDisposed() || !isVisible() || isBusy() || m == null) return;
message = m;
schedule();
}

@Override
public int getCurrentState() {
return control.getCurrentState();
}
public int getCurrentState() { return control.getCurrentState(); }

/**
* Sets the target.
*
* @param l the l
* @param s the s
* @param l
* the l
* @param s
* the s
*/
public void setTarget(final IUpdaterTarget<Message> l, final IDisplaySurface s) {
control = l;
}

@Override
public boolean isBusy() {
return control.isBusy();
}
public boolean isBusy() { return control.isBusy(); }

@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
if (control.isDisposed()) {
return Status.CANCEL_STATUS;
}
if (control.isBusy() || !control.isVisible()) {
return Status.OK_STATUS;
}
if (control.isDisposed()) return Status.CANCEL_STATUS;
if (control.isBusy() || !control.isVisible()) return Status.OK_STATUS;
control.updateWith(message);
return Status.OK_STATUS;
}
Expand Down

0 comments on commit 7a4fcee

Please sign in to comment.