Display more specific error messages when project open fails.
This commit is contained in:
parent
38182a85e3
commit
9c21fb209a
|
@ -107,7 +107,7 @@ LASH::handle_restore_file ( const char *path )
|
||||||
|
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
|
|
||||||
return Project::open( project_path );
|
return Project::open( project_path ) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -209,11 +209,12 @@ Project::validate ( const char *name )
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
/** try to open project /name/. Returns 0 if sucsessful, an error code otherwise */
|
||||||
|
int
|
||||||
Project::open ( const char *name )
|
Project::open ( const char *name )
|
||||||
{
|
{
|
||||||
if ( ! validate( name ) )
|
if ( ! validate( name ) )
|
||||||
return false;
|
return E_INVALID;
|
||||||
|
|
||||||
close();
|
close();
|
||||||
|
|
||||||
|
@ -222,7 +223,7 @@ Project::open ( const char *name )
|
||||||
if ( ! get_lock( ".lock" ) )
|
if ( ! get_lock( ".lock" ) )
|
||||||
{
|
{
|
||||||
WARNING( "Could not open project: locked by another process!" );
|
WARNING( "Could not open project: locked by another process!" );
|
||||||
return false;
|
return Project::E_LOCKED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! Loggable::open( "history" ) )
|
if ( ! Loggable::open( "history" ) )
|
||||||
|
@ -241,7 +242,7 @@ Project::open ( const char *name )
|
||||||
|
|
||||||
timeline->zoom_fit();
|
timeline->zoom_fit();
|
||||||
|
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -271,7 +272,7 @@ Project::create ( const char *name, const char *template_name )
|
||||||
|
|
||||||
/* TODO: copy template */
|
/* TODO: copy template */
|
||||||
|
|
||||||
if ( open( name ) )
|
if ( open( name ) == 0 )
|
||||||
{
|
{
|
||||||
write_info();
|
write_info();
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,20 @@ class Project
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
E_INVALID = -1,
|
||||||
|
E_LOCKED = -2,
|
||||||
|
E_PERM = -3,
|
||||||
|
};
|
||||||
|
|
||||||
static bool write_info ( void );
|
static bool write_info ( void );
|
||||||
static bool read_info ( void );
|
static bool read_info ( void );
|
||||||
static const char *name ( void ) { return Project::_name; }
|
static const char *name ( void ) { return Project::_name; }
|
||||||
static void set_name ( const char *name );
|
static void set_name ( const char *name );
|
||||||
static bool close ( void );
|
static bool close ( void );
|
||||||
static bool validate ( const char *name );
|
static bool validate ( const char *name );
|
||||||
static bool open ( const char *name );
|
static int open ( const char *name );
|
||||||
static bool open ( void ) { return _is_open; }
|
static bool open ( void ) { return _is_open; }
|
||||||
static bool create ( const char *name, const char *template_name );
|
static bool create ( const char *name, const char *template_name );
|
||||||
|
|
||||||
|
|
|
@ -160,10 +160,10 @@ Loggable::progress_callback( &TLE::progress_cb, this );} {}
|
||||||
Function {make_window()} {open
|
Function {make_window()} {open
|
||||||
} {
|
} {
|
||||||
Fl_Window main_window {
|
Fl_Window main_window {
|
||||||
label Timeline
|
label Timeline open
|
||||||
xywh {174 117 1025 770} type Double resizable xclass Non_DAW visible
|
xywh {174 117 1025 770} type Double resizable xclass Non_DAW visible
|
||||||
} {
|
} {
|
||||||
Fl_Menu_Bar menubar {
|
Fl_Menu_Bar menubar {open
|
||||||
xywh {0 0 1024 25}
|
xywh {0 0 1024 25}
|
||||||
} {
|
} {
|
||||||
Submenu {} {
|
Submenu {} {
|
||||||
|
@ -198,16 +198,29 @@ if ( ! name )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
if ( ! Project::validate( name ) )
|
int r = Project::open( name );
|
||||||
{
|
|
||||||
fl_alert( "The path \\"%s\\"\\ndoes not refer to a valid Non-DAW project!", name );
|
|
||||||
}
|
|
||||||
else if ( ! Project::open( name ) )
|
|
||||||
{
|
|
||||||
fl_alert( "Could not open \\"%s\\" as a Non-DAW project!", name );
|
|
||||||
|
|
||||||
|
if ( r < 0 )
|
||||||
|
{
|
||||||
|
const char *s = "";
|
||||||
|
|
||||||
|
switch ( r )
|
||||||
|
{
|
||||||
|
case Project::E_LOCKED:
|
||||||
|
s = "Locked by another process";
|
||||||
|
break;
|
||||||
|
case Project::E_PERM:
|
||||||
|
s = "Access denied";
|
||||||
|
break;
|
||||||
|
case Project::E_INVALID:
|
||||||
|
s = "Not a Non-DAW project";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fl_alert( "Could not open project \\"%s\\":\\n\\n\\t%s", name, s );
|
||||||
// we are in a somewhar ambiguous state now with no project open.
|
// we are in a somewhar ambiguous state now with no project open.
|
||||||
}}
|
}} selected
|
||||||
xywh {10 10 40 25}
|
xywh {10 10 40 25}
|
||||||
}
|
}
|
||||||
MenuItem {} {
|
MenuItem {} {
|
||||||
|
@ -932,7 +945,7 @@ while ( window->shown() )
|
||||||
Function {make_window()} {open
|
Function {make_window()} {open
|
||||||
} {
|
} {
|
||||||
Fl_Window window {
|
Fl_Window window {
|
||||||
label {Project info} open selected
|
label {Project info} open
|
||||||
private xywh {649 226 520 625} type Double modal visible
|
private xywh {649 226 520 625} type Double modal visible
|
||||||
} {
|
} {
|
||||||
Fl_Value_Output {} {
|
Fl_Value_Output {} {
|
||||||
|
|
|
@ -140,7 +140,7 @@ main ( int argc, char **argv )
|
||||||
tle->run();
|
tle->run();
|
||||||
|
|
||||||
if ( argc > 1 )
|
if ( argc > 1 )
|
||||||
if ( ! Project::open( argv[ 1 ] ) )
|
if ( Project::open( argv[ 1 ] ) != 0 )
|
||||||
FATAL( "Could not open project specified on command line" );
|
FATAL( "Could not open project specified on command line" );
|
||||||
|
|
||||||
/* FIXME: open project in /tmp if none is given? */
|
/* FIXME: open project in /tmp if none is given? */
|
||||||
|
|
Loading…
Reference in New Issue