@@ -817,24 +817,36 @@ bool QgsWmsProvider::downloadCapabilitiesURI(QString const & uri)
817
817
818
818
}
819
819
*/
820
-
820
+ # include < fstream >
821
821
bool QgsWmsProvider::parseCapabilitiesDOM (QByteArray const & xml, QgsWmsCapabilitiesProperty& capabilitiesProperty)
822
822
{
823
- #ifdef QGISDEBUG
823
+ // #ifdef QGISDEBUG
824
824
std::cout << " QgsWmsProvider::parseCapabilitiesDOM: entering." << std::endl;
825
825
826
- // test the content of the QByteArray
827
- QString responsestring (xml);
828
- qWarning (" QgsWmsProvider::parseCapabilitiesDOM, received the following data: " +responsestring);
829
-
826
+ // test the content of the QByteArray.
827
+ // There is a bug in Qt4.1.2, due for fixing in 4.2.0, where
828
+ // QString(QByteArray) uses strlen to find the length of the
829
+ // QByteArray. However, there are no guarantees that the QByteArray
830
+ // has a terminating \0, and hence this can cause a crash, so we supply
831
+ // the qbytearray to qstring in a way that ensures that there is a
832
+ // terminating \0, and just to be safe, we also give it the actual
833
+ // size.
834
+
835
+ // Also, the Qt qWarning() function has a limit of 8192 bytes per
836
+ // message, which can easily be exceeded by wms capability
837
+ // documents, so we use the qgs logger stuff instead which doesn't
838
+ // have that limitation.
839
+
840
+ QString responsestring (QString::fromAscii (xml.constData (), xml.size ()));
841
+ QgsLogger::debug (" QgsWmsProvider::parseCapabilitiesDOM, received the following data: " +responsestring);
830
842
831
843
// QFile file( "/tmp/qgis-wmsprovider-capabilities.xml" );
832
844
// if ( file.open( QIODevice::WriteOnly ) )
833
845
// {
834
846
// file.writeBlock(xml);
835
847
// file.close();
836
848
// }
837
- #endif
849
+ // #endif
838
850
839
851
// Convert completed document into a DOM
840
852
QString errorMsg;
@@ -852,9 +864,7 @@ bool QgsWmsProvider::parseCapabilitiesDOM(QByteArray const & xml, QgsWmsCapabili
852
864
853
865
mError += " \n " + tr (" This is probably due to an incorrect WMS Server URL." );
854
866
855
- #ifdef QGISDEBUG
856
- qWarning (" DOM Exception: " +mError );
857
- #endif
867
+ QgsLogger::debug (" DOM Exception: " +mError );
858
868
859
869
return FALSE ;
860
870
}
@@ -884,9 +894,7 @@ bool QgsWmsProvider::parseCapabilitiesDOM(QByteArray const & xml, QgsWmsCapabili
884
894
885
895
mError += " \n " + tr (" This is probably due to an incorrect WMS Server URL." );
886
896
887
- #ifdef QGISDEBUG
888
- qWarning (" DOM Exception: " +mError );
889
- #endif
897
+ QgsLogger::debug (" DOM Exception: " +mError );
890
898
891
899
return FALSE ;
892
900
}
@@ -1676,7 +1684,7 @@ bool QgsWmsProvider::parseServiceExceptionReportDOM(QByteArray const & xml)
1676
1684
1677
1685
// test the content of the QByteArray
1678
1686
QString responsestring (xml);
1679
- qWarning (" QgsWmsProvider::parseServiceExceptionReportDOM, received the following data: " +responsestring);
1687
+ QgsLogger::debug (" QgsWmsProvider::parseServiceExceptionReportDOM, received the following data: " +responsestring);
1680
1688
#endif
1681
1689
1682
1690
// Convert completed document into a DOM
@@ -1694,9 +1702,7 @@ bool QgsWmsProvider::parseServiceExceptionReportDOM(QByteArray const & xml)
1694
1702
.arg (errorLine)
1695
1703
.arg (errorColumn) );
1696
1704
1697
- #ifdef QGISDEBUG
1698
- qWarning (" DOM Exception: " +mError );
1699
- #endif
1705
+ QgsLogger::debug (" DOM Exception: " +mError );
1700
1706
1701
1707
return FALSE ;
1702
1708
}
0 commit comments