Suggestions for improvement
Ticket 1410 | Suggestion for improvement | Software version | 2011-07-25 1:19 am
Answers: 1
Use some kind of prefix comment
Solved
2011-07-25 1:19 am
You are extensively using QCoreApplication::applicationDirPath(), which requires source code modifications for platforms, where binaries and data files are put on different places. A better way is to use some kind of prefix.
A quick and dirty fix I used is:
for i in `grep -R 'QCoreApplication::applicationDirPath()' * | awk '{print $1}' | sed -e 's/:$//'`; do sed -i '' -e 's/QCoreApplication::applicationDirPath()/QString(DATADIR)/g' $i ; done
with setting the DATADIR environment variable to something like /usr/local/share/tipp10. Here is a patch for tipp10.pro
--- tipp10.pro 2011-03-12 20:22:32.000000000 +0100
+++ tipp10.pro 2011-07-24 14:24:03.000000000 +0200
@@ -88,3 +88,5 @@
sql/startsql.cpp \
games/abcrainwidget.cpp \
games/charball.cpp
+
+DEFINES += "DATADIR=\"\\\"$$(DATADIR)\\\"\""
As I have said, this is a quick and dirty way that allows "proper" installing the program data in a different directory, where the binary will look for it.
A quick and dirty fix I used is:
for i in `grep -R 'QCoreApplication::applicationDirPath()' * | awk '{print $1}' | sed -e 's/:$//'`; do sed -i '' -e 's/QCoreApplication::applicationDirPath()/QString(DATADIR)/g' $i ; done
with setting the DATADIR environment variable to something like /usr/local/share/tipp10. Here is a patch for tipp10.pro
--- tipp10.pro 2011-03-12 20:22:32.000000000 +0100
+++ tipp10.pro 2011-07-24 14:24:03.000000000 +0200
@@ -88,3 +88,5 @@
sql/startsql.cpp \
games/abcrainwidget.cpp \
games/charball.cpp
+
+DEFINES += "DATADIR=\"\\\"$$(DATADIR)\\\"\""
As I have said, this is a quick and dirty way that allows "proper" installing the program data in a different directory, where the binary will look for it.
2011-07-25 1:19 am
I use QCoreApplication::applicationDirPath() to read and copy the database template to the users home directory at the first start of Tipp10. And I call it whenever I need the user settings (registry) in the portable Windows version. To manage the user data I don't use applicationDirPath(), because then I use the access to the user directory.
What exactly do you mean with "data file"? OS like Windows, OS X or Ubuntu separate program data and user data. Tipp10 does this, too. Which OS do you have? FreeBSD? Why is there a need to separate files that are in the program directory?
If there is a need, you are right, a define variable with the path to the program directory would be nice for systems who separate binary and data file from the program directory. On the other hand, the program directory can change in one OS, for example it is different between Windows 98 and Windows 7. If I would use a "prefix" I had to compile different versions of Tipp10 for different versions of one OS!
What exactly do you mean with "data file"? OS like Windows, OS X or Ubuntu separate program data and user data. Tipp10 does this, too. Which OS do you have? FreeBSD? Why is there a need to separate files that are in the program directory?
If there is a need, you are right, a define variable with the path to the program directory would be nice for systems who separate binary and data file from the program directory. On the other hand, the program directory can change in one OS, for example it is different between Windows 98 and Windows 7. If I would use a "prefix" I had to compile different versions of Tipp10 for different versions of one OS!
Link zu diesem Ticket: https://www.tipp10.com/en/support/improvements/0/1410/