Changeset 1051


Ignore:
Timestamp:
01/21/11 20:04:11 (2 years ago)
Author:
msl
Message:

Fix camera crash because syntax error in ptpcam

+ lua(r) syntax error will be shown direct in ptpcam.

+ fix in ptpcam chdkde changeset 560: http://my-trac.assembla.com/chdkde/changeset/560

Location:
trunk/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/ptp.c

    r1043 r1051  
    417417 
    418418        free(buf); 
    419  
    420         if ( param3 & PTP_CHDK_ES_WAIT ) 
    421         { 
    422  
    423           while ( script_is_running() ) 
    424             msleep(100); 
    425  
    426           if ( param3 & PTP_CHDK_ES_RESULT ) 
     419         
     420        if (script_action_stack < 0) 
     421        { 
     422          ptp.code = PTP_RC_InvalidParameter; 
     423          break; 
     424        } 
     425        else 
     426        { 
     427 
     428          if ( param3 & PTP_CHDK_ES_WAIT ) 
    427429          { 
    428             lua_State *Lt; 
    429             temp_data.lua_state = lua_consume_result(); 
    430             Lt = get_lua_thread(temp_data.lua_state); 
    431             temp_data_kind = 2; 
    432             if ( lua_gettop(Lt) == 0 ) 
     430 
     431            while ( script_is_running() ) 
     432              msleep(100); 
     433 
     434            if ( param3 & PTP_CHDK_ES_RESULT ) 
    433435            { 
    434               temp_data_extra = PTP_CHDK_TYPE_NOTHING; 
    435             } else if ( lua_isnil(Lt,1) ) 
    436             { 
    437               temp_data_extra = PTP_CHDK_TYPE_NIL; 
    438             } else if ( lua_isboolean(Lt,1) ) 
    439             { 
    440               temp_data_extra = PTP_CHDK_TYPE_BOOLEAN; 
    441             } else if ( lua_isnumber(Lt,1) ) 
    442             { 
    443               temp_data_extra = PTP_CHDK_TYPE_INTEGER; 
    444             } else if ( lua_isstring(Lt,1) ) 
    445             { 
    446               temp_data_extra = PTP_CHDK_TYPE_STRING; 
    447             } else { 
    448               temp_data_extra = PTP_CHDK_TYPE_NOTHING; 
    449             } 
    450             ptp.num_param = 1; 
    451             ptp.param1 = temp_data_extra; 
    452             if ( temp_data_extra != PTP_CHDK_TYPE_STRING ) 
    453             { 
    454               if ( temp_data_extra == PTP_CHDK_TYPE_BOOLEAN ) 
    455               { 
     436              lua_State *Lt; 
     437              temp_data.lua_state = lua_consume_result(); 
     438              Lt = get_lua_thread(temp_data.lua_state); 
     439              temp_data_kind = 2; 
     440              if ( lua_gettop(Lt) == 0 ) 
     441              { 
     442                temp_data_extra = PTP_CHDK_TYPE_NOTHING; 
     443              } else if ( lua_isnil(Lt,1) ) 
     444              { 
     445                temp_data_extra = PTP_CHDK_TYPE_NIL; 
     446              } else if ( lua_isboolean(Lt,1) ) 
     447              { 
     448                temp_data_extra = PTP_CHDK_TYPE_BOOLEAN; 
     449              } else if ( lua_isnumber(Lt,1) ) 
     450              { 
     451                temp_data_extra = PTP_CHDK_TYPE_INTEGER; 
     452              } else if ( lua_isstring(Lt,1) ) 
     453              { 
     454                temp_data_extra = PTP_CHDK_TYPE_STRING; 
     455              } else { 
     456                temp_data_extra = PTP_CHDK_TYPE_NOTHING; 
     457              } 
     458              ptp.num_param = 1; 
     459              ptp.param1 = temp_data_extra; 
     460              if ( temp_data_extra != PTP_CHDK_TYPE_STRING ) 
     461              { 
     462                if ( temp_data_extra == PTP_CHDK_TYPE_BOOLEAN ) 
     463                { 
     464                  ptp.num_param = 2; 
     465                  ptp.param2 = lua_toboolean(Lt,1); 
     466                } if ( temp_data_extra == PTP_CHDK_TYPE_INTEGER ) 
     467                { 
     468                  ptp.num_param = 2; 
     469                  ptp.param2 = lua_tonumber(Lt,1); 
     470                } 
     471                lua_close(Lt); 
     472                temp_data_kind = 0; 
     473              } else { 
    456474                ptp.num_param = 2; 
    457                 ptp.param2 = lua_toboolean(Lt,1); 
    458               } if ( temp_data_extra == PTP_CHDK_TYPE_INTEGER ) 
    459               { 
    460                 ptp.num_param = 2; 
    461                 ptp.param2 = lua_tonumber(Lt,1); 
     475                ptp.param2 = lua_objlen(Lt,1); 
    462476              } 
    463               lua_close(Lt); 
    464               temp_data_kind = 0; 
    465             } else { 
    466               ptp.num_param = 2; 
    467               ptp.param2 = lua_objlen(Lt,1); 
    468477            } 
    469478          } 
  • trunk/core/ptp.h

    r1005 r1051  
    1818#define PTP_RC_GeneralError 0x2002 
    1919#define PTP_RC_ParameterNotSupported 0x2006 
     20#define PTP_RC_InvalidParameter 0x201D 
    2021 
    2122// N.B.: unused parameters should be set to 0 
  • trunk/core/script.c

    r1045 r1051  
    676676long script_start_ptp( char *script , int keep_result ) 
    677677{ 
    678   lua_script_start(script); 
     678  if (!lua_script_start(script)) return -1; 
    679679  lua_keep_result = keep_result; 
    680680  state_lua_kbd_first_call_to_resume = 1; 
Note: See TracChangeset for help on using the changeset viewer.