From ec406db06a0c86a7cf801bf6593ef20a7d689a34 Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Fri, 20 Feb 2009 19:05:35 +0000 Subject: * fix for segfault if no .vmchooser is found .. git-svn-id: http://svn.openslx.org/svn/openslx/openslx-src-tools/vmchooser/trunk@2625 95ad53e4-c205-0410-b2fa-d234c58c8868 --- vmchooser/SWindow.cxx | 25 ++++++++++++++++--------- vmchooser/userSession.cxx | 4 ++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/vmchooser/SWindow.cxx b/vmchooser/SWindow.cxx index a3ec373..b08b224 100644 --- a/vmchooser/SWindow.cxx +++ b/vmchooser/SWindow.cxx @@ -5,6 +5,8 @@ #include #include +#include + #include #include #include @@ -204,16 +206,21 @@ void SWindow::unfold_entries() { //sel.indented(false); char* prename = readSession(); - sel.goto_index(0); - Item* it = (Item*) sel.next(); - - while( it ) { - if(! strcmp(prename,it->label()) ) { - sel.select_only_this(0); - curr = it; - return; + if ( prename == NULL ) { + return; + } else { + printf("readsesseion returned: %s", prename); + sel.goto_index(0); + Item* it = (Item*) sel.next(); + + while( it ) { + if(! strcmp(prename,it->label()) ) { + sel.select_only_this(0); + curr = it; + return; + } + it = (Item*) sel.next(); } - it = (Item*) sel.next(); } } diff --git a/vmchooser/userSession.cxx b/vmchooser/userSession.cxx index af11d4b..9f0edaa 100644 --- a/vmchooser/userSession.cxx +++ b/vmchooser/userSession.cxx @@ -59,6 +59,10 @@ char* readSession() { // read presaved session with ifstream ifstream fin(fname.c_str()); + if (!fin) { + cout << ".vmchooser file not found .. continue with global default" << endl; + return NULL; + } string sessname; getline(fin,sessname); char* blub = (char*) malloc(sessname.size()); -- cgit v1.2.3-55-g7522