Ticket #8986: streamReadPatch.patch

File streamReadPatch.patch, 1.2 KB (added by Andy Stevenson <lists@…>, 14 years ago)
  • libs/libmyth/util.cpp

     
    945945                ok = false;
    946946            }
    947947        }
     948
     949#if CONFIG_DARWIN
     950        if (src.isSequential())
     951        {
     952            qint64 bytesAvail;
     953            do
     954            {
     955                myth_yield();
     956
     957                bytesAvail = src.size();
     958                if (bytesAvail > 0 && bytesAvail < buflen)
     959                {
     960                    // Adding this sleep call when a small number of bytes
     961                    // is available seems to correct the problem with the hang
     962                    // in QFSFileEnginePrivate::nativeRead on MacOS.
     963                    //
     964                    // With the sleep, src.atEnd() correctly returns true
     965                    // after the last read.  Otherwise, it returns false forever.
     966                    sleep(1);
     967                }
     968            } while (bytesAvail == 0 && !src.atEnd());
     969
     970            if (src.atEnd())
     971            {
     972                break;
     973            }
     974        }
     975#endif
    948976    }
    949977    delete[] buf;
    950978