@@ -659,10 +659,9 @@ static bool writeSVGFigureLink(FTextStream &out,const QCString &relPath,
659
659
660
660
// since dot silently reproduces the input file when it does not
661
661
// support the PNG format, we need to check the result.
662
- static void checkDotResult (const QCString & imgName)
662
+ static void checkDotResult (const char *imgExt, const char * imgName)
663
663
{
664
- QCString imgExt = getDotImageExtension ();
665
- if (imgExt==" png" )
664
+ if (qstrcmp (imgExt," png" )==0 )
666
665
{
667
666
FILE *f = portable_fopen (imgName," rb" );
668
667
if (f)
@@ -675,19 +674,19 @@ static void checkDotResult(const QCString &imgName)
675
674
err (" Image `%s' produced by dot is not a valid PNG!\n "
676
675
" You should either select a different format "
677
676
" (DOT_IMAGE_FORMAT in the config file) or install a more "
678
- " recent version of graphviz (1.7+)\n " ,imgName. data ()
677
+ " recent version of graphviz (1.7+)\n " ,imgName
679
678
);
680
679
}
681
680
}
682
681
else
683
682
{
684
- err (" Could not read image `%s' generated by dot!\n " ,imgName. data () );
683
+ err (" Could not read image `%s' generated by dot!\n " ,imgName);
685
684
}
686
685
fclose (f);
687
686
}
688
687
else
689
688
{
690
- err (" Could not open image `%s' generated by dot!\n " ,imgName. data () );
689
+ err (" Could not open image `%s' generated by dot!\n " ,imgName);
691
690
}
692
691
}
693
692
}
@@ -793,54 +792,46 @@ int DotNodeList::compareValues(const DotNode *n1,const DotNode *n2) const
793
792
794
793
DotRunner::DotRunner (const QCString &file,const QCString &path,
795
794
bool checkResult,const QCString &imageName)
796
- : m_file(file), m_path(path),
797
- m_checkResult(checkResult), m_imageName(imageName)
798
- {
799
- static bool dotCleanUp = Config_getBool (" DOT_CLEANUP" );
800
- m_cleanUp = dotCleanUp;
795
+ : m_dotExe(Config_getString(" DOT_PATH" )+"dot"),
796
+ m_file(file), m_path(path),
797
+ m_checkResult(checkResult), m_imageName(imageName),
798
+ m_imgExt(getDotImageExtension())
799
+ {
800
+ static bool dotCleanUp = Config_getBool (" DOT_CLEANUP" );
801
+ static bool dotMultiTargets = Config_getBool (" DOT_MULTI_TARGETS" );
802
+ m_cleanUp = dotCleanUp;
803
+ m_multiTargets = dotMultiTargets;
801
804
m_jobs.setAutoDelete (TRUE );
802
805
}
803
806
804
807
void DotRunner::addJob (const char *format,const char *output)
805
808
{
806
809
QCString args = QCString (" -T" )+format+" -o \" " +output+" \" " ;
807
- m_jobs.append (new QCString (args));
810
+ m_jobs.append (new DotConstString (args));
808
811
}
809
812
810
813
void DotRunner::addPostProcessing (const char *cmd,const char *args)
811
814
{
812
- m_postCmd = cmd;
813
- m_postArgs = args;
815
+ m_postCmd. set ( cmd) ;
816
+ m_postArgs. set ( args) ;
814
817
}
815
818
816
819
bool DotRunner::run ()
817
820
{
818
821
int exitCode=0 ;
819
- // we need to use data here to make a copy of the string, as Config_getString can be called by
820
- // multiple threads simulaneously and the reference counting is not thread safe.
821
- QCString dotExe = Config_getString (" DOT_PATH" ).data ();
822
- dotExe+=" dot" ;
823
822
824
- bool multiTargets = Config_getBool (" DOT_MULTI_TARGETS" );
825
823
QCString dotArgs;
826
- QListIterator<QCString> li (m_jobs);
827
- QCString *s;
828
- QCString file = m_file;
829
- QCString path = m_path;
830
- QCString imageName = m_imageName;
831
- QCString postCmd = m_postCmd;
832
- QCString postArgs = m_postArgs;
833
- bool checkResult = m_checkResult;
834
- bool cleanUp = m_cleanUp;
835
- if (multiTargets)
836
- {
837
- dotArgs=" \" " +file+" \" " ;
824
+ QListIterator<DotConstString> li (m_jobs);
825
+ DotConstString *s;
826
+ if (m_multiTargets)
827
+ {
828
+ dotArgs=QCString (" \" " )+m_file.data ()+" \" " ;
838
829
for (li.toFirst ();(s=li.current ());++li)
839
830
{
840
831
dotArgs+=' ' ;
841
- dotArgs+=*s ;
832
+ dotArgs+=s-> data () ;
842
833
}
843
- if ((exitCode=portable_system (dotExe ,dotArgs,FALSE ))!=0 )
834
+ if ((exitCode=portable_system (m_dotExe. data () ,dotArgs,FALSE ))!=0 )
844
835
{
845
836
goto error;
846
837
}
@@ -849,30 +840,33 @@ bool DotRunner::run()
849
840
{
850
841
for (li.toFirst ();(s=li.current ());++li)
851
842
{
852
- dotArgs=" \" " +file +" \" " +*s ;
853
- if ((exitCode=portable_system (dotExe ,dotArgs,FALSE ))!=0 )
843
+ dotArgs=QCString ( " \" " )+m_file. data () +" \" " +s-> data () ;
844
+ if ((exitCode=portable_system (m_dotExe. data () ,dotArgs,FALSE ))!=0 )
854
845
{
855
846
goto error;
856
847
}
857
848
}
858
849
}
859
- if (!postCmd .isEmpty () && portable_system (postCmd,postArgs )!=0 )
850
+ if (!m_postCmd .isEmpty () && portable_system (m_postCmd. data (),m_postArgs. data () )!=0 )
860
851
{
861
852
err (" Problems running '%s' as a post-processing step for dot output\n " ,m_postCmd.data ());
862
853
return FALSE ;
863
854
}
864
- if (checkResult) checkDotResult (imageName);
865
- if (cleanUp)
855
+ if (m_checkResult)
856
+ {
857
+ checkDotResult (m_imgExt.data (),m_imageName.data ());
858
+ }
859
+ if (m_cleanUp)
866
860
{
867
861
// printf("removing dot file %s\n",m_file.data());
868
862
// QDir(path).remove(file);
869
- m_cleanupItem.file = file ;
870
- m_cleanupItem.path = path ;
863
+ m_cleanupItem.file . set (m_file. data ()) ;
864
+ m_cleanupItem.path . set (m_path. data ()) ;
871
865
}
872
866
return TRUE ;
873
867
error:
874
868
err (" Problems running dot: exit code=%d, command='%s', arguments='%s'\n " ,
875
- exitCode,dotExe .data (),dotArgs.data ());
869
+ exitCode,m_dotExe .data (),dotArgs.data ());
876
870
return FALSE ;
877
871
}
878
872
@@ -1202,7 +1196,7 @@ void DotWorkerThread::run()
1202
1196
while ((runner=m_queue->dequeue ()))
1203
1197
{
1204
1198
runner->run ();
1205
- DotRunner::CleanupItem cleanup = runner->cleanup ();
1199
+ const DotRunner::CleanupItem & cleanup = runner->cleanup ();
1206
1200
if (!cleanup.file .isEmpty ())
1207
1201
{
1208
1202
m_cleanupItems.append (new DotRunner::CleanupItem (cleanup));
@@ -1216,7 +1210,7 @@ void DotWorkerThread::cleanup()
1216
1210
DotRunner::CleanupItem *ci;
1217
1211
for (;(ci=it.current ());++it)
1218
1212
{
1219
- QDir (ci->path ) .remove (ci->file );
1213
+ QDir (ci->path . data ()) .remove (ci->file . data () );
1220
1214
}
1221
1215
}
1222
1216
@@ -4237,7 +4231,7 @@ void writeDotGraphFromFile(const char *inFile,const char *outDir,
4237
4231
return ;
4238
4232
}
4239
4233
4240
- if (format==GOF_BITMAP) checkDotResult (absImgName);
4234
+ if (format==GOF_BITMAP) checkDotResult (getDotImageExtension (), absImgName);
4241
4235
4242
4236
Doxygen::indexList->addImageFile (imgName);
4243
4237
0 commit comments