From 182a5e8af049289e8bdad30e5a25ad444d17dffd Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 20 May 2019 13:34:52 +0200 Subject: added check if .dot file is already queued for processing before adding a new processing job --- src/dot.cpp | 92 +++++++++++++++++++++++++++++++++++++++++++++++++------------ src/dot.h | 8 +++++- 2 files changed, 81 insertions(+), 19 deletions(-) diff --git a/src/dot.cpp b/src/dot.cpp index ae51fb0..86607a6 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -806,10 +806,10 @@ int DotNodeList::compareValues(const DotNode *n1,const DotNode *n2) const //-------------------------------------------------------------------- -DotRunner::DotRunner(const QCString& file, const QCString& path, const QCString& md5Hash, +DotRunner::DotRunner(const QCString& absDotName, const QCString& path, const QCString& md5Hash, bool checkResult, const QCString& imageName) : m_dotExe(Config_getString(DOT_PATH)+"dot"), - m_file(file), m_path(path), + m_file(absDotName), m_path(path), m_checkResult(checkResult), m_imageName(imageName), m_imgExt(getDotImageExtension()), m_md5Hash(md5Hash) { @@ -1504,6 +1504,23 @@ bool DotManager::run() return TRUE; } +bool DotManager::containsRun(const QCString& absDotName, const QCString& md5Hash) +{ + QListIterator li(m_dotRuns); + DotRunner *dr; + for (li.toFirst();(dr=li.current());++li) + { + if (absDotName != QCString(dr->getFileName().data())) continue; + // we have a match + if (md5Hash != QCString(dr->getMd5Hash().data())) + { + err("md5 hash does not match for two different runs of %s !\n", absDotName.data()); + } + return TRUE; + } + return FALSE; +} + //-------------------------------------------------------------------- @@ -2373,6 +2390,7 @@ void DotGfxHierarchyTable::createGraph(DotNode *n,FTextStream &out, QCString absImgName = QCString(d.absPath().data())+"/"+imgName; QCString absMapName = QCString(d.absPath().data())+"/"+mapName; QCString absBaseName = QCString(d.absPath().data())+"/"+baseName; + QCString absDotName = absBaseName+".dot"; QListIterator dnli2(*m_rootNodes); DotNode *node; @@ -2401,19 +2419,23 @@ void DotGfxHierarchyTable::createGraph(DotNode *n,FTextStream &out, MD5Buffer((const unsigned char *)theGraph.data(),theGraph.length(),md5_sig); MD5SigToString(md5_sig,sigStr.rawData(),33); bool regenerate=FALSE; - if (checkMd5Signature(absBaseName,sigStr) || + if (DotManager::instance()->containsRun(absDotName, d.absPath().data(), sigStr)) + { + // file is already queued + regenerate=TRUE; + } + else if (checkMd5Signature(absBaseName,sigStr) || !checkDeliverables(absImgName,absMapName)) { regenerate=TRUE; // image was new or has changed - QCString dotName=absBaseName+".dot"; - QFile f(dotName); + QFile f(absDotName); if (!f.open(IO_WriteOnly)) return; FTextStream t(&f); t << theGraph; f.close(); - DotRunner *dotRun = new DotRunner(dotName,d.absPath().data(),sigStr,TRUE,absImgName); + DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),sigStr,TRUE,absImgName); dotRun->addJob(imgFmt,absImgName); dotRun->addJob(MAP_CMD,absMapName); DotManager::instance()->addRun(dotRun); @@ -3173,7 +3195,7 @@ QCString computeMd5Signature(DotNode *root, return sigStr; } -static bool updateDotGraph(DotNode *root, +static void updateDotGraph(DotNode *root, DotNode::GraphType gt, const QCString &baseName, GraphOutputFormat format, @@ -3195,7 +3217,6 @@ static bool updateDotGraph(DotNode *root, FTextStream t(&f); t << theGraph; } - return checkMd5Signature(baseName,sigStr); // graph needs to be regenerated } QCString DotClassGraph::writeGraph(FTextStream &out, @@ -3245,16 +3266,23 @@ QCString DotClassGraph::writeGraph(FTextStream &out, bool regenerate = FALSE; QCString sigStr; - if (updateDotGraph(m_startNode, + updateDotGraph(m_startNode, m_graphType, absBaseName, graphFormat, m_lrRank ? "LR" : "", - m_graphType==DotNode::Inheritance, + m_graphType == DotNode::Inheritance, TRUE, sigStr, m_startNode->label() - ) || + ); + + if (DotManager::instance()->containsRun(absDotName, d.absPath().data(), sigStr)) + { + // file is already queued + regenerate=TRUE; + } + else if (checkMd5Signature(absBaseName,sigStr) || !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName : usePDFLatex ? absPdfName : absEpsName, graphFormat==GOF_BITMAP && generateImageMap ? absMapName : QCString()) @@ -3586,7 +3614,7 @@ QCString DotInclDepGraph::writeGraph(FTextStream &out, bool regenerate = FALSE; QCString sigStr; - if (updateDotGraph(m_startNode, + updateDotGraph(m_startNode, DotNode::Dependency, absBaseName, graphFormat, @@ -3595,7 +3623,14 @@ QCString DotInclDepGraph::writeGraph(FTextStream &out, m_inverse, // backArrows sigStr, m_startNode->label() - ) || + ); + + if (DotManager::instance()->containsRun(absDotName, d.absPath().data(), sigStr)) + { + // file is already queued + regenerate=TRUE; + } + else if (checkMd5Signature(absBaseName,sigStr) || !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName : usePDFLatex ? absPdfName : absEpsName, graphFormat==GOF_BITMAP && generateImageMap ? absMapName : QCString()) @@ -3897,7 +3932,7 @@ QCString DotCallGraph::writeGraph(FTextStream &out, GraphOutputFormat graphForma bool regenerate = FALSE; QCString sigStr; - if (updateDotGraph(m_startNode, + updateDotGraph(m_startNode, DotNode::CallGraph, absBaseName, graphFormat, @@ -3906,7 +3941,14 @@ QCString DotCallGraph::writeGraph(FTextStream &out, GraphOutputFormat graphForma m_inverse, // backArrows sigStr, m_startNode->label() - ) || + ); + + if (DotManager::instance()->containsRun(absDotName, d.absPath().data(), sigStr)) + { + // file is already queued + regenerate=TRUE; + } + else if (checkMd5Signature(absBaseName,sigStr) || !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName : usePDFLatex ? absPdfName : absEpsName, graphFormat==GOF_BITMAP && generateImageMap ? absMapName : QCString()) @@ -4062,7 +4104,12 @@ QCString DotDirDeps::writeGraph(FTextStream &out, MD5Buffer((const unsigned char *)theGraph.data(),theGraph.length(),md5_sig); MD5SigToString(md5_sig,sigStr.rawData(),33); bool regenerate=FALSE; - if (checkMd5Signature(absBaseName,sigStr) || + if (DotManager::instance()->containsRun(absDotName, d.absPath().data(), sigStr)) + { + // file is already queued + regenerate=TRUE; + } + else if (checkMd5Signature(absBaseName,sigStr) || !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName : usePDFLatex ? absPdfName : absEpsName, graphFormat==GOF_BITMAP && generateImageMap ? absMapName : QCString()) @@ -4210,7 +4257,11 @@ void generateGraphLegend(const char *path) QCString imgFmt = Config_getEnum(DOT_IMAGE_FORMAT); QCString imgName = "graph_legend."+imgExt; QCString absImgName = absBaseName+"."+imgExt; - if (checkMd5Signature(absBaseName,sigStr) || + if (DotManager::instance()->containsRun(absDotName, d.absPath().data(), sigStr)) + { + // file is already queued + } + else if (checkMd5Signature(absBaseName,sigStr) || !checkDeliverables(absImgName)) { QFile dotFile(absDotName); @@ -4623,7 +4674,12 @@ QCString DotGroupCollaboration::writeGraph( FTextStream &t, QCString absPdfName = absBaseName+".pdf"; QCString absEpsName = absBaseName+".eps"; bool regenerate=FALSE; - if (checkMd5Signature(absBaseName,sigStr) || + if (DotManager::instance()->containsRun(absDotName, d.absPath().data(), sigStr)) + { + // file is already queued + regenerate=TRUE; + } + else if (checkMd5Signature(absBaseName,sigStr) || !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName : usePDFLatex ? absPdfName : absEpsName, graphFormat==GOF_BITMAP /*&& generateImageMap*/ ? absMapName : QCString()) diff --git a/src/dot.h b/src/dot.h index 4460ac2..3f6deeb 100644 --- a/src/dot.h +++ b/src/dot.h @@ -400,7 +400,7 @@ class DotRunner }; /** Creates a runner for a dot \a file. */ - DotRunner(const QCString& file, const QCString& path, const QCString& md5Hash, + DotRunner(const QCString& absDotName, const QCString& path, const QCString& md5Hash, bool checkResult, const QCString &imageName = QCString()); /** Adds an additional job to the run. @@ -416,6 +416,10 @@ class DotRunner bool run(); const CleanupItem &cleanup() const { return m_cleanupItem; } + DotConstString const& getFileName() { return m_file; } + DotConstString const& getPath() { return m_path; } + DotConstString const& getMd5Hash() { return m_md5Hash; } + private: DotConstString m_dotExe; bool m_multiTargets; @@ -505,6 +509,8 @@ class DotManager const QCString &figureNAme,const QCString &relPath); bool run(); + bool containsRun(const QCString& absDotName, const QCString& md5Hash); + private: DotManager(); virtual ~DotManager(); -- cgit v0.12