diff options
author | David Athay <ko2fan@gmail.com> | 2009-04-13 16:03:38 +0100 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2009-04-13 16:03:38 +0100 |
commit | ceff9177ea052c9e398fc9f337cf5320deba14ed (patch) | |
tree | 563e740f4ad9ddd9fe89d4385c7700efcb7a5320 /src/gui/widgets/browserbox.cpp | |
parent | effc112bed400d632368ca633d8a6600ea8c8aae (diff) | |
download | mana-ceff9177ea052c9e398fc9f337cf5320deba14ed.tar.gz mana-ceff9177ea052c9e398fc9f337cf5320deba14ed.tar.bz2 mana-ceff9177ea052c9e398fc9f337cf5320deba14ed.tar.xz mana-ceff9177ea052c9e398fc9f337cf5320deba14ed.zip |
Fixed broken links
Diffstat (limited to 'src/gui/widgets/browserbox.cpp')
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 6b1cb434..603f2056 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -70,7 +70,7 @@ void BrowserBox::addRow(const std::string &row) std::string tmp = row; std::string newRow; BROWSER_LINK bLink; - int idx1, idx2, idx3; + std::string::size_type idx1, idx2, idx3; TrueTypeFont *font = static_cast<TrueTypeFont*>(getFont()); // Use links and user defined colors @@ -78,10 +78,13 @@ void BrowserBox::addRow(const std::string &row) { // Check for links in format "@@link|Caption@@" idx1 = tmp.find("@@"); - while (idx1 >= 0) + while (idx1 != std::string::npos) { idx2 = tmp.find("|", idx1); idx3 = tmp.find("@@", idx2); + + if (idx2 == std::string::npos || idx3 == std::string::npos) + break; bLink.link = tmp.substr(idx1 + 2, idx2 - (idx1 + 2)); bLink.caption = tmp.substr(idx2 + 1, idx3 - (idx2 + 1)); bLink.y1 = mTextRows.size() * font->getHeight(); @@ -91,7 +94,7 @@ void BrowserBox::addRow(const std::string &row) std::string tmp2 = newRow; idx1 = tmp2.find("##"); - while (idx1 >= 0) + while (idx1 != std::string::npos) { tmp2.erase(idx1, 3); idx1 = tmp2.find("##"); @@ -143,7 +146,7 @@ void BrowserBox::addRow(const std::string &row) if (mMode == AUTO_SIZE) { std::string plain = newRow; - for (idx1 = plain.find("##"); idx1 >= 0; idx1 = plain.find("##")) + for (idx1 = plain.find("##"); idx1 != std::string::npos; idx1 = plain.find("##")) plain.erase(idx1, 3); // Adjust the BrowserBox size |