summaryrefslogtreecommitdiffstats
path: root/src/dot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dot.cpp')
-rw-r--r--src/dot.cpp127
1 files changed, 78 insertions, 49 deletions
diff --git a/src/dot.cpp b/src/dot.cpp
index 8609efa..27e559f 100644
--- a/src/dot.cpp
+++ b/src/dot.cpp
@@ -609,11 +609,14 @@ static void checkDotResult(const QCString &imgName)
{
if (Config_getEnum("DOT_IMAGE_FORMAT")=="png")
{
- QFile f(imgName);
- if (f.open(IO_ReadOnly))
+ //QFile f(imgName);
+ FILE *f = fopen(imgName,"rb");
+ //if (f.open(IO_ReadOnly))
+ if (f)
{
char data[4];
- if (f.readBlock(data,4)==4)
+ if (fread(data,1,4,f)==4)
+ //if (f.readBlock(data,4)==4)
{
if (!(data[1]=='P' && data[2]=='N' && data[3]=='G'))
{
@@ -628,6 +631,7 @@ static void checkDotResult(const QCString &imgName)
{
err("error: Could not read image `%s' generated by dot!\n",imgName.data());
}
+ fclose(f);
}
else
{
@@ -757,8 +761,8 @@ void DotRunner::addPostProcessing(const char *cmd,const char *args)
bool DotRunner::run()
{
int exitCode=0;
- static QCString dotExe = Config_getString("DOT_PATH")+"dot";
- static bool multiTargets = Config_getBool("DOT_MULTI_TARGETS");
+ QCString dotExe = Config_getString("DOT_PATH")+"dot";
+ bool multiTargets = Config_getBool("DOT_MULTI_TARGETS");
QCString dotArgs;
QListIterator<QCString> li(m_jobs);
QCString *s;
@@ -1139,21 +1143,24 @@ DotManager::DotManager() : m_dotMaps(1007)
m_queue = new DotRunnerQueue;
int i;
int numThreads = QMIN(32,Config_getInt("DOT_NUM_THREADS"));
- if (numThreads==0) numThreads = QMAX(1,QThread::idealThreadCount()+1);
- for (i=0;i<numThreads;i++)
+ if (numThreads!=1)
{
- DotWorkerThread *thread = new DotWorkerThread(i,m_queue);
- thread->start();
- if (thread->isRunning())
+ if (numThreads==0) numThreads = QMAX(2,QThread::idealThreadCount()+1);
+ for (i=0;i<numThreads;i++)
{
- m_workers.append(thread);
- }
- else // no more threads available!
- {
- delete thread;
+ DotWorkerThread *thread = new DotWorkerThread(i,m_queue);
+ thread->start();
+ if (thread->isRunning())
+ {
+ m_workers.append(thread);
+ }
+ else // no more threads available!
+ {
+ delete thread;
+ }
}
+ ASSERT(m_workers.count()>0);
}
- ASSERT(m_workers.count()>0);
}
DotManager::~DotManager()
@@ -1222,7 +1229,14 @@ bool DotManager::run()
uint numDotMaps = m_dotMaps.count();
if (numDotRuns+numDotMaps>1)
{
- msg("Generating dot graphs using %d parallel threads...\n",QMIN(numDotRuns+numDotMaps,m_workers.count()));
+ if (m_workers.count()==0)
+ {
+ msg("Generating dot graphs in single threaded mode...\n");
+ }
+ else
+ {
+ msg("Generating dot graphs using %d parallel threads...\n",QMIN(numDotRuns+numDotMaps,m_workers.count()));
+ }
}
int i=1;
QListIterator<DotRunner> li(m_dotRuns);
@@ -1246,41 +1260,53 @@ bool DotManager::run()
portable_sysTimerStart();
// fill work queue with dot operations
DotRunner *dr;
- for (li.toFirst();(dr=li.current());++li)
- {
- m_queue->enqueue(dr);
- }
int prev=1;
- // wait for the queue to become empty
- while ((i=m_queue->count())>0)
+ if (m_workers.count()==0) // no threads to work with
{
- i = numDotRuns - i;
- while (i>=prev)
+ for (li.toFirst();(dr=li.current());++li)
{
msg("Running dot for graph %d/%d\n",prev,numDotRuns);
+ dr->run();
prev++;
}
- portable_sleep(100);
}
- while ((int)numDotRuns>=prev)
+ else // use multiple threads to run instances of dot in parallel
{
- msg("Running dot for graph %d/%d\n",prev,numDotRuns);
- prev++;
- }
- // signal the workers we are done
- for (i=0;i<(int)m_workers.count();i++)
- {
- m_queue->enqueue(0); // add terminator for each worker
- }
- // wait for the workers to finish
- for (i=0;i<(int)m_workers.count();i++)
- {
- m_workers.at(i)->wait();
- }
- // clean up dot files from main thread
- for (i=0;i<(int)m_workers.count();i++)
- {
- m_workers.at(i)->cleanup();
+ for (li.toFirst();(dr=li.current());++li)
+ {
+ m_queue->enqueue(dr);
+ }
+ // wait for the queue to become empty
+ while ((i=m_queue->count())>0)
+ {
+ i = numDotRuns - i;
+ while (i>=prev)
+ {
+ msg("Running dot for graph %d/%d\n",prev,numDotRuns);
+ prev++;
+ }
+ portable_sleep(100);
+ }
+ while ((int)numDotRuns>=prev)
+ {
+ msg("Running dot for graph %d/%d\n",prev,numDotRuns);
+ prev++;
+ }
+ // signal the workers we are done
+ for (i=0;i<(int)m_workers.count();i++)
+ {
+ m_queue->enqueue(0); // add terminator for each worker
+ }
+ // wait for the workers to finish
+ for (i=0;i<(int)m_workers.count();i++)
+ {
+ m_workers.at(i)->wait();
+ }
+ // clean up dot files from main thread
+ for (i=0;i<(int)m_workers.count();i++)
+ {
+ m_workers.at(i)->cleanup();
+ }
}
portable_sysTimerStop();
if (setPath)
@@ -1572,7 +1598,7 @@ void DotNode::writeBox(FTextStream &t,
writeBoxMemberList(t,'-',m_classDef->getMemberList(MemberList::priStaticMethods),m_classDef,TRUE);
writeBoxMemberList(t,'-',m_classDef->getMemberList(MemberList::priSlots),m_classDef);
}
- if (m_classDef->getLanguage()!=SrcLangExt_F90 &&
+ if (m_classDef->getLanguage()!=SrcLangExt_Fortran &&
m_classDef->getMemberGroupSDict())
{
MemberGroupSDict::Iterator mgdi(*m_classDef->getMemberGroupSDict());
@@ -3301,7 +3327,7 @@ void DotCallGraph::buildGraph(DotNode *n,MemberDef *md,int distance)
QCString tooltip = rmd->briefDescriptionAsTooltip();
bn = new DotNode(
m_curNodeNumber++,
- linkToText(name,FALSE),
+ linkToText(rmd->getLanguage(),name,FALSE),
tooltip,
uniqueId,
0 //distance
@@ -3388,7 +3414,7 @@ DotCallGraph::DotCallGraph(MemberDef *md,bool inverse)
name = md->qualifiedName();
}
m_startNode = new DotNode(m_curNodeNumber++,
- linkToText(name,FALSE),
+ linkToText(md->getLanguage(),name,FALSE),
"",
uniqueId.data(),
TRUE // root node
@@ -3837,8 +3863,11 @@ void writeDotImageMapFromFile(FTextStream &t,
if (imgExt=="svg") // vector graphics
{
- writeSVGFigureLink(t,relPath,inFile,inFile+".svg");
- DotFilePatcher patcher(inFile+".svg");
+ //writeSVGFigureLink(t,relPath,inFile,inFile+".svg");
+ //DotFilePatcher patcher(inFile+".svg");
+ QCString svgName=outDir+"/"+baseName+".svg";
+ writeSVGFigureLink(t,relPath,baseName,svgName);
+ DotFilePatcher patcher(svgName);
patcher.addSVGConversion(relPath,TRUE,context,TRUE,graphId);
patcher.run();
}