summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Lebl <jirka@5z.com>2000-09-28 00:18:05 +0000
committerGeorge Lebl <jirka@src.gnome.org>2000-09-28 00:18:05 +0000
commitf05c1c4ed730f8c20a15d83539008f76403227ae (patch)
treef972548239c115627e1e19d54e292e16d906bdbe
parent2f333135c57a4cce57f4ac36373549510eabe5bc (diff)
store the path to the device in the CDPlayerData structure. This fixes aGNOME_APPLETS_1_2_3
Wed Sep 27 17:10:50 2000 George Lebl <jirka@5z.com> * cdplyaer/cdplayer.[ch]: store the path to the device in the CDPlayerData structure. This fixes a problem of the cdplayer not working sometimes as it was using freed data.
-rw-r--r--ChangeLog6
-rw-r--r--cdplayer/cdplayer.c34
-rw-r--r--cdplayer/cdplayer.h1
3 files changed, 26 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index e6894ddcd..16cf51310 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Sep 27 17:10:50 2000 George Lebl <jirka@5z.com>
+
+ * cdplyaer/cdplayer.[ch]: store the path to the device in the
+ CDPlayerData structure. This fixes a problem of the cdplayer
+ not working sometimes as it was using freed data.
+
Tue Aug 29 19:02:36 2000 George Lebl <jirka@5z.com>
* configure.in: added the it directory makefile for webcontrol
diff --git a/cdplayer/cdplayer.c b/cdplayer/cdplayer.c
index cc76545a8..cf0cce298 100644
--- a/cdplayer/cdplayer.c
+++ b/cdplayer/cdplayer.c
@@ -39,14 +39,12 @@ void cdpanel_realized(GtkWidget *cdpanel, CDPlayerData *cd);
GtkWidget *applet = NULL;
-char *devpath = NULL;
-
static gboolean
cd_try_open(CDPlayerData *cd)
{
int err;
if(cd->cdrom_device == NULL) {
- cd->cdrom_device = cdrom_open(devpath, &err);
+ cd->cdrom_device = cdrom_open(cd->devpath, &err);
return cd->cdrom_device != NULL;
}
return TRUE;
@@ -55,8 +53,10 @@ cd_try_open(CDPlayerData *cd)
static void
cd_close (CDPlayerData *cd)
{
- cdrom_close(cd->cdrom_device);
- cd->cdrom_device = NULL;
+ if (cd->cdrom_device != NULL) {
+ cdrom_close(cd->cdrom_device);
+ cd->cdrom_device = NULL;
+ }
}
static void
@@ -94,8 +94,9 @@ cd_panel_update(GtkWidget * cdplayer, CDPlayerData * cd)
}
}
cd_close(cd);
- } else
+ } else {
led_nodisc(cd->panel.time, cd->panel.track_control.display);
+ }
return;
cdplayer = NULL;
}
@@ -314,17 +315,20 @@ create_cdpanel_widget(GtkWidget *window, CDPlayerData * cd)
return cd->panel.frame;
}
-
-
static void
-destroy_cdplayer(GtkWidget * widget, void *data)
+destroy_cdplayer(GtkWidget * widget, gpointer data)
{
CDPlayerData *cd;
cd = gtk_object_get_user_data(GTK_OBJECT(widget));
- gtk_timeout_remove(cd->timeout);
- if(cd->cdrom_device)
- cdrom_close(cd->cdrom_device);
+ if (cd->timeout != 0)
+ gtk_timeout_remove(cd->timeout);
+ cd->timeout = 0;
+ cd_close (cd);
+
+ g_free (cd->devpath);
+ cd->devpath = NULL;
+
g_free(cd);
return;
@@ -482,10 +486,10 @@ create_cdplayer_widget(GtkWidget *window, char *globcfgpath)
cd = g_new0(CDPlayerData, 1);
gnome_config_push_prefix(globcfgpath);
- devpath = gnome_config_get_string("cdplayer/devpath=/dev/cdrom");
+ /* NOTE THAT devpath is GLOBAL!, EEK! */
+ cd->devpath = gnome_config_get_string("cdplayer/devpath=/dev/cdrom");
gnome_config_pop_prefix();
- cd->cdrom_device = cdrom_open(devpath, &err);
- g_free (devpath);
+ cd->cdrom_device = cdrom_open(cd->devpath, &err);
cd->size = APPLET_WIDGET(window)->size;
cd->orient = APPLET_WIDGET(window)->orient;
diff --git a/cdplayer/cdplayer.h b/cdplayer/cdplayer.h
index 9fe21b85b..e3c8f6388 100644
--- a/cdplayer/cdplayer.h
+++ b/cdplayer/cdplayer.h
@@ -6,6 +6,7 @@ typedef struct {
cdrom_device_t cdrom_device;
int size;
PanelOrientType orient;
+ char *devpath;
struct {
GtkWidget *frame;