grassplugin2.patch

Minoru Akagi, 2012-11-01 06:42 PM

Download (2.56 KB)

View differences:

src/plugins/grass/qgsgrassmodule.cpp
353 353
    return;
354 354
  }
355 355

  
356
  // convert encoding of interface description by myself because
357
  // Qt doesn't recognize most of codepage name "CPxxx" currently
358
  QByteArray enc;
359
  QByteArray ifDesc = process.readAllStandardOutput();
360
  QRegExp reg( "encoding=\"(.+)\"" );
361
  if ( reg.indexIn( ifDesc.split( '\n' )[0] ) != -1 )
362
  {
363
    enc = reg.cap( 1 ).toLocal8Bit();
364
  }
365

  
366
  QTextCodec *codec = QTextCodec::codecForName( enc );
367
  if ( !codec )
368
  {
369
    // treat codepage name that Qt doesn't recognize as System
370
    // default encoding
371
    codec = QTextCodec::codecForName( "System" );
372
    Q_ASSERT( codec );
373
  }
374

  
356 375
  QDomDocument gDoc( "task" );
357 376
  QString err;
358 377
  int line, column;
359
  if ( !gDoc.setContent( &process, false, &err, &line, &column ) )
378
  if ( !gDoc.setContent( codec->toUnicode( ifDesc ), false, &err, &line, &column ) )
360 379
  {
361 380
    QString errmsg = tr( "Cannot read module description (%1):" ).arg( mXName )
362 381
                     + tr( "\n%1\nat line %2 column %3" ).arg( err ).arg( line ).arg( column );
......
1552 1571
  QString line;
1553 1572
  QRegExp rxpercent( "GRASS_INFO_PERCENT: (\\d+)" );
1554 1573

  
1574
  QTextCodec *codec = QTextCodec::codecForName( "System" );
1575
  Q_ASSERT( codec );
1576

  
1555 1577
  mProcess.setReadChannel( QProcess::StandardOutput );
1556 1578
  while ( mProcess.canReadLine() )
1557 1579
  {
1558 1580
    //line = QString::fromLocal8Bit( mProcess.readLineStdout().ascii() );
1559 1581
    QByteArray ba = mProcess.readLine();
1560
    line = QString::fromUtf8( ba ).replace( '\n', "" );
1582
    line = codec->toUnicode( ba ).replace( '\n', "" );
1561 1583
    //QgsDebugMsg(QString("line: '%1'").arg(line));
1562 1584

  
1563 1585
    // GRASS_INFO_PERCENT is catched here only because of bugs in GRASS,
......
1587 1609
  QRegExp rxerror( "GRASS_INFO_ERROR\\(\\d+,\\d+\\): (.*)" );
1588 1610
  QRegExp rxend( "GRASS_INFO_END\\(\\d+,\\d+\\)" );
1589 1611

  
1612
  QTextCodec *codec = QTextCodec::codecForName( "System" );
1613
  Q_ASSERT( codec );
1590 1614

  
1591 1615
  while ( mProcess.canReadLine() )
1592 1616
  {
1593 1617
    //line = QString::fromLocal8Bit( mProcess.readLineStderr().ascii() );
1594 1618
    QByteArray ba = mProcess.readLine();
1595
    line = QString::fromUtf8( ba ).replace( '\n', "" );
1619
    line = codec->toUnicode( ba ).replace( '\n', "" );
1596 1620
    //QgsDebugMsg(QString("line: '%1'").arg(line));
1597 1621

  
1598 1622
    if ( rxpercent.indexIn( line ) != -1 )