--- filter/source/graphicfilter/ieps/ieps.cxx.orig 2014-06-12 17:25:19.000000000 +0900 +++ filter/source/graphicfilter/ieps/ieps.cxx 2014-08-07 19:00:28.000000000 +0900 @@ -36,6 +36,7 @@ #include #include #include +#include class FilterConfigItem; @@ -245,6 +246,29 @@ return bRet; } +struct WriteData +{ + oslFileHandle m_pFile; + const sal_uInt8 *m_pBuf; + sal_uInt32 m_nBytesToWrite; +}; + +extern "C" { + +static void WriteFileInThread(void *wData) +{ + WriteData *wdata; + sal_uInt64 nCount; + wdata = (WriteData *)wData; + osl_writeFile(wdata->m_pFile, wdata->m_pBuf, wdata->m_nBytesToWrite, &nCount); + // File must be closed here. + // Otherwise, the helper process may wait for the next input, + // then its stdout is not closed and osl_readFile() blocks. + if (wdata->m_pFile) osl_closeFile(wdata->m_pFile); +} + +} + static bool RenderAsBMPThroughHelper(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &rGraphic, OUString &rProgName, rtl_uString *pArgs[], size_t nArgs) { @@ -258,11 +282,15 @@ if (eErr!=osl_Process_E_None) return false; + WriteData Data; + oslThread hThread; + Data.m_pFile = pIn; + Data.m_pBuf = pBuf; + Data.m_nBytesToWrite = nBytesRead; + hThread = osl_createThread(WriteFileInThread, &Data); + bool bRet = false; sal_uInt64 nCount; - osl_writeFile(pIn, pBuf, nBytesRead, &nCount); - if (pIn) osl_closeFile(pIn); - if (nCount == nBytesRead) { SvMemoryStream aMemStm; sal_uInt8 aBuf[32000];