]> granicus.if.org Git - graphviz/commitdiff
Partial fix for bug 2477; fix windows build to use the newest attribute list
authorEmden R. Gansner <erg@alum.mit.edu>
Wed, 6 Aug 2014 20:21:07 +0000 (16:21 -0400)
committerEmden R. Gansner <erg@alum.mit.edu>
Wed, 6 Aug 2014 20:21:07 +0000 (16:21 -0400)
cmd/gvedit/csettings.cpp
windows/build.bat

index 5d4314c914dd07a212715266980c9345427b0fc0..a27a7a2f9b0bc31ecb93fd342ce89ca15502a813 100644 (file)
@@ -32,6 +32,38 @@ typedef struct {
     int cur;
 } rdr_t;
 
+#ifdef WIN32
+#define BSZ 1024
+
+QString findAttrFile ()
+{
+    char line[BSZ];
+    int r;
+    char* s;
+    QString path;
+    MEMORY_BASIC_INFORMATION mbi;
+
+    if (VirtualQuery (&findAttrFile, &mbi, sizeof(mbi)) == 0) {
+       errout << "failed to get handle for executable.\n";
+       return path;
+    }
+    r = GetModuleFileNameA((HMODULE)mbi.AllocationBase, line, BSZ);
+    if (!r || (r == BSZ)) {
+       errout << "failed to get path for executable.\n";
+       return path;
+    }
+    s = strstr(line,"\\bin\\");
+    if (!s) {
+       errout << "no \"\\bin\" in path " << line << "\n";
+       return path;
+    }
+    *s = '\0';
+    path.append(line);
+    path.append("\\share\\graphviz\\gvedit\\attributes.txt");
+    return path;
+}
+#endif
 bool loadAttrs(const QString fileName, QComboBox * cbNameG,
               QComboBox * cbNameN, QComboBox * cbNameE)
 {
@@ -63,6 +95,7 @@ bool loadAttrs(const QString fileName, QComboBox * cbNameG,
     } else {
        errout << "Could not open attribute name file \"" << fileName <<
            "\" for reading\n" << flush;
+       return true;
     }
 
     return false;
@@ -120,9 +153,15 @@ CFrmSettings::CFrmSettings()
     loadAttrs(path + "/attrs.txt", WIDGET(QComboBox, cbNameG),
              WIDGET(QComboBox, cbNameN), WIDGET(QComboBox, cbNameE));
 #else
-    loadAttrs("../share/graphviz/gvedit/attributes.txt",
+    if (loadAttrs("../share/graphviz/gvedit/attributes.txt",
+             WIDGET(QComboBox, cbNameG), WIDGET(QComboBox, cbNameN),
+             WIDGET(QComboBox, cbNameE))) {
+       path = findAttrFile();
+       if (!path.isEmpty())
+           loadAttrs(path,
              WIDGET(QComboBox, cbNameG), WIDGET(QComboBox, cbNameN),
              WIDGET(QComboBox, cbNameE));
+    }
 #endif
     setWindowIcon(QIcon(":/images/icon.png"));
 }
index eeeaba174888f2e69fb2651ee6e56a6883665400..6233dbe4fbc156683341ad308ea5517970ab7381 100755 (executable)
@@ -109,9 +109,10 @@ copy /Y %outputDir%*.lib  %targetDir%lib\release\lib
 copy /Y %outputDir%*.dll  %targetDir%lib\release\dll\r
 REM *****************************************************\r
 \r
-REM Copy smyrna shared files\r
+REM Copy smyrna and gvedit shared files\r
 xcopy /Y %buildDir%share\gui %targetDir%share\graphviz\smyrna\ /S\r
 xcopy /Y %buildDir%share\examples %targetDir%share\graphviz\examples\ /S\r
+copy /Y %buildDir%doc\infosrc\attrs  %targetDir%share\graphviz\gvedit\attributes.txt\r
 REM *****************************************************\r
 \r
 REM *****************************************************\r