Skip to content

Commit 8496494

Browse files
committedNov 21, 2011
Dont use QgsApplication, --prefix, json fix
1 parent 716dc01 commit 8496494

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed
 

‎tests/bench/main.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ void usage( std::string const & appName )
8181
<< "\t[--extent xmin,ymin,xmax,ymax]\tset initial map extent\n"
8282
<< "\t[--optionspath path]\tuse the given QSettings path\n"
8383
<< "\t[--configpath path]\tuse the given path for all user configuration\n"
84+
<< "\t[--prefix path]\tpath to a different build of qgis, may be used to test old versions\n"
8485
<< "\t[--quality]\trenderer hint(s), comma separated, possible values: Antialiasing,TextAntialiasing,SmoothPixmapTransform,NonCosmeticDefaultPen\n"
8586
<< "\t[--help]\t\tthis text\n\n"
8687
<< " FILES:\n"
@@ -132,6 +133,7 @@ int main( int argc, char *argv[] )
132133
int myIterations = 1;
133134
QString mySnapshotFileName = "";
134135
QString myLogFileName = "";
136+
QString myPrefixPath = "";
135137
int mySnapshotWidth = 800;
136138
int mySnapshotHeight = 600;
137139
QString myQuality = "";
@@ -171,14 +173,15 @@ int main( int argc, char *argv[] )
171173
{"extent", required_argument, 0, 'e'},
172174
{"optionspath", required_argument, 0, 'o'},
173175
{"configpath", required_argument, 0, 'c'},
176+
{"prefix", required_argument, 0, 'r'},
174177
{"quality", required_argument, 0, 'q'},
175178
{0, 0, 0, 0}
176179
};
177180

178181
/* getopt_long stores the option index here. */
179182
int option_index = 0;
180183

181-
optionChar = getopt_long( argc, argv, "rswhlpeoc",
184+
optionChar = getopt_long( argc, argv, "islwhpeocrq",
182185
long_options, &option_index );
183186

184187
/* Detect the end of the options. */
@@ -233,6 +236,10 @@ int main( int argc, char *argv[] )
233236
configpath = optarg;
234237
break;
235238

239+
case 'r':
240+
myPrefixPath = optarg;
241+
break;
242+
236243
case 'q':
237244
myQuality = optarg;
238245
break;
@@ -309,7 +316,11 @@ int main( int argc, char *argv[] )
309316
configpath = argv[++i];
310317
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, configpath );
311318
}
312-
else if ( i + 1 < argc && ( arg == "--configpath" || arg == "-c" ) )
319+
else if ( i + 1 < argc && ( arg == "--prefix" ) )
320+
{
321+
myPrefixPath = argv[++i];
322+
}
323+
else if ( i + 1 < argc && ( arg == "--quality" || arg == "-q" ) )
313324
{
314325
myQuality = argv[++i];
315326
}
@@ -338,7 +349,18 @@ int main( int argc, char *argv[] )
338349
// but QgsApplication inherits from QApplication (GUI)
339350
// it is working, but maybe we should make QgsCoreApplication, which
340351
// could also be used by mapserver
341-
QgsApplication myApp( argc, argv, false, configpath );
352+
// Don't use QgsApplication( int, char **, bool GUIenabled, QString) which is new
353+
// so that this program may be run with old libraries
354+
//QgsApplication myApp( argc, argv, false, configpath );
355+
QCoreApplication myApp( argc, argv );
356+
357+
if ( myPrefixPath.isEmpty() )
358+
{
359+
QDir dir( QCoreApplication::applicationDirPath() );
360+
dir.cdUp();
361+
myPrefixPath = dir.absolutePath();
362+
}
363+
QgsApplication::setPrefixPath( myPrefixPath, true );
342364

343365
// Set up the QSettings environment must be done after qapp is created
344366
QgsApplication::setOrganizationName( "QuantumGIS" );

‎tests/bench/qgsbench.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,17 @@ QString QgsBench::serialize( QMap<QString, QVariant> theMap, int level )
211211
switch ( i.value().type() )
212212
{
213213
case QMetaType::Int:
214-
list.append( space2 + i.key() + ": " + QString( "%1" ).arg( i.value().toInt() ) );
214+
list.append( space2 + "\"" + i.key() + "\": " + QString( "%1" ).arg( i.value().toInt() ) );
215215
break;
216216
case QMetaType::Double:
217-
list.append( space2 + i.key() + ": " + QString( "%1" ).arg( i.value().toDouble(), 0, 'f', 3 ) );
217+
list.append( space2 + "\"" + i.key() + "\": " + QString( "%1" ).arg( i.value().toDouble(), 0, 'f', 3 ) );
218218
break;
219219
case QMetaType::QString:
220-
list.append( space2 + i.key() + ": " + i.value().toString() );
220+
list.append( space2 + "\"" + i.key() + "\": \"" + i.value().toString() + "\"" );
221221
break;
222222
//case QMetaType::QMap: QMap is not in QMetaType
223223
default:
224-
list.append( space2 + i.key() + ": " + serialize( i.value().toMap(), level + 1 ) );
224+
list.append( space2 + "\"" + i.key() + "\": " + serialize( i.value().toMap(), level + 1 ) );
225225
break;
226226
}
227227
++i;

‎tests/bench/qgsbench.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,16 @@ class QgsBench : public QObject
6161
void readProject( const QDomDocument &doc );
6262

6363
private:
64-
// Number of rendering cycles
65-
int mIterations;
66-
6764
// snapshot image width
6865
int mWidth;
6966

7067
// snapshot image height
7168
int mHeight;
7269

70+
// Number of rendering cycles
71+
int mIterations;
72+
73+
7374
QgsRectangle mExtent;
7475
bool mSetExtent;
7576

0 commit comments

Comments
 (0)
Please sign in to comment.