Skip to content

Commit 8de53bd

Browse files
author
g_j_m
committedAug 24, 2006

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎src/gui/qgsmaplayer.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,13 @@ QgsMapLayer::QgsMapLayer(int type,
7373
// Generate the unique ID of this layer
7474
QDateTime dt = QDateTime::currentDateTime();
7575
ID = lyrname + dt.toString("yyyyMMddhhmmsszzz");
76-
ID.replace(" ", "_");
76+
// Tidy the ID up to avoid characters that may cause problems
77+
// elsewhere (e.g in some parts of XML). Replaces every non-word
78+
// character (word characters are the alphabet, numbers and
79+
// underscore) with an underscore.
80+
// Note that the first backslashe in the regular expression is
81+
// there for the compiler, so the pattern is actually \W
82+
ID.replace(QRegExp("[\\W]"), "_");
7783

7884
QString myThemePath = QgsApplication::themePath();
7985
mInOverviewPixmap.load(myThemePath + "/mActionInOverview.png");

0 commit comments

Comments
 (0)
Please sign in to comment.