diff --git a/app/src/gambas3/.project b/app/src/gambas3/.project index 1fea9ad08..2ec57ffab 100644 --- a/app/src/gambas3/.project +++ b/app/src/gambas3/.project @@ -1,5 +1,5 @@ # Gambas Project File 3.0 -# Compiled with Gambas 2.99.0 (r1601) +# Compiled with Gambas 2.99.0 (r1645) Title=Gambas 3 Startup=Project Icon=img/logo/new-logo.png diff --git a/app/src/gambas3/Design.module b/app/src/gambas3/Design.module index 771995770..b9f594689 100644 --- a/app/src/gambas3/Design.module +++ b/app/src/gambas3/Design.module @@ -707,14 +707,14 @@ Private Sub Start(sCmd As String) sExec &= " " & Quote.Shell(sArg) Next - $hProcess = Shell sExec For Read Write + $hProcess = Shell sExec For Read Write As "Process" Else aExec = [System.Path &/ "bin/gbx" & System.Version, "-g", "-f", File.Dir(SConv(Project.Path)), "--"] aExec.Insert(Project.Arguments) - $hProcess = Exec aExec For Read Write 'AS $hProcess + $hProcess = Exec aExec For Read Write As "Process" Endif diff --git a/app/src/gambas3/Package.module b/app/src/gambas3/Package.module index ce520077c..ca15207fc 100644 --- a/app/src/gambas3/Package.module +++ b/app/src/gambas3/Package.module @@ -274,9 +274,9 @@ Private Sub RunCommand(sCmd As String, Optional sDir As String) $sOutput = "" $bEnd = False If sDir Then - Shell "(cd " & SConv(Quote.Shell(sDir)) & ";" & sCmd & ") 2>&1" For Read 'TO sOutput + Shell "(cd " & SConv(Quote.Shell(sDir)) & ";" & sCmd & ") 2>&1" For Read As "Process" Else - Shell sCmd & " 2>&1" For Read + Shell sCmd & " 2>&1" For Read As "Process" Endif Repeat Sleep 0.01 @@ -357,8 +357,7 @@ Private Function MakeDebPackage(sSys As String) ' Rename the source archive project directory to the package name 'TRY MOVE Path &/ (sPrefix & Subst("&1", Project.Name)) TO sPackagePath Try Kill sArch - Try Shell "cp -Rf " & sPackagePath & " " & sPackagePath & ".orig" - + Try Shell "cp -Rf " & sPackagePath & " " & sPackagePath & ".orig" Wait Try Mkdir sPackagePath &/ "debian" @@ -535,10 +534,9 @@ Private Function MakeDebPackage(sSys As String) AddLog(("Creating package...")) sCmd = "cd " & Quote.Shell(sPackagePath) & "; fakeroot dpkg-buildpackage -d" - Shell sCmd Wait For Read + Shell sCmd Wait If Process.LastValue > 2 Then Error.Raise(("'dpkg-buildpackage' has failed.")) - Try Shell "rm -Rf " & Quote.Shell(sPackagePath) Wait Try Shell "rm -f " & Quote.Shell(Path) &/ "*.dsc.asc" Wait @@ -930,7 +928,7 @@ Private Function MakeRpmPackage(sSys As String) 'sTemp = Temp$ $sOutput = "" $bEnd = False - Shell sCmd & " 2>&1" Wait For Read 'TO sOutput + Shell sCmd & " 2>&1" Wait For Read As "Process" 'TO sOutput ' REPEAT ' SLEEP 0.01 ' WAIT diff --git a/app/src/gambas3/VersionControl.module b/app/src/gambas3/VersionControl.module index 380dae399..5ee8e918c 100644 --- a/app/src/gambas3/VersionControl.module +++ b/app/src/gambas3/VersionControl.module @@ -33,7 +33,7 @@ End Private Sub Run(sCmd As String, Optional sRemove As String) $bEnd = False - Shell sCmd & " 2>&1" For Read 'TO sOutput + Shell sCmd & " 2>&1" For Read As "Process" 'TO sOutput If sRemove Then sCmd = Replace(sCmd, sRemove, "") diff --git a/gb.qt/src/CWindow.cpp b/gb.qt/src/CWindow.cpp index 9efb81d77..d43175c85 100644 --- a/gb.qt/src/CWindow.cpp +++ b/gb.qt/src/CWindow.cpp @@ -1597,10 +1597,10 @@ void MyMainWindow::showActivate(QWidget *transient) doReparent(newParentWidget, getWFlags(), pos()); } - /*#ifndef NO_X_WINDOW - if (THIS != CWINDOW_Main) - X11_set_transient_for(winId(), QWIDGET(CWINDOW_Main)->winId()); - #endif*/ + #ifndef NO_X_WINDOW + if (newParentWidget && getTool()) + X11_set_transient_for(winId(), newParentWidget->winId()); + #endif //qDebug("showActivate %p", _object); diff --git a/main/gbc/gbc_trans_subr.c b/main/gbc/gbc_trans_subr.c index f29854d6e..814c76170 100644 --- a/main/gbc/gbc_trans_subr.c +++ b/main/gbc/gbc_trans_subr.c @@ -541,7 +541,7 @@ static void trans_exec_shell(bool shell) { int mode = TS_EXEC_NONE; bool wait; - bool as = FALSE; + bool as = TRUE; /* programme �ex�uter */ TRANS_expression(FALSE); @@ -563,7 +563,6 @@ static void trans_exec_shell(bool shell) if (TRANS_is(RS_OUTPUT)) mode |= TS_EXEC_WRITE; } - as = TRUE; } else if (TRANS_is(RS_TO)) { @@ -573,6 +572,9 @@ static void trans_exec_shell(bool shell) mode = TS_EXEC_STRING; wait = TRUE; } + + if (wait) + as = FALSE; CODE_push_boolean(wait); CODE_push_number(mode); diff --git a/main/gbx/gbx_c_file.c b/main/gbx/gbx_c_file.c index a6274b4f2..c669d324a 100644 --- a/main/gbx/gbx_c_file.c +++ b/main/gbx/gbx_c_file.c @@ -688,6 +688,15 @@ BEGIN_PROPERTY(CSTREAM_eof) GB_ReturnBoolean(CSTREAM_stream(THIS_STREAM)->common.eof); END_PROPERTY + +BEGIN_PROPERTY(CSTREAM_blocking) + + if (READ_PROPERTY) + GB_ReturnBoolean(STREAM_is_blocking(CSTREAM_stream(THIS_STREAM))); + else + STREAM_blocking(CSTREAM_stream(THIS_STREAM), VPROP(GB_BOOLEAN)); + +END_PROPERTY #endif @@ -702,6 +711,7 @@ GB_DESC NATIVE_Stream[] = GB_PROPERTY("EndOfLine", "i", CSTREAM_eol), GB_METHOD("Close", NULL, CSTREAM_close, NULL), GB_PROPERTY_READ("EndOfFile", "b", CSTREAM_eof), + GB_PROPERTY("Blocking", "b", CSTREAM_blocking), GB_END_DECLARE }; diff --git a/main/gbx/gbx_c_process.c b/main/gbx/gbx_c_process.c index 7dd59054a..814b3b2f0 100644 --- a/main/gbx/gbx_c_process.c +++ b/main/gbx/gbx_c_process.c @@ -610,8 +610,8 @@ CPROCESS *CPROCESS_create(int mode, void *cmd, char *name) /*printf("** CPROCESS_create <<<< \n");*/ - if (!name || !*name) - name = "Process"; + //if (!name || !*name) + // name = "Process"; OBJECT_new((void **)(void *)&process, CLASS_Process, name, OP ? (OBJECT *)OP : (OBJECT *)CP); @@ -620,6 +620,9 @@ CPROCESS *CPROCESS_create(int mode, void *cmd, char *name) OBJECT_UNREF_KEEP(process, "CPROCESS_create"); + if (!name || !*name) + STREAM_blocking(CSTREAM_stream(process), TRUE); + /*printf("** CPROCESS_create >>>> \n");*/ return process; diff --git a/main/gbx/gbx_stream.c b/main/gbx/gbx_stream.c index 3f9e0dc1b..b76445fcd 100644 --- a/main/gbx/gbx_stream.c +++ b/main/gbx/gbx_stream.c @@ -289,7 +289,7 @@ char STREAM_getchar(STREAM *stream) } -void STREAM_read_max(STREAM *stream, void *addr, int len) +static void STREAM_read_max(STREAM *stream, void *addr, int len) { bool is_term = stream->common.is_term; bool err; @@ -400,6 +400,42 @@ void STREAM_seek(STREAM *stream, int64_t pos, int whence) } } +static void fill_buffer(STREAM *stream, char *addr) +{ + bool err; + STREAM_eff_read = 0; + int flags, fd; + + fd = STREAM_handle(stream); + + err = (*(stream->type->read))(stream, addr, 1); + if (!err) + { + flags = fcntl(fd, F_GETFL); + if ((flags & O_NONBLOCK) == 0) + fcntl(fd, F_SETFL, flags | O_NONBLOCK); + + err = (*(stream->type->read))(stream, addr + 1, STREAM_BUFFER_SIZE - 1); + + if ((flags & O_NONBLOCK) == 0) + fcntl(fd, F_SETFL, flags); + } + + if (err) + { + switch(errno) + { + case 0: + case EAGAIN: + break; + case EIO: + break; //THROW(E_READ); + default: + THROW_SYSTEM(errno, NULL); + } + } +} + static void input(STREAM *stream, char **addr, boolean line) { @@ -428,7 +464,7 @@ static void input(STREAM *stream, char **addr, boolean line) } } - if (STREAM_eof(stream)) + if (!STREAM_is_blocking(stream) && STREAM_eof(stream)) THROW(E_EOF); buffer = stream->common.buffer; @@ -463,7 +499,8 @@ static void input(STREAM *stream, char **addr, boolean line) stream->common.buffer_pos = buffer_pos; stream->common.buffer_len = buffer_len; - STREAM_read_max(stream, buffer, STREAM_BUFFER_SIZE); + fill_buffer(stream, buffer); + //STREAM_read_max(stream, buffer, STREAM_BUFFER_SIZE); buffer_pos = 0; buffer_len = STREAM_eff_read; @@ -513,22 +550,6 @@ static void input(STREAM *stream, char **addr, boolean line) break; len++; - //COMMON_buffer[len++] = c; - - // Optimized eof - - /* - if (STREAM_eof(stream)) - { - stream->common.eof = TRUE; - break; - } - */ - /*if ((*eof_func)(stream)) - { - stream->common.eof = TRUE; - break; - }*/ } if (len > 0) @@ -1066,4 +1087,25 @@ int STREAM_write_direct(int fd, char *buffer, int len) } +void STREAM_blocking(STREAM *stream, bool block) +{ + int fd = STREAM_handle(stream); + + if (fd < 0) + return; + + if (block) + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK); + else + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); +} +bool STREAM_is_blocking(STREAM *stream) +{ + int fd = STREAM_handle(stream); + + if (fd < 0) + return TRUE; + + return (fcntl(fd, F_GETFL) & O_NONBLOCK) == 0; +} diff --git a/main/gbx/gbx_stream.h b/main/gbx/gbx_stream.h index 77399055b..f50ed84a0 100644 --- a/main/gbx/gbx_stream.h +++ b/main/gbx/gbx_stream.h @@ -231,4 +231,7 @@ void STREAM_lock(STREAM *stream); #define STREAM_is_closed(_stream) ((_stream)->type == NULL) +void STREAM_blocking(STREAM *stream, bool block); +bool STREAM_is_blocking(STREAM *stream); + #endif