summaryrefslogtreecommitdiffstats
path: root/src/dot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dot.cpp')
-rw-r--r--src/dot.cpp57
1 files changed, 50 insertions, 7 deletions
diff --git a/src/dot.cpp b/src/dot.cpp
index 3c8360d..77faf6e 100644
--- a/src/dot.cpp
+++ b/src/dot.cpp
@@ -178,6 +178,39 @@ static bool isLeaf(ClassDef *cd)
return TRUE;
}
+// since dot silently reproduces the input file when it does not
+// support the PNG format, we need to check the result.
+static void checkDotResult(const QCString &imgName)
+{
+ if (Config_getEnum("DOT_IMAGE_FORMAT")=="png")
+ {
+ QFile f(imgName);
+ if (f.open(IO_ReadOnly))
+ {
+ char data[4];
+ if (f.readBlock(data,4)==4)
+ {
+ if (!(data[1]=='P' && data[2]=='N' && data[3]=='G'))
+ {
+ err("Error! Image `%s' produced by dot is not a valid PNG!\n"
+ "You should either select a different format "
+ "(DOT_IMAGE_FORMAT in the config file) or install a more "
+ "recent version of graphviz (1.7+)\n",imgName.data()
+ );
+ }
+ }
+ else
+ {
+ err("Error: Could not read image `%s' generated by dot!\n",imgName.data());
+ }
+ }
+ else
+ {
+ err("Error: Could not open image `%s' generated by dot!\n",imgName.data());
+ }
+ }
+}
+
//--------------------------------------------------------------------
class DotNodeList : public QList<DotNode>
@@ -719,6 +752,7 @@ void DotGfxHierarchyTable::writeGraph(QTextStream &out,const char *path)
out << "</table>" << endl;
return;
}
+ checkDotResult(imgName);
dotArgs.sprintf("-Timap \"%s\" -o \"%s\"",dotName.data(),mapName.data());
//printf("Running: dot -Timap %s -o %s\n",dotName.data(),mapName.data());
if (iSystem(Config_getString("DOT_PATH")+"dot",dotArgs)!=0)
@@ -1300,14 +1334,16 @@ QCString DotClassGraph::writeGraph(QTextStream &out,
{
QCString dotArgs(4096);
QCString imgExt = Config_getEnum("DOT_IMAGE_FORMAT");
- dotArgs.sprintf("-T%s \"%s.dot\" -o \"%s.%s\"",
- imgExt.data(),baseName.data(),baseName.data(),imgExt.data());
+ QCString imgName = baseName+"."+imgExt;
+ dotArgs.sprintf("-T%s \"%s.dot\" -o \"%s\"",
+ imgExt.data(),baseName.data(),imgName.data());
if (iSystem(Config_getString("DOT_PATH")+"dot",dotArgs)!=0)
{
err("Error: Problems running dot. Check your installation!\n");
QDir::setCurrent(oldDir);
return baseName;
}
+ checkDotResult(imgName);
if (generateImageMap)
{
// run dot again to create an image map
@@ -1529,14 +1565,16 @@ QCString DotInclDepGraph::writeGraph(QTextStream &out,
// run dot to create a bitmap image
QCString dotArgs(4096);
QCString imgExt = Config_getEnum("DOT_IMAGE_FORMAT");
- dotArgs.sprintf("-T%s \"%s.dot\" -o \"%s.%s\"",
- imgExt.data(),baseName.data(),baseName.data(),imgExt.data());
+ QCString imgName=baseName+"."+imgExt;
+ dotArgs.sprintf("-T%s \"%s.dot\" -o \"%s\"",
+ imgExt.data(),baseName.data(),imgName.data());
if (iSystem(Config_getString("DOT_PATH")+"dot",dotArgs)!=0)
{
err("Problems running dot. Check your installation!\n");
QDir::setCurrent(oldDir);
return baseName;
}
+ checkDotResult(imgName);
if (generateImageMap)
{
@@ -1674,13 +1712,15 @@ void generateGraphLegend(const char *path)
// run dot to generate the a bitmap image from the graph
QCString dotArgs(4096);
QCString imgExt = Config_getEnum("DOT_IMAGE_FORMAT");
- dotArgs.sprintf("-T%s graph_legend.dot -o graph_legend.%s",imgExt.data(),imgExt.data());
+ QCString imgName = "graph_legend."+imgExt;
+ dotArgs.sprintf("-T%s graph_legend.dot -o %s",imgExt.data(),imgName.data());
if (iSystem(Config_getString("DOT_PATH")+"dot",dotArgs)!=0)
{
err("Problems running dot. Check your installation!\n");
QDir::setCurrent(oldDir);
return;
}
+ checkDotResult(imgName);
QDir::setCurrent(oldDir);
}
@@ -1690,10 +1730,11 @@ void writeDotGraphFromFile(const char *inFile,const char *outFile,
{
QCString dotArgs(4096);
QCString imgExt = Config_getEnum("DOT_IMAGE_FORMAT");
+ QCString imgName = (QCString)outFile+"."+imgExt;
if (format==BITMAP)
{
- dotArgs.sprintf("-T%s \"%s\" -o \"%s.%s\"",imgExt.data(),
- inFile,outFile,imgExt.data());
+ dotArgs.sprintf("-T%s \"%s\" -o \"%s\"",imgExt.data(),
+ inFile,imgName.data());
}
else // format==EPS
{
@@ -1705,4 +1746,6 @@ void writeDotGraphFromFile(const char *inFile,const char *outFile,
{
err("Problems running dot. Check your installation!\n");
}
+ if (format==BITMAP) checkDotResult(imgName);
}
+