Skip to content

Commit 1559013

Browse files
committedNov 13, 2018
support platforms that does not have QProcess support (iOS)
1 parent bfdb3ec commit 1559013

File tree

6 files changed

+44
-16
lines changed

6 files changed

+44
-16
lines changed
 

‎python/core/auto_generated/qgsmaprenderertask.sip.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ task. This can be used to draw maps without blocking the QGIS interface.
2626

2727
enum ErrorType
2828
{
29+
//! Image allocation failure
2930
ImageAllocationFail,
30-
ImageSaveFail
31+
//! Image save failure
32+
ImageSaveFail,
33+
34+
ImageUnsupportedFormat
3135
};
3236

3337
QgsMapRendererTask( const QgsMapSettings &ms,

‎python/core/auto_generated/qgsrunprocess.sip.in

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class QgsRunProcess: QObject /NoDefaultCtors/
1717
A class that executes an external program/script.
1818
It can optionally capture the standard output and error from the
1919
process and displays them in a dialog box.
20+
21+
On some platforms (e.g. iOS) , the process execution is skipped
22+
https://lists.qt-project.org/pipermail/development/2015-July/022205.html
2023
%End
2124

2225
%TypeHeaderCode
@@ -26,16 +29,15 @@ process and displays them in a dialog box.
2629

2730
static QgsRunProcess *create( const QString &action, bool capture ) /Factory/;
2831

32+
private:
33+
QgsRunProcess( const QString &action, bool capture );
34+
~QgsRunProcess();
2935
public slots:
3036
void stdoutAvailable();
3137
void stderrAvailable();
3238
void processError( QProcess::ProcessError );
3339
void processExit( int, QProcess::ExitStatus );
3440
void dialogGone();
35-
36-
private:
37-
QgsRunProcess( const QString &action, bool capture );
38-
~QgsRunProcess();
3941
};
4042

4143
/************************************************************************

‎src/core/qgsapplication.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include <QMessageBox>
6262
#include <QPalette>
6363
#include <QProcess>
64+
#include <QProcessEnvironment>
6465
#include <QIcon>
6566
#include <QPixmap>
6667
#include <QThreadPool>
@@ -270,7 +271,9 @@ void QgsApplication::init( QString profileFolder )
270271
// store system environment variables passed to application, before they are adjusted
271272
QMap<QString, QString> systemEnvVarMap;
272273
QString passfile( QStringLiteral( "QGIS_AUTH_PASSWORD_FILE" ) ); // QString, for comparison
273-
Q_FOREACH ( const QString &varStr, QProcess::systemEnvironment() )
274+
275+
const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
276+
for ( const QString &varStr : systemEnvironment )
274277
{
275278
int pos = varStr.indexOf( QLatin1Char( '=' ) );
276279
if ( pos == -1 )
@@ -947,7 +950,7 @@ QString QgsApplication::userLoginName()
947950
sUserName = QString( name );
948951
}
949952

950-
#else
953+
#elseif QT_CONFIG(process)
951954
QProcess process;
952955

953956
process.start( QStringLiteral( "whoami" ) );

‎src/core/qgsrunprocess.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <QTextCodec>
2727
#include <QMessageBox>
2828

29+
#if QT_CONFIG(process)
2930
QgsRunProcess::QgsRunProcess( const QString &action, bool capture )
3031

3132
{
@@ -162,3 +163,13 @@ void QgsRunProcess::processError( QProcess::ProcessError err )
162163
QgsDebugMsg( "Got error: " + QString( "%d" ).arg( err ) );
163164
}
164165
}
166+
#else
167+
QgsRunProcess::QgsRunProcess( const QString &action, bool )
168+
{
169+
QgsDebugMsg( "Skipping command: " + action );
170+
}
171+
172+
QgsRunProcess::~QgsRunProcess()
173+
{
174+
}
175+
#endif

‎src/core/qgsrunprocess.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828
#include "qgis_sip.h"
2929

3030
class QgsMessageOutput;
31-
3231
/**
3332
* \ingroup core
3433
* A class that executes an external program/script.
3534
* It can optionally capture the standard output and error from the
3635
* process and displays them in a dialog box.
36+
*
37+
* On some platforms (e.g. iOS) , the process execution is skipped
38+
* https://lists.qt-project.org/pipermail/development/2015-July/022205.html
3739
*/
3840
class CORE_EXPORT QgsRunProcess: public QObject SIP_NODEFAULTCTORS
3941
{
@@ -50,23 +52,25 @@ class CORE_EXPORT QgsRunProcess: public QObject SIP_NODEFAULTCTORS
5052
static QgsRunProcess *create( const QString &action, bool capture ) SIP_FACTORY
5153
{ return new QgsRunProcess( action, capture ); }
5254

53-
public slots:
54-
void stdoutAvailable();
55-
void stderrAvailable();
56-
void processError( QProcess::ProcessError );
57-
void processExit( int, QProcess::ExitStatus );
58-
void dialogGone();
59-
6055
private:
6156
QgsRunProcess( const QString &action, bool capture ) SIP_FORCE;
6257
~QgsRunProcess() override SIP_FORCE;
6358

59+
#if QT_CONFIG(process)
6460
// Deletes the instance of the class
6561
void die();
6662

6763
QProcess *mProcess = nullptr;
6864
QgsMessageOutput *mOutput = nullptr;
6965
QString mCommand;
66+
67+
public slots:
68+
void stdoutAvailable();
69+
void stderrAvailable();
70+
void processError( QProcess::ProcessError );
71+
void processExit( int, QProcess::ExitStatus );
72+
void dialogGone();
73+
#endif // !(QT_CONFIG(process)
7074
};
7175

7276
#endif

‎src/core/qgsuserprofilemanager.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,21 @@ QgsUserProfile *QgsUserProfileManager::userProfile()
196196

197197
void QgsUserProfileManager::loadUserProfile( const QString &name )
198198
{
199+
#if QT_CONFIG(process)
199200
QString path = QDir::toNativeSeparators( QCoreApplication::applicationFilePath() );
200201
QStringList arguments;
201202
arguments << QCoreApplication::arguments();
202203
// The first is the path to the application
203204
// on Windows this might not be case so we need to handle that
204205
// http://doc.qt.io/qt-5/qcoreapplication.html#arguments
205206
arguments.removeFirst();
206-
207207
arguments << QStringLiteral( "--profile" ) << name;
208208
QgsDebugMsg( QStringLiteral( "Starting instance from %1 with %2" ).arg( path ).arg( arguments.join( " " ) ) );
209209
QProcess::startDetached( path, arguments, QDir::toNativeSeparators( QCoreApplication::applicationDirPath() ) );
210+
#else
211+
Q_UNUSED( name )
212+
Q_ASSERT( "Starting the user profile is not supported on the platform" );
213+
#endif //QT_CONFIG(process)
210214
}
211215

212216
void QgsUserProfileManager::setActiveUserProfile( const QString &profile )

0 commit comments

Comments
 (0)
Please sign in to comment.