Molecular Modeling Software
リビジョン | f6d97e8d931665836a88cbc1c0af4e1f0498bfe9 (tree) |
---|---|
日時 | 2022-01-29 00:14:00 |
作者 | Toshi Nagata <alchemist.2005@nift...> |
コミッター | Toshi Nagata |
Calling subprocess was (still) having problems. Hopefully fixed.
@@ -1484,8 +1484,8 @@ MyApp::CallSubProcess(const char *cmdline, const char *procname, int (*callback) | ||
1484 | 1484 | wxString bufstr; |
1485 | 1485 | wxString buferrstr; |
1486 | 1486 | while (1) { |
1487 | - m_process->GetLine(bufstr); | |
1488 | - if (bufstr.Length() > 0) { | |
1487 | + int len1 = m_process->GetLine(bufstr); | |
1488 | + if (len1 > 0) { | |
1489 | 1489 | #if LOG_SUBPROCESS |
1490 | 1490 | dateTime.SetToCurrent(); |
1491 | 1491 | fprintf(fplog, "%s[STDOUT]%s", (const char *)(dateTime.FormatISOCombined(' ')), (const char *)bufstr); |
@@ -1501,8 +1501,8 @@ MyApp::CallSubProcess(const char *cmdline, const char *procname, int (*callback) | ||
1501 | 1501 | MyAppCallback_showScriptMessage("%s", (const char *)bufstr); |
1502 | 1502 | } |
1503 | 1503 | } |
1504 | - m_process->GetErrorLine(buferrstr); | |
1505 | - if (buferrstr.Length() > 0) { | |
1504 | + int len2 = m_process->GetErrorLine(buferrstr); | |
1505 | + if (len2 > 0) { | |
1506 | 1506 | #if LOG_SUBPROCESS |
1507 | 1507 | dateTime.SetToCurrent(); |
1508 | 1508 | fprintf(fplog, "%s[STDERR]%s", (const char *)(dateTime.FormatISOCombined(' ')), buf); |
@@ -1517,6 +1517,11 @@ MyApp::CallSubProcess(const char *cmdline, const char *procname, int (*callback) | ||
1517 | 1517 | } |
1518 | 1518 | } |
1519 | 1519 | |
1520 | + if (len1 < 0 && len2 < 0) { | |
1521 | + // The standard/error outputs are exhausted; the process should have terminated | |
1522 | + // (Normally, this should be detected by wxBetterProcess::OnTerminate()) | |
1523 | + interrupted = true; | |
1524 | + } | |
1520 | 1525 | ::wxMilliSleep(25); |
1521 | 1526 | if (callback != NULL && callback != DUMMY_CALLBACK) { |
1522 | 1527 | callback_result = (*callback)(callback_data); |
@@ -1527,6 +1532,8 @@ MyApp::CallSubProcess(const char *cmdline, const char *procname, int (*callback) | ||
1527 | 1532 | SetProgressValue(-1); |
1528 | 1533 | if (IsInterrupted()) |
1529 | 1534 | interrupted = true; |
1535 | + } else { | |
1536 | + ::wxSafeYield(); // This allows updating console and wxProcess status | |
1530 | 1537 | } |
1531 | 1538 | |
1532 | 1539 | #if LOG_SUBPROCESS |