Skip to content
Permalink
Browse files
Dont use QgsApplication, --prefix, json fix
  • Loading branch information
blazek committed Nov 21, 2011
1 parent 716dc01 commit 84964942c71458a072428b37a779409884c649b0
Showing with 33 additions and 10 deletions.
  1. +25 −3 tests/bench/main.cpp
  2. +4 −4 tests/bench/qgsbench.cpp
  3. +4 −3 tests/bench/qgsbench.h
@@ -81,6 +81,7 @@ void usage( std::string const & appName )
<< "\t[--extent xmin,ymin,xmax,ymax]\tset initial map extent\n"
<< "\t[--optionspath path]\tuse the given QSettings path\n"
<< "\t[--configpath path]\tuse the given path for all user configuration\n"
<< "\t[--prefix path]\tpath to a different build of qgis, may be used to test old versions\n"
<< "\t[--quality]\trenderer hint(s), comma separated, possible values: Antialiasing,TextAntialiasing,SmoothPixmapTransform,NonCosmeticDefaultPen\n"
<< "\t[--help]\t\tthis text\n\n"
<< " FILES:\n"
@@ -132,6 +133,7 @@ int main( int argc, char *argv[] )
int myIterations = 1;
QString mySnapshotFileName = "";
QString myLogFileName = "";
QString myPrefixPath = "";
int mySnapshotWidth = 800;
int mySnapshotHeight = 600;
QString myQuality = "";
@@ -171,14 +173,15 @@ int main( int argc, char *argv[] )
{"extent", required_argument, 0, 'e'},
{"optionspath", required_argument, 0, 'o'},
{"configpath", required_argument, 0, 'c'},
{"prefix", required_argument, 0, 'r'},
{"quality", required_argument, 0, 'q'},
{0, 0, 0, 0}
};

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

optionChar = getopt_long( argc, argv, "rswhlpeoc",
optionChar = getopt_long( argc, argv, "islwhpeocrq",
long_options, &option_index );

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

case 'r':
myPrefixPath = optarg;
break;

case 'q':
myQuality = optarg;
break;
@@ -309,7 +316,11 @@ int main( int argc, char *argv[] )
configpath = argv[++i];
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, configpath );
}
else if ( i + 1 < argc && ( arg == "--configpath" || arg == "-c" ) )
else if ( i + 1 < argc && ( arg == "--prefix" ) )
{
myPrefixPath = argv[++i];
}
else if ( i + 1 < argc && ( arg == "--quality" || arg == "-q" ) )
{
myQuality = argv[++i];
}
@@ -338,7 +349,18 @@ int main( int argc, char *argv[] )
// but QgsApplication inherits from QApplication (GUI)
// it is working, but maybe we should make QgsCoreApplication, which
// could also be used by mapserver
QgsApplication myApp( argc, argv, false, configpath );
// Don't use QgsApplication( int, char **, bool GUIenabled, QString) which is new
// so that this program may be run with old libraries
//QgsApplication myApp( argc, argv, false, configpath );
QCoreApplication myApp( argc, argv );

if ( myPrefixPath.isEmpty() )
{
QDir dir( QCoreApplication::applicationDirPath() );
dir.cdUp();
myPrefixPath = dir.absolutePath();
}
QgsApplication::setPrefixPath( myPrefixPath, true );

// Set up the QSettings environment must be done after qapp is created
QgsApplication::setOrganizationName( "QuantumGIS" );
@@ -211,17 +211,17 @@ QString QgsBench::serialize( QMap<QString, QVariant> theMap, int level )
switch ( i.value().type() )
{
case QMetaType::Int:
list.append( space2 + i.key() + ": " + QString( "%1" ).arg( i.value().toInt() ) );
list.append( space2 + "\"" + i.key() + "\": " + QString( "%1" ).arg( i.value().toInt() ) );
break;
case QMetaType::Double:
list.append( space2 + i.key() + ": " + QString( "%1" ).arg( i.value().toDouble(), 0, 'f', 3 ) );
list.append( space2 + "\"" + i.key() + "\": " + QString( "%1" ).arg( i.value().toDouble(), 0, 'f', 3 ) );
break;
case QMetaType::QString:
list.append( space2 + i.key() + ": " + i.value().toString() );
list.append( space2 + "\"" + i.key() + "\": \"" + i.value().toString() + "\"" );
break;
//case QMetaType::QMap: QMap is not in QMetaType
default:
list.append( space2 + i.key() + ": " + serialize( i.value().toMap(), level + 1 ) );
list.append( space2 + "\"" + i.key() + "\": " + serialize( i.value().toMap(), level + 1 ) );
break;
}
++i;
@@ -61,15 +61,16 @@ class QgsBench : public QObject
void readProject( const QDomDocument &doc );

private:
// Number of rendering cycles
int mIterations;

// snapshot image width
int mWidth;

// snapshot image height
int mHeight;

// Number of rendering cycles
int mIterations;


QgsRectangle mExtent;
bool mSetExtent;

0 comments on commit 8496494

Please sign in to comment.