Fixes STR#3318 for win32.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@11879 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
6348651114
commit
2f6c01b590
@ -72,7 +72,7 @@ ExternalCodeEditor::ExternalCodeEditor() {
|
||||
|
||||
// DTOR
|
||||
ExternalCodeEditor::~ExternalCodeEditor() {
|
||||
kill_editor(); // Kill any open editors, deletes tmp file
|
||||
close_editor(); // close editor, delete tmp file
|
||||
set_filename(0); // free()s filename
|
||||
}
|
||||
|
||||
@ -132,6 +132,35 @@ static int terminate_app(DWORD pid, DWORD msecTimeout) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// [Protected] Wait for editor to close
|
||||
void ExternalCodeEditor::close_editor() {
|
||||
if ( G_debug ) printf("close_editor() called: pid=%ld\n", long(pinfo_.dwProcessId));
|
||||
// Wait until editor is closed + reaped
|
||||
while ( is_editing() ) {
|
||||
switch ( reap_editor() ) {
|
||||
case -1: // error
|
||||
fl_alert("Error reaping external editor\n"
|
||||
"pid=%ld file=%s", long(pinfo_.dwProcessId), filename());
|
||||
break;
|
||||
case 0: // process still running
|
||||
switch ( fl_choice("Please close external editor\npid=%ld file=%s",
|
||||
"Force Close", // button 0
|
||||
"Closed", // button 1
|
||||
0, // button 2
|
||||
long(pinfo_.dwProcessId), filename() ) ) {
|
||||
case 0: // Force Close
|
||||
kill_editor();
|
||||
continue;
|
||||
case 1: // Closed? try to reap
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
default: // process reaped
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// [Protected] Kill the running editor (if any) and cleanup
|
||||
// Kills the editor, reaps the process, and removes the tmp file.
|
||||
// The dtor calls this to ensure no editors remain running when fluid exits.
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
~ExternalCodeEditor();
|
||||
int is_editing();
|
||||
DWORD reap_editor();
|
||||
void close_editor();
|
||||
const char *filename() { return filename_; }
|
||||
int open_editor(const char *editor_cmd, const char *code);
|
||||
int handle_changes(const char **code, int force=0);
|
||||
|
Loading…
Reference in New Issue
Block a user