From: Emden R. Gansner Date: Wed, 6 Aug 2014 20:21:07 +0000 (-0400) Subject: Partial fix for bug 2477; fix windows build to use the newest attribute list X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~180 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93793553bbbbcb0935aa4fcab92a212c7cf377e0;p=graphviz Partial fix for bug 2477; fix windows build to use the newest attribute list --- diff --git a/cmd/gvedit/csettings.cpp b/cmd/gvedit/csettings.cpp index 5d4314c91..a27a7a2f9 100644 --- a/cmd/gvedit/csettings.cpp +++ b/cmd/gvedit/csettings.cpp @@ -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")); } diff --git a/windows/build.bat b/windows/build.bat index eeeaba174..6233dbe4f 100755 --- a/windows/build.bat +++ b/windows/build.bat @@ -109,9 +109,10 @@ copy /Y %outputDir%*.lib %targetDir%lib\release\lib copy /Y %outputDir%*.dll %targetDir%lib\release\dll REM ***************************************************** -REM Copy smyrna shared files +REM Copy smyrna and gvedit shared files xcopy /Y %buildDir%share\gui %targetDir%share\graphviz\smyrna\ /S xcopy /Y %buildDir%share\examples %targetDir%share\graphviz\examples\ /S +copy /Y %buildDir%doc\infosrc\attrs %targetDir%share\graphviz\gvedit\attributes.txt REM ***************************************************** REM *****************************************************