Skip to content

Commit 86517c8

Browse files
committed
Modernize code
1 parent 28341f9 commit 86517c8

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/python/qgspythonutilsimpl.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void QgsPythonUtilsImpl::initPython( QgisInterface *interface, const bool instal
216216
if ( interface )
217217
{
218218
// initialize 'iface' object
219-
runString( "qgis.utils.initInterface(" + QString::number( ( quint64 ) interface ) + ')' );
219+
runString( QStringLiteral( "qgis.utils.initInterface(%1)" ).arg( reinterpret_cast< quint64 >( interface ) ) );
220220
}
221221

222222
if ( !checkQgisUser() )
@@ -250,7 +250,7 @@ void QgsPythonUtilsImpl::initServerPython( QgsServerInterface *interface )
250250
}
251251

252252
// This is the other main difference with initInterface() for desktop plugins
253-
runString( "qgis.utils.initServerInterface(" + QString::number( ( quint64 ) interface ) + ')' );
253+
runString( QStringLiteral( "qgis.utils.initServerInterface(%1)" ).arg( reinterpret_cast< quint64 >( interface ) ) );
254254

255255
doCustomImports();
256256
finish();
@@ -371,37 +371,37 @@ QString QgsPythonUtilsImpl::getTraceback()
371371

372372
modStringIO = PyImport_ImportModule( iomod );
373373
if ( !modStringIO )
374-
TRACEBACK_FETCH_ERROR( QString( "can't import %1" ).arg( iomod ) );
374+
TRACEBACK_FETCH_ERROR( QStringLiteral( "can't import %1" ).arg( iomod ) );
375375

376-
obStringIO = PyObject_CallMethod( modStringIO, ( char * ) "StringIO", nullptr );
376+
obStringIO = PyObject_CallMethod( modStringIO, reinterpret_cast< const char * >( "StringIO" ), nullptr );
377377

378378
/* Construct a cStringIO object */
379379
if ( !obStringIO )
380-
TRACEBACK_FETCH_ERROR( "cStringIO.StringIO() failed" );
380+
TRACEBACK_FETCH_ERROR( QStringLiteral( "cStringIO.StringIO() failed" ) );
381381

382382
modTB = PyImport_ImportModule( "traceback" );
383383
if ( !modTB )
384-
TRACEBACK_FETCH_ERROR( "can't import traceback" );
384+
TRACEBACK_FETCH_ERROR( QStringLiteral( "can't import traceback" ) );
385385

386-
obResult = PyObject_CallMethod( modTB, ( char * ) "print_exception",
387-
( char * ) "OOOOO",
386+
obResult = PyObject_CallMethod( modTB, reinterpret_cast< const char * >( "print_exception" ),
387+
reinterpret_cast< const char * >( "OOOOO" ),
388388
type, value ? value : Py_None,
389389
traceback ? traceback : Py_None,
390390
Py_None,
391391
obStringIO );
392392

393393
if ( !obResult )
394-
TRACEBACK_FETCH_ERROR( "traceback.print_exception() failed" );
394+
TRACEBACK_FETCH_ERROR( QStringLiteral( "traceback.print_exception() failed" ) );
395395

396396
Py_DECREF( obResult );
397397

398-
obResult = PyObject_CallMethod( obStringIO, ( char * ) "getvalue", nullptr );
398+
obResult = PyObject_CallMethod( obStringIO, reinterpret_cast< const char * >( "getvalue" ), nullptr );
399399
if ( !obResult )
400-
TRACEBACK_FETCH_ERROR( "getvalue() failed." );
400+
TRACEBACK_FETCH_ERROR( QStringLiteral( "getvalue() failed." ) );
401401

402402
/* And it should be a string all ready to go - duplicate it. */
403403
if ( !PyUnicode_Check( obResult ) )
404-
TRACEBACK_FETCH_ERROR( "getvalue() did not return a string" );
404+
TRACEBACK_FETCH_ERROR( QStringLiteral( "getvalue() did not return a string" ) );
405405

406406
result = QString::fromUtf8( PyUnicode_AsUTF8( obResult ) );
407407

0 commit comments

Comments
 (0)