summaryrefslogtreecommitdiffstats
path: root/hacks/glx/sonar.c
diff options
context:
space:
mode:
Diffstat (limited to 'hacks/glx/sonar.c')
-rw-r--r--hacks/glx/sonar.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/hacks/glx/sonar.c b/hacks/glx/sonar.c
index c4ea949..ddbb79f 100644
--- a/hacks/glx/sonar.c
+++ b/hacks/glx/sonar.c
@@ -623,17 +623,20 @@ static void
update_sensor_data (sonar_configuration *sp)
{
sonar_bogie *new_list = sp->ssd->scan_cb (sp->ssd);
- sonar_bogie *b2;
+ sonar_bogie *b2, *next;
/* If a bogie exists in 'new_list' but not 'pending', add it.
If a bogie exists in both, update it in 'pending'.
*/
- for (b2 = new_list; b2; b2 = b2->next)
+ for (b2 = new_list, next = b2 ? b2->next : 0;
+ b2;
+ b2 = next, next = next ? next->next : 0)
{
if (debug_p > 2)
fprintf (stderr, "%s: updated: %s (%5.2f %5.2f %5.2f)\n",
progname, b2->name, b2->r, b2->th, b2->ttl);
copy_and_insert_bogie (sp->ssd, b2, &sp->pending);
+ sonar_free_bogie (sp->ssd, b2);
}
if (debug_p > 2) fprintf (stderr, "\n");
}
@@ -1041,7 +1044,7 @@ draw_sonar (ModeInfo *mi)
if (!sp->glx_context)
return;
- glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(sp->glx_context));
+ glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *sp->glx_context);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -1227,13 +1230,16 @@ draw_sonar (ModeInfo *mi)
ENTRYPOINT void
free_sonar (ModeInfo *mi)
{
-#if 0
sonar_configuration *sp = &sps[MI_SCREEN(mi)];
sonar_bogie *b = sp->displayed;
+
+ if (!sp->glx_context) return;
+ glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *sp->glx_context);
+
while (b)
{
sonar_bogie *next = b->next;
- free_bogie (sp->ssd, b);
+ sonar_free_bogie (sp->ssd, b);
b = next;
}
sp->displayed = 0;
@@ -1242,15 +1248,24 @@ free_sonar (ModeInfo *mi)
while (b)
{
sonar_bogie *next = b->next;
- free_bogie (sp->ssd, b);
+ sonar_free_bogie (sp->ssd, b);
b = next;
}
sp->pending = 0;
- sp->ssd->free_data_cb (sp->ssd, sp->ssd->closure);
- free (sp->ssd);
- sp->ssd = 0;
-#endif
+ if (sp->ssd) {
+ sp->ssd->free_data_cb (sp->ssd, sp->ssd->closure);
+ free (sp->ssd);
+ sp->ssd = 0;
+ }
+
+ if (sp->trackball) gltrackball_free (sp->trackball);
+ if (sp->rot) free_rotator (sp->rot);
+ if (sp->texfont) free_texture_font (sp->texfont);
+ glDeleteLists (sp->table_list, 1);
+ glDeleteLists (sp->screen_list, 1);
+ glDeleteLists (sp->grid_list, 1);
+ glDeleteLists (sp->sweep_list, 1);
}
XSCREENSAVER_MODULE ("Sonar", sonar)