[gnote] * Fix wrongly highlighted URLs and a crash when inserting in some situation.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnote] * Fix wrongly highlighted URLs and a crash when inserting in some situation.
- Date: Sat, 18 Apr 2009 00:36:35 -0400 (EDT)
commit 2ad6f26c242c7385ba06c9f944b38b2d4bd08c33
Author: Hubert Figuiere <hub figuiere net>
Date: Fri Apr 17 20:41:28 2009 -0400
* Fix wrongly highlighted URLs and a crash when inserting in some situation.
(Close #579225)
---
NEWS | 2 ++
src/notebuffer.cpp | 4 ++--
src/watchers.cpp | 18 ++++++++----------
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/NEWS b/NEWS
index 6293226..a269f57 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ Fixes:
dialog is open. (Close #579105)
* Check for Gtk+ 2.14 or later and include gtk/gtk.h in src/utils.cpp
(Close #579240)
+ * Fix wrongly highlighted URLs and a crash when inserting in some situation.
+ (Close #579225)
Translations:
diff --git a/src/notebuffer.cpp b/src/notebuffer.cpp
index e6a2a0d..4e249a5 100644
--- a/src/notebuffer.cpp
+++ b/src/notebuffer.cpp
@@ -326,13 +326,13 @@ namespace gnote {
// to have multiple lines in a single bullet point
if (prev_depth && soft_break) {
bool at_end_of_line = insert_iter.ends_line();
- insert(insert_iter, Glib::ustring(4, (gunichar)0x2028));
+ insert_iter = insert(insert_iter, Glib::ustring(4, (gunichar)0x2028));
// Hack so that the user sees that what they type
// next will appear on a new line, otherwise the
// cursor stays at the end of the previous line.
if (at_end_of_line) {
- insert(insert_iter, " ");
+ insert_iter = insert(insert_iter, " ");
Gtk::TextIter bound = insert_iter;
bound.backward_char();
move_mark(get_selection_bound(), bound);
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 76bd04a..5cbf0f2 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -527,20 +527,18 @@ namespace gnote {
while(m1 != m2) {
const boost::sub_match<std::string::const_iterator> & match = (*m1)[1];
- /*
- Logger.Log ("Highlighting url: '{0}' at offset {1}",
- group,
- group.Index);
- */
-
Gtk::TextIter start_cpy = start;
- start_cpy.forward_chars (match.first - s.begin());
+ // must construct the Glib::ustring from a std:;string.
+ // otherwise it expect the num of chars (UTF-8) instead of bytes.
+ Glib::ustring segment(std::string(s.c_str(), match.first - s.begin()));
+ start_cpy.forward_chars (segment.size());
end = start_cpy;
- end.forward_chars (match.length());
+ // here match.str() is the std::string we need. All good.
+ Glib::ustring segment2(match.str());
+ end.forward_chars (segment2.length());
- std::string debug = start_cpy.get_slice(end);
- DBG_OUT("url is %s", debug.c_str());
+ DBG_OUT("url is %s", segment2.c_str());
get_buffer()->apply_tag (m_url_tag, start_cpy, end);
++m1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]