XGetWindowAttributes(nedsim->dpy, nedsim->win, &xgwa);
/* Only restart the simulation if the window changed size. */
if (nedsim->dpy_width != xgwa.width || nedsim->dpy_height != xgwa.height) {
- NEDsim_free(dpy, win, closure);
- closure = NEDsim_init(dpy, win);
+ struct NEDstate * original_nedstate = nedsim->nedstate;
+ nedsim->nedstate = NULL;
+ NEDsim_free(dpy, win, nedsim);
+ struct NEDsim * new_nedsim = NEDsim_init(dpy, win);
+ new_nedsim->nedstate = original_nedstate;
+ closure = new_nedsim;
}
}