gui: Improve session management when opening files.

This commit is contained in:
tgoff0 2014-12-15 18:23:08 +00:00
parent 049efb642f
commit 52fdc300b8

View file

@ -147,28 +147,48 @@ proc openFile { filename } {
global undolog activetool global undolog activetool
global canvas_list curcanvas systype global canvas_list curcanvas systype
global changed global changed
global oper_mode
if { [lindex [file extension $filename] 0] == ".py" } {
execPythonFile $filename
return
}
set prev_oper_mode $oper_mode
if { [popupStopSessionPrompt] == "cancel" } { if { [popupStopSessionPrompt] == "cancel" } {
return return
} }
set currentFile $filename set currentFile $filename
if { [lindex [file extension $currentFile] 0] == ".py" } {
set flags 0x10 ;# status request flag
sendRegMessage -1 $flags [list "exec" $currentFile]
addFileToMrulist $currentFile
return
}
if { [file extension $currentFile] == ".xml" } {
setGuiTitle "" setGuiTitle ""
cleanupGUIState cleanupGUIState
resetGlobalVars openfile resetGlobalVars openfile
if { $canvas_list == "" } {
set curcanvas [newCanvas ""]
}
if { $prev_oper_mode == "exec" } {
if { $oper_mode == "exec" } {
global g_current_session
setOperMode edit
set g_current_session 0
}
# disconnect and get a new session number
set name [lindex [getEmulPlugin "*"] 0]
if { $name != "" } {
pluginConnect $name disconnect 1
pluginConnect $name connect 1
}
}
if { [file extension $currentFile] == ".xml" } {
xmlFileLoadSave "open" $currentFile xmlFileLoadSave "open" $currentFile
addFileToMrulist $currentFile addFileToMrulist $currentFile
return return
} }
set fileName [file tail $currentFile]
# flush daemon configuration # flush daemon configuration
if { [llength [findWlanNodes ""]] > 0 } { if { [llength [findWlanNodes ""]] > 0 } {
if { [lindex $systype 0] == "FreeBSD" } { if { [lindex $systype 0] == "FreeBSD" } {
@ -186,12 +206,8 @@ proc openFile { filename } {
return return
} }
close $fileId close $fileId
setGuiTitle ""
loadCfg $cfg loadCfg $cfg
set curcanvas [lindex $canvas_list 0]
switchCanvas none
# already called from switchCanvas: redrawAll
resetGlobalVars openfile
set undolog(0) $cfg set undolog(0) $cfg
set activetool select set activetool select