Stephan Witt wrote:

> $ lyx-build/cmake/2.2.0dev/bin/Debug/tex2lyx
> tex2lyx: Not enough arguments.
> Usage: tex2lyx [options] infile.tex [outfile.lyx]
> …
> -sysdir SYSDIR     Set system directory to SYSDIR.
> Default: /Users/stephan/git/lyx/lib/
> -userdir USERDIR   Set user directory to USERDIR.
> Default: /Users/stephan/Library/Application Support/LyX/tex2lyx/LyX/

I do understand now what happens. The path is built like this on OS X:

$HOME/Library/Application Support/$org/$app/$package/

where $org is the organization name (always "LyX", set by 
QCoreApplication::setOrganizationName(), and $app is either "LyX", "tex2lyx" 
or "client" (set by QCoreApplication::setApplicationName()). If the build 
was configured with a version suffix then this suffix is added to all three 
names. The path excluding $package is returned by qt, $package is added by 
ourselves. $package is the same string for all three applications, and by 
construction equal to $app in case of LyX (see 
LyXConsoleApp::LyXConsoleApp() or GuiApplication::GuiApplication())

Therefore, if we want to comply to the OS X rules for constructing the user 
data directory path, and at the same time to use the same directory for LyX, 
tex2lyx and client, we simply have to pop off the last component of the path 
returned by qt before adding package. This is what the attached patch does.

Stephan, does it work? Note that this is not a regression (2.1 has the same 
code), so it is not really urgent. If we apply it, we need to be aware that 
the user directory would change for LyX compared to earlier releases.


Georg
diff --git a/src/support/Package.cpp b/src/support/Package.cpp
index de06c19..cc20b09 100644
--- a/src/support/Package.cpp
+++ b/src/support/Package.cpp
@@ -689,13 +689,19 @@ FileName const get_default_user_support_dir(FileName const & home_dir)
 	os::GetFolderPath win32_folder_path;
 	return FileName(addPath(win32_folder_path(os::GetFolderPath::APPDATA), PACKAGE));
 
-#elif defined (USE_MACOSX_PACKAGING) && (QT_VERSION >= 0x050000)
-	(void)home_dir; // Silence warning about unused variable.
-	return FileName(addPath(fromqstr(QStandardPaths::writableLocation(QStandardPaths::DataLocation)), PACKAGE));
-
 #elif defined (USE_MACOSX_PACKAGING)
 	(void)home_dir; // Silence warning about unused variable.
-	return FileName(addPath(fromqstr(QDesktopServices::storageLocation(QDesktopServices::DataLocation)), PACKAGE));
+#if QT_VERSION >= 0x050000
+	string const appPath = fromqstr(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+#else
+	string const appPath = fromqstr(QDesktopServices::writableLocation(QDesktopServices::DataLocation));
+#endif
+	// appPath is "$HOME/Library/Application Support/$org/$app", where
+	// $org is "LyX" (set by QCoreApplication::setOrganizationName())
+	// and $app is equal to PACKAGE for LyX, and "tex2lyx" PROGRAM_SUFFIX for tex2lyx etc.
+	// Since we need to share the same user directory for LyX, tex2lyx and client,
+	// we need to strip the last path component and add PACKAGE.
+	return FileName(addPath(onlyPath(appPath), PACKAGE));
 
 #elif defined (USE_HAIKU_PACKAGING)
 	return FileName(addPath(home_dir.absFileName(), string("/config/settings/") + PACKAGE));

Reply via email to