From 1c85b047b6cfdbae010f0967e9c9f99f7a101d32 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Mon, 14 Oct 2019 07:47:17 +0300 Subject: tdf#94117: try gswin64c if gswin32c failed Change-Id: I3c29ef72525aa25ee8606122f01b7b611ecb2091 Reviewed-on: https://gerrit.libreoffice.org/80748 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- filter/source/graphicfilter/ieps/ieps.cxx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx index 2ce4fd01b022..39c2d1fe784d 100644 --- a/filter/source/graphicfilter/ieps/ieps.cxx +++ b/filter/source/graphicfilter/ieps/ieps.cxx @@ -296,15 +296,21 @@ static void WriteFileInThread(void *wData) } static bool RenderAsBMPThroughHelper(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, - Graphic &rGraphic, const OUString &rProgName, rtl_uString *pArgs[], size_t nArgs) + Graphic& rGraphic, + std::initializer_list aProgNames, + rtl_uString* pArgs[], size_t nArgs) { - oslProcess aProcess; + oslProcess aProcess = nullptr; oslFileHandle pIn = nullptr; oslFileHandle pOut = nullptr; oslFileHandle pErr = nullptr; - oslProcessError eErr = runProcessWithPathSearch(rProgName, - pArgs, nArgs, - &aProcess, &pIn, &pOut, &pErr); + oslProcessError eErr = osl_Process_E_Unknown; + for (const auto& rProgName : aProgNames) + { + eErr = runProcessWithPathSearch(rProgName, pArgs, nArgs, &aProcess, &pIn, &pOut, &pErr); + if (eErr == osl_Process_E_None) + break; + } if (eErr!=osl_Process_E_None) return false; @@ -362,7 +368,7 @@ static bool RenderAsBMPThroughConvert(const sal_uInt8* pBuf, sal_uInt32 nBytesRe arg1.pData, arg2.pData, arg3.pData, arg4.pData }; return RenderAsBMPThroughHelper(pBuf, nBytesRead, rGraphic, - ("convert" EXESUFFIX), + { "convert" EXESUFFIX }, args, SAL_N_ELEMENTS(args)); } @@ -389,9 +395,13 @@ static bool RenderAsBMPThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, }; return RenderAsBMPThroughHelper(pBuf, nBytesRead, rGraphic, #ifdef _WIN32 - "gswin32c" EXESUFFIX, + // Try both 32-bit and 64-bit ghostscript executable name + { + "gswin32c" EXESUFFIX, + "gswin64c" EXESUFFIX, + }, #else - "gs" EXESUFFIX, + { "gs" EXESUFFIX }, #endif args, SAL_N_ELEMENTS(args)); -- cgit