@@ -77,43 +77,38 @@ QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled, QStri
77
77
{
78
78
init ( customConfigPath ); // init can also be called directly by e.g. unit tests that don't inherit QApplication.
79
79
}
80
+
80
81
void QgsApplication::init ( QString customConfigPath )
81
82
{
82
83
if ( customConfigPath.isEmpty () )
83
84
{
84
85
customConfigPath = QDir::homePath () + QString ( " /.qgis/" );
85
86
}
87
+
86
88
qRegisterMetaType<QgsGeometry::Error>( " QgsGeometry::Error" );
87
89
88
90
QString prefixPath ( getenv ( " QGIS_PREFIX_PATH" ) ? getenv ( " QGIS_PREFIX_PATH" ) : applicationDirPath () );
89
91
90
92
// check if QGIS is run from build directory (not the install directory)
91
- QDir appDir ( prefixPath );
92
- #ifndef _MSC_VER
93
- #define SOURCE_PATH " source_path.txt"
94
- #else
95
- #define SOURCE_PATH " ../source_path.txt"
96
- #endif
97
- if ( appDir.exists ( SOURCE_PATH ) )
93
+ QFile f;
94
+ foreach ( QString path, QStringList () << " " << " /.." << " /bin" )
98
95
{
99
- QFile f ( prefixPath + " /" + SOURCE_PATH );
100
- if ( f.open ( QIODevice::ReadOnly ) )
101
- {
102
- ABISYM ( mRunningFromBuildDir ) = true ;
103
- ABISYM ( mBuildSourcePath ) = f.readAll ();
104
- #if _MSC_VER
105
- QStringList elems = prefixPath.split ( " /" , QString::SkipEmptyParts );
106
- ABISYM ( mCfgIntDir ) = elems.last ();
107
- ABISYM ( mBuildOutputPath ) = prefixPath + " /../.." ;
108
- #elif defined(Q_WS_MACX)
109
- ABISYM ( mBuildOutputPath ) = prefixPath;
110
- #else
111
- ABISYM ( mBuildOutputPath ) = prefixPath + " /.." ; // on linux
96
+ f.setFileName ( prefixPath + path + " /path.txt" );
97
+ if ( f.exists () )
98
+ break ;
99
+ }
100
+ if ( f.exists () && f.open ( QIODevice::ReadOnly ) )
101
+ {
102
+ ABISYM ( mRunningFromBuildDir ) = true ;
103
+ ABISYM ( mBuildSourcePath ) = f.readLine ().trimmed ();
104
+ ABISYM ( mBuildOutputPath ) = f.readLine ().trimmed ();
105
+ qDebug ( " Running from build directory!" );
106
+ qDebug ( " - source directory: %s" , ABISYM ( mBuildSourcePath ).toUtf8 ().data () );
107
+ qDebug ( " - output directory of the build: %s" , ABISYM ( mBuildOutputPath ).toUtf8 ().data () );
108
+ #ifdef _MSC_VER
109
+ ABISYM ( mCfgIntDir ) = prefixPath.split ( " /" , QString::SkipEmptyParts ).last ();
110
+ qDebug ( " - cfg: %s" , ABISYM ( mCfgIntDir ).toUtf8 ().data () );
112
111
#endif
113
- qDebug ( " Running from build directory!" );
114
- qDebug ( " - source directory: %s" , ABISYM ( mBuildSourcePath ).toAscii ().data () );
115
- qDebug ( " - output directory of the build: %s" , ABISYM ( mBuildOutputPath ).toAscii ().data () );
116
- }
117
112
}
118
113
119
114
if ( ABISYM ( mRunningFromBuildDir ) )
0 commit comments