Save the cmdset stack before entering batchcommands in order to properly re-establiish the stack after batch runs instead of simply clearing it. Resolves #1085.
This commit is contained in:
parent
eb4618625d
commit
4e9d070b64
1 changed files with 14 additions and 7 deletions
|
|
@ -205,9 +205,15 @@ def purge_processor(caller):
|
||||||
del caller.ndb.batch_batchmode
|
del caller.ndb.batch_batchmode
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
# clear everything but the default cmdset.
|
# clear everything back to the state before the batch call
|
||||||
caller.cmdset.delete(BatchSafeCmdSet)
|
if caller.ndb.batch_cmdset_backup:
|
||||||
caller.cmdset.clear()
|
caller.cmdset.cmdset_stack = caller.ndb.batch_cmdset_backup
|
||||||
|
caller.cmdset.update()
|
||||||
|
del caller.ndb.batch_cmdset_backup
|
||||||
|
else:
|
||||||
|
# something went wrong. Purge cmdset except default
|
||||||
|
caller.cmdset.clear()
|
||||||
|
|
||||||
caller.scripts.validate() # this will purge interactive mode
|
caller.scripts.validate() # this will purge interactive mode
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
|
@ -269,6 +275,8 @@ class CmdBatchCommands(_COMMAND_DEFAULT_CLASS):
|
||||||
caller.ndb.batch_stackptr = 0
|
caller.ndb.batch_stackptr = 0
|
||||||
caller.ndb.batch_pythonpath = python_path
|
caller.ndb.batch_pythonpath = python_path
|
||||||
caller.ndb.batch_batchmode = "batch_commands"
|
caller.ndb.batch_batchmode = "batch_commands"
|
||||||
|
# we use list() here to create a new copy of the cmdset stack
|
||||||
|
caller.ndb.batch_cmdset_backup = list(caller.cmdset.cmdset_stack)
|
||||||
caller.cmdset.add(BatchSafeCmdSet)
|
caller.cmdset.add(BatchSafeCmdSet)
|
||||||
|
|
||||||
if 'inter' in switches or 'interactive' in switches:
|
if 'inter' in switches or 'interactive' in switches:
|
||||||
|
|
@ -377,6 +385,8 @@ class CmdBatchCode(_COMMAND_DEFAULT_CLASS):
|
||||||
caller.ndb.batch_pythonpath = python_path
|
caller.ndb.batch_pythonpath = python_path
|
||||||
caller.ndb.batch_batchmode = "batch_code"
|
caller.ndb.batch_batchmode = "batch_code"
|
||||||
caller.ndb.batch_debug = debug
|
caller.ndb.batch_debug = debug
|
||||||
|
# we use list() here to create a new copy of cmdset_stack
|
||||||
|
caller.ndb.batch_cmdset_backup = list(caller.cmdset.cmdset_stack)
|
||||||
caller.cmdset.add(BatchSafeCmdSet)
|
caller.cmdset.add(BatchSafeCmdSet)
|
||||||
|
|
||||||
if 'inter' in switches or 'interactive'in switches:
|
if 'inter' in switches or 'interactive'in switches:
|
||||||
|
|
@ -696,10 +706,7 @@ class CmdStateCC(_COMMAND_DEFAULT_CLASS):
|
||||||
step_pointer(caller, 1)
|
step_pointer(caller, 1)
|
||||||
show_curr(caller)
|
show_curr(caller)
|
||||||
|
|
||||||
del caller.ndb.batch_stack
|
purge_processor(self)
|
||||||
del caller.ndb.batch_stackptr
|
|
||||||
del caller.ndb.batch_pythonpath
|
|
||||||
del caller.ndb.batch_batchmode
|
|
||||||
caller.msg(format_code("Finished processing batch file."))
|
caller.msg(format_code("Finished processing batch file."))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue