r21359 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Sat May 28 21:43:57 UTC 2016


Author: jghali
Date: Sat May 28 21:43:57 2016
New Revision: 21359

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21359
Log:
#14111: Crash when trying to edit 'Variable Text' Mark

Modified:
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/ui/markvariabletext.cpp
    trunk/Scribus/scribus/ui/markvariabletext.h

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21359&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Sat May 28 21:43:57 2016
@@ -9665,10 +9665,10 @@
 		case MARKVariableTextType:
 			if (currItem == NULL)
 				//invoked from Marks Manager
-				editMDialog = (MarkInsert*) new MarkVariableText(mrk, this);
+				editMDialog = dynamic_cast<MarkInsert*>(new MarkVariableText(mrk, this));
 			else
 				//invoked from mark`s entry in text
-				editMDialog = (MarkInsert*) new MarkVariableText(doc->marksList(), this);
+				editMDialog = dynamic_cast<MarkInsert*>(new MarkVariableText(doc->marksList(), this));
 			editMDialog->setValues(mrk->label, mrk->getString());
 			break;
 		case MARK2ItemType:

Modified: trunk/Scribus/scribus/ui/markvariabletext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21359&path=/trunk/Scribus/scribus/ui/markvariabletext.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/markvariabletext.cpp	(original)
+++ trunk/Scribus/scribus/ui/markvariabletext.cpp	Sat May 28 21:43:57 2016
@@ -2,7 +2,7 @@
 #include "marks.h"
 #include <QComboBox>
 
-MarkVariableText::MarkVariableText(const QList<Mark*>& marks, QWidget *parent) : MarkInsert(marks, parent), m_mark(0)
+MarkVariableText::MarkVariableText(const QList<Mark*>& marks, QWidget *parent) : MarkInsert(marks, parent), m_mark(0), m_widgetType(ComboBox)
 {
 	//for editing mark entry in text - user can change mark pointer inserted into text or create new mark entry
 	setupUi(this);
@@ -22,7 +22,7 @@
 	setWindowTitle(tr("Mark with Variable Text"));
 }
 
-MarkVariableText::MarkVariableText(const Mark* mark, QWidget *parent) : MarkInsert(mark, parent), m_mark(mark)
+MarkVariableText::MarkVariableText(const Mark* mark, QWidget *parent) : MarkInsert(mark, parent), m_mark(mark), m_widgetType(LineEdit)
 {
 	//for editing by marks Manager - user can change label and variable text
 	setupUi(this);
@@ -45,13 +45,14 @@
 {
 	text = textEdit->text();
 	//hack to read if it is QComboBox or QLineEdit
-	if (labelEditWidget->toolTip() != tr("Edit selected Mark's label."))
+	if (m_widgetType == ComboBox)
 	{
-		int labelID = ((QComboBox*) labelEditWidget)->currentIndex();
-		label = ((QComboBox*) labelEditWidget)->currentText();
+		QComboBox* comboBox = (QComboBox*) labelEditWidget;
+		int labelID = comboBox->currentIndex();
+		label = comboBox->currentText();
 		if (label == tr("New Mark"))
 			label = "VariableMark";
-		return (Mark*) ((QComboBox*) labelEditWidget)->itemData(labelID).value<void*>();
+		return (Mark*) (comboBox->itemData(labelID).value<void*>());
 	}
 	label = ((QLineEdit*) labelEditWidget)->text();
 	if (label == tr("New Mark"))
@@ -61,10 +62,13 @@
 
 void MarkVariableText::setValues(QString label, QString text)
 {
-	if (labelEditWidget->toolTip() == tr("Edit selected Mark's label."))
+	if (m_widgetType == LineEdit)
 		((QLineEdit*) labelEditWidget)->setText(label);
 	else
-		((QComboBox*) labelEditWidget)->setCurrentIndex(((QComboBox*) labelEditWidget)->findText(label));
+	{
+		QComboBox* comboBox = (QComboBox*) labelEditWidget;
+		comboBox->setCurrentIndex(comboBox->findText(label));
+	}
 	textEdit->setText(text);
 }
 

Modified: trunk/Scribus/scribus/ui/markvariabletext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21359&path=/trunk/Scribus/scribus/ui/markvariabletext.h
==============================================================================
--- trunk/Scribus/scribus/ui/markvariabletext.h	(original)
+++ trunk/Scribus/scribus/ui/markvariabletext.h	Sat May 28 21:43:57 2016
@@ -23,7 +23,16 @@
 	void onLabelList_currentIndexChanged(int index);
 
 private:
+
+	enum WidgetType
+	{
+		ComboBox = 0,
+		LineEdit = 1
+	};
+
 	QWidget* labelEditWidget;
+	const WidgetType m_widgetType;
+
 	const Mark* m_mark;
 };
 




More information about the scribus-commit mailing list