From: Tatsuro M. <tma...@ya...> - 2018-03-11 23:54:58
|
----- Original Message ----- > From: Enrico Forestieri > To: Tatsuro MATSUOKA > Cc: > Date: 2018/3/12, Mon 06:56 > Subject: Re: qt terminal on Cygwin > > Hi! Sorry for the personal email but it seems I cannot post to the > gnuplot mailing list. > > On Sat, Mar 10, 2018 at 04:50:44PM +0900, Tatsuro MATSUOKA wrote: > >> I have tried the patch for qt-5.4.0 in the below thread >> >> https://sourceforge.net/p/gnuplot/mailman/message/33212164/ >> >> For gnuplot >> --- old/src/qtterminal/qt_term.cpp 2014-12-30 19:52:59.000000000 +0100 >> +++ new/src/qtterminal/qt_term.cpp 2015-01-04 01:25:03.219400000 +0100 >> @@ -273,7 +273,19 @@ >> // The QLocalSocket::waitForConnected does not respect the time out > argument when >> // the gnuplot_qt application is not yet started or has not yet > self-initialized. >> // To wait for it, we need to implement the timeout ourselves >> +#ifdef __CYGWIN__ >> + QDateTime timeout = QDateTime::currentDateTime().addMSecs(5000); >> + char const * const sockname = >> + qt->socket.fullServerName().toLocal8Bit().constData(); >> + do >> + { >> + usleep(300000); >> + >> + } while(access(sockname, F_OK) != 0 && > QDateTime::currentDateTime() < timeout); >> + timeout = QDateTime::currentDateTime().addMSecs(1000); >> +#else >> QDateTime timeout = QDateTime::currentDateTime().addMSecs(30000); >> +#endif >> do >> { >> qt->socket.connectToServer(server); > > Seemingly, patching the gnuplot sources is not necessary anymore, > so the above patch can be dropped. > >> For qt >> >> --- > a/qtbase-opensource-src-5.4.0/src/network/socket/qlocalsocket_unix.cpp > 2014-12-25 19:48:59.845052000 +0100 >> +++ > b/qtbase-opensource-src-5.4.0/src/network/socket/qlocalsocket_unix.cpp > 2014-12-25 18:41:32.359905400 +0100 >> @@ -240,6 +240,7 @@ void QLocalSocket::connectToServer(OpenM >> > QLatin1String("QLocalSocket::connectToServer")); >> return; >> } >> +#ifndef Q_OS_CYGWIN >> // set non blocking so we can try to connect and it won't wait >> int flags = fcntl(d->connectingSocket, F_GETFL, 0); >> if (-1 == flags >> @@ -248,6 +249,7 @@ void QLocalSocket::connectToServer(OpenM >> QLatin1String("QLocalSocket::connectToServer")); >> return; >> } >> +#endif >> >> // _q_connectToSocket does the actual connecting >> d->connectingName = d->serverName; >> >> >> Now Qt version for cygwin is 5.9.4 >> >> However, code of corresponding part is changed to >> >> // create the socket >> if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, > SOCK_STREAM, 0, O_NONBLOCK))) { >> d->errorOccurred(UnsupportedSocketOperationError, >> > QLatin1String("QLocalSocket::connectToServer")); >> return; >> } >> >> I commented out the above > > You should simply avoid using O_NONBLOCK. Please, try the following patch: > > --- a/qtbase-everywhere-src-5.10.1/src/network/socket/qlocalsocket_unix.cpp > +++ b/qtbase-everywhere-src-5.10.1/src/network/socket/qlocalsocket_unix.cpp > @@ -239,7 +239,7 @@ void QLocalSocket::connectToServer(OpenM > } > > // create the socket > - if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0, > O_NONBLOCK))) { > + if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, > 0))) { > d->errorOccurred(UnsupportedSocketOperationError, > > QLatin1String("QLocalSocket::connectToServer")); > return; > > -- > Enrico Thanks the above worked!! Tatsuro |