]> granicus.if.org Git - graphviz/commitdiff
If current directory is not writable at the start, put output in user's home directory;
authorEmden R. Gansner <erg@research.att.com>
Thu, 1 Aug 2013 21:30:25 +0000 (17:30 -0400)
committerEmden R. Gansner <erg@research.att.com>
Thu, 1 Aug 2013 21:30:25 +0000 (17:30 -0400)
null out graph pointer when graph is closed.

cmd/gvedit/csettings.cpp
cmd/gvedit/ui_settings.h

index af9347a91a4eca6dd77a971a05e2ea5bc2a1d8fe..c0ef5465624ba88d2276b83fe59632f29065ebdd 100644 (file)
@@ -23,6 +23,8 @@
 #include "mainwindow.h"
 #include <QTemporaryFile>
 
+extern int errorPipe(char *errMsg);
+
 #define WIDGET(t,f)  ((t*)findChild<t *>(#f))
 typedef struct {
     const char *data;
@@ -315,8 +317,10 @@ void CFrmSettings::saveSlot()
 
 bool CFrmSettings::loadGraph(MdiChild * m)
 {
-    if (graph)
+    if (graph) {
        agclose(graph);
+       graph = NULL;
+    }
     graphData.clear();
     graphData.append(m->toPlainText());
     setActiveWindow(m);
@@ -339,7 +343,7 @@ bool CFrmSettings::createLayout()
     /* Reset line number and file name;
      * If known, might want to use real name
      */
-    agsetfile("<gvedit>");
+    agsetfile((char*)"<gvedit>");
     QByteArray bytes = graphData.toUtf8();
     rdr.data = bytes.constData();
     rdr.len = strlen(rdr.data);
@@ -363,7 +367,7 @@ bool CFrmSettings::createLayout()
     Agraph_t *G = this->graph;
     QString layout;
 
-    if(agfindnodeattr(G, "pos"))
+    if(agfindnodeattr(G, (char*)"pos"))
        layout="nop2";
     else
        layout=WIDGET(QComboBox, cbLayout)->currentText();
@@ -421,6 +425,26 @@ bool CFrmSettings::renderLayout()
        if (fileName != activeWindow->outputFile)
            activeWindow->outputFile = fileName;
 
+#ifdef WIN32
+       if ((!fileName.contains('/')) && (!fileName.contains('\\'))) 
+#else
+       if (!fileName.contains('/'))
+#endif
+       {  // no directory info => can we create/write the file?
+           QFile outf(fileName);
+           if (outf.open(QIODevice::WriteOnly))
+               outf.close();
+           else {
+               QString pathName = QDir::homePath();
+               pathName.append("/").append(fileName);
+               fileName = QDir::toNativeSeparators (pathName);
+               QString msg ("Output written to ");
+               msg.append(fileName);
+               msg.append("\n");
+               errorPipe((char *) msg.toAscii().constData());
+           }
+       }
+
        if (gvRenderFilename
            (gvc, graph, (char *) sfx.toUtf8().constData(),
             (char *) fileName.toUtf8().constData()))
index 0ffb4a0e5cd2f797bf346613acafb528f68064d5..f3c68c8e196ae0c2e45b5f055c83925269f0bed0 100644 (file)
@@ -360,7 +360,7 @@ public:
          << QApplication::translate("Dialog", "sfdp", 0, QApplication::UnicodeUTF8)
          << QApplication::translate("Dialog", "twopi", 0, QApplication::UnicodeUTF8)
         );
-        label_3->setText(QApplication::translate("Dialog", "Output file Type", 0, QApplication::UnicodeUTF8));
+        label_3->setText(QApplication::translate("Dialog", "Output File Type", 0, QApplication::UnicodeUTF8));
         cbExtension->clear();
         cbExtension->insertItems(0, QStringList()
          << QApplication::translate("Dialog", "png", 0, QApplication::UnicodeUTF8)