[gnote] * Don't crash when deleting a note (Closes #579839)
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnote] * Don't crash when deleting a note (Closes #579839)
- Date: Thu, 30 Apr 2009 03:46:05 -0400 (EDT)
commit 076c798c8b35d5ba99e3cdae1366a678fb6dd10b
Author: Hubert Figuiere <hub figuiere net>
Date: Thu Apr 30 01:20:59 2009 -0400
* Don't crash when deleting a note (Closes #579839)
---
NEWS | 8 ++++++++
src/note.cpp | 23 ++++++++++++++++++-----
src/sharp/string.cpp | 6 ++++++
3 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index cbdab2a..b578511 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,14 @@
+0.3.1 -
+
Fixes:
* Missing header in src/addins/inserttimestamp/inserttimestampnoteaddin.cpp
+ * Don't crash when deleting a note (Closes #579839)
+
+Translations:
+
+ * Updated translations:
+ - Arabic (ar)
0.3.0 - 2009/04/29
diff --git a/src/note.cpp b/src/note.cpp
index 6a9b736..061111a 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -667,17 +667,30 @@ namespace gnote {
void Note::remove_tag(Tag & tag)
{
+ std::string tag_name = tag.normalized_name();
NoteData::TagMap & thetags(m_data.data().tags());
- NoteData::TagMap::iterator iter = thetags.find(tag.normalized_name());
- if (iter == thetags.end())
- return;
+ NoteData::TagMap::iterator iter;
+
+ // if we are deleting the note, no need to check for the tag, we
+ // know it is there.
+ if(!m_is_deleting) {
+ iter = thetags.find(tag_name);
+ if (iter == thetags.end()) {
+ return;
+ }
+ }
m_signal_tag_removing(*this, tag);
- thetags.erase(iter);
+ // don't erase the tag if we are deleting the note.
+ // This will invalidate the iterator.
+ // see bug 579839.
+ if(!m_is_deleting) {
+ thetags.erase(iter);
+ }
tag.remove_note(*this);
- m_signal_tag_removed(shared_from_this(), tag.normalized_name());
+ m_signal_tag_removed(shared_from_this(), tag_name);
DBG_OUT("Tag removed, queueing save");
queue_save(OTHER_DATA_CHANGED);
diff --git a/src/sharp/string.cpp b/src/sharp/string.cpp
index 5ff45ad..784d9cc 100644
--- a/src/sharp/string.cpp
+++ b/src/sharp/string.cpp
@@ -104,11 +104,17 @@ namespace sharp {
bool string_starts_with(const std::string & source, const std::string & with)
{
+ if(source.empty()) {
+ return false;
+ }
return boost::starts_with(source, with);
}
bool string_ends_with(const std::string & source, const std::string & with)
{
+ if(source.empty()) {
+ return false;
+ }
return boost::ends_with(source, with);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]