summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2011-11-15 11:43:38 +0100
committerportix <portix@gmx.net>2011-11-15 11:43:38 +0100
commit3a973d7c571cf8e71c8989d3166a2cdc078ecf33 (patch)
treeca7c95aef67b2ee1d1cf17298217622cd8f9f285 /src
parent7c1b32549f9175e32bd3e3da5c5dec90e2b101e0 (diff)
downloaddwb-3a973d7c571cf8e71c8989d3166a2cdc078ecf33.zip
Fix segfault in session_list if no sessions were saved
Diffstat (limited to 'src')
-rw-r--r--src/dwb.c15
-rw-r--r--src/dwb.h4
-rw-r--r--src/session.c6
3 files changed, 13 insertions, 12 deletions
diff --git a/src/dwb.c b/src/dwb.c
index ad580b48..4684ea8d 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -3216,8 +3216,8 @@ dwb_init_gui() {
dwb.gui.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
else
dwb.gui.window = gtk_plug_new(dwb.gui.wid);
- gtk_window_set_wmclass(GTK_WINDOW(dwb.gui.window), dwb.misc.name, dwb.misc.name);
- gtk_widget_set_name(dwb.gui.window, "dwb");
+ gtk_window_set_wmclass(GTK_WINDOW(dwb.gui.window), dwb.misc.name, "Dwb");
+ gtk_widget_set_name(dwb.gui.window, dwb.misc.name);
/* Icon */
GdkPixbuf *icon_pixbuf = gdk_pixbuf_new_from_xpm_data(icon);
gtk_window_set_icon(GTK_WINDOW(dwb.gui.window), icon_pixbuf);
@@ -3554,7 +3554,7 @@ dwb_handle_channel(GIOChannel *c, GIOCondition condition, void *data) {
/* dwb_init_fifo{{{*/
static void
-dwb_init_fifo(int single) {
+dwb_init_fifo(gboolean single) {
FILE *ff;
/* Files */
@@ -3562,7 +3562,7 @@ dwb_init_fifo(int single) {
dwb.files.unifile = g_build_filename(path, "dwb-uni.fifo", NULL);
dwb.misc.si_channel = NULL;
- if (single == NEW_INSTANCE) {
+ if (single) {
FREE(path);
return;
}
@@ -3624,9 +3624,8 @@ main(int argc, char *argv[]) {
dwb.misc.prog_path = argv[0];
dwb.gui.wid = 0;
int last = 0;
- int single = 0;
+ gboolean single = false;
int argr = argc;
-
gtk_init(&argc, &argv);
@@ -3644,7 +3643,7 @@ main(int argc, char *argv[]) {
argr -= 2;
}
else if (argv[i][1] == 'n') {
- single = NEW_INSTANCE;
+ single = true;
argr -=1;
}
else if (argv[i][1] == 'e' && argv[++i]) {
@@ -3673,7 +3672,7 @@ main(int argc, char *argv[]) {
}
dwb_init_files();
dwb_init_settings();
- if (GET_BOOL("save-session") && argr == 1 && !restore && single != NEW_INSTANCE) {
+ if (GET_BOOL("save-session") && argr == 1 && !restore && !single) {
restore = "default";
}
diff --git a/src/dwb.h b/src/dwb.h
index c2320919..a176ac47 100644
--- a/src/dwb.h
+++ b/src/dwb.h
@@ -55,8 +55,6 @@
#ifndef COPYRIGHT
#define COPYRIGHT "© 2010-2011 Stefan Bolte"
#endif
-#define SINGLE_INSTANCE 1
-#define NEW_INSTANCE 2
#define PBAR_LENGTH 20
#define STRING_LENGTH 1024
@@ -156,7 +154,7 @@
fprintf(stderr, "\n\033[31;1mDEBUG:\033[0m %s:%d:%s():\t", __FILE__, __LINE__, __func__); \
fprintf(stderr, __VA_ARGS__);\
fprintf(stderr, "\n"); \
- } while(0);
+ } while(0)
#else
#define PRINT_DEBUG(message, ...)
diff --git a/src/session.c b/src/session.c
index 0b9414f3..e7390a6b 100644
--- a/src/session.c
+++ b/src/session.c
@@ -68,8 +68,12 @@ session_load_webview(GList *gl, char *uri, int last) {
void
session_list() {
char *path = util_build_path();
- dwb.files.session = g_build_filename(path, "session", NULL);
+ dwb.files.session = util_check_directory(g_build_filename(path, dwb.misc.profile, "session", NULL));
char **content = session_get_groups();
+ if (content == NULL) {
+ fprintf(stderr, "No sessions found for profile: %s\n", dwb.misc.profile);
+ exit(EXIT_SUCCESS);
+ }
int i=1;
while (content[i]) {
char **group = g_strsplit(content[i], "\n", -1);