r23627 by jghali - Fix potential crash when deleting note frame

scribus-commit scribus-commit at lists.scribus.net
Mon Apr 20 12:14:15 UTC 2020


Author: jghali
Date: Mon Apr 20 12:14:14 2020
New Revision: 23627

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23627
Log:
Fix potential crash when deleting note frame

Modified:
    trunk/Scribus/scribus/pageitem_textframe.cpp

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23627&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Mon Apr 20 12:14:14 2020
@@ -4629,26 +4629,29 @@
 						if (is)
 							is->set("noteframeName", getUName());
 						//remove marks from notes
-						for (int ii = notes2DEL.count() -1; ii >= 0; --ii)
+						for (int ii = notes2DEL.count() - 1; ii >= 0; --ii)
 						{
 							TextNote* note = notes2DEL.at(ii).first;
 							Q_ASSERT(note != nullptr);
-							if (note->textLen > 0)
-							{
-								itemText.deselectAll();
-								itemText.select(notes2DEL.at(ii).second + 1, note->textLen);
-								removeMarksFromText(true);
-							}
+							if (note->textLen <= 0)
+								continue;
+							int oldTextLen = itemText.length();
+							itemText.deselectAll();
+							itemText.select(notes2DEL.at(ii).second + 1, note->textLen);
+							removeMarksFromText(true);
+							marksNum += oldTextLen - itemText.length();
 						}
 						asNoteFrame()->updateNotesText();
 						for (int ii = notes2DEL.count() -1; ii >= 0; --ii)
 						{
 							TextNote* note = notes2DEL.at(ii).first;
 							Q_ASSERT(note != nullptr);
+							int oldTextLen = itemText.length();
 							m_Doc->setUndoDelNote(note);
 							if (note->isEndNote())
 								m_Doc->flag_updateEndNotes = true;
 							m_Doc->deleteNote(note);
+							marksNum += oldTextLen - itemText.length();
 						}
 						if (is)
 						{




More information about the scribus-commit mailing list