Skip to content

Commit a8b9d43

Browse files
author
Hugo Mercier
committedJul 18, 2013
refs #8045 Fix python plugin path encoding issues
1 parent 9d4956a commit a8b9d43

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed
 

‎src/python/qgspythonutilsimpl.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,17 @@ void QgsPythonUtilsImpl::initPython( QgisInterface* interface )
7777
#ifdef Q_OS_WIN
7878
p = p.replace( '\\', "\\\\" );
7979
#endif
80-
pluginpaths << '"' + p + '"';
80+
if ( !QDir( p ).exists() )
81+
{
82+
QgsMessageOutput* msg = QgsMessageOutput::createMessageOutput();
83+
msg->setTitle( QObject::tr( "Python error" ) );
84+
msg->setMessage( QString( QObject::tr("The extra plugin path '%1' does not exist !") ).arg(p), QgsMessageOutput::MessageText );
85+
msg->showMessage();
86+
}
87+
// we store here paths in unicode strings
88+
// the str constant will contain utf8 code (through runString)
89+
// so we call '...'.decode('utf-8') to make a unicode string
90+
pluginpaths << '"' + p + "\".decode('utf-8')";
8191
}
8292
pluginpaths << homePluginsPath();
8393
pluginpaths << '"' + pluginsPath() + '"';
@@ -469,11 +479,11 @@ QString QgsPythonUtilsImpl::homePythonPath()
469479
QString settingsDir = QgsApplication::qgisSettingsDirPath();
470480
if ( QDir::cleanPath( settingsDir ) == QDir::homePath() + QString( "/.qgis%1" ).arg( 2 /* FIXME QGis::QGIS_VERSION_INT / 10000 */ ) )
471481
{
472-
return QString( "os.path.expanduser(\"~/.qgis%1/python\")" ).arg( 2 /* FIXME: QGis::QGIS_VERSION_INT / 10000 */ );
482+
return QString( "os.path.expanduser(\"~/.qgis%1/python\").decode('utf-8')" ).arg( 2 /* FIXME: QGis::QGIS_VERSION_INT / 10000 */ );
473483
}
474484
else
475485
{
476-
return '"' + settingsDir.replace( '\\', "\\\\" ) + "python\"";
486+
return '"' + settingsDir.replace( '\\', "\\\\" ) + "python\".decode('utf-8')";
477487
}
478488
}
479489

0 commit comments

Comments
 (0)
Please sign in to comment.