r17235 by craig - Apply changes used for #10082 in relation to declared vars, fix a couple of memory leaks where dialogs were not deleted

scribus-commit scribus-commit at lists.scribus.net
Wed Jan 25 21:11:35 UTC 2012


Author: craig
Date: Wed Jan 25 21:11:35 2012
New Revision: 17235

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17235
Log:
Apply changes used for #10082 in relation to declared vars, fix a couple of memory leaks where dialogs were not deleted

Modified:
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/ui/javadocs.cpp
    trunk/Scribus/scribus/ui/scrapbookpalette.cpp
    trunk/Scribus/scribus/ui/shadebutton.cpp

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17235&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Wed Jan 25 21:11:35 2012
@@ -6940,17 +6940,15 @@
 	else
 	{
 		bool ok = false;
-		Query* dia = new Query(this, "New", 1, 0, tr("&Size:"), tr("Size"));
-		if (dia->exec())
-		{
-			c = qRound(dia->getEditText().toDouble(&ok));
+		Query dia(this, "New", 1, 0, tr("&Size:"), tr("Size"));
+		if (dia.exec())
+		{
+			c = qRound(dia.getEditText().toDouble(&ok));
 			if ((ok) && (c < 1025) && (c > 0))
 				doc->itemSelection_SetFontSize(c*10);
 		}
-		delete dia;
 	}
 	propertiesPalette->textPal->displayFontSize(c*10);
-// 	slotDocCh();
 }
 
 //CB-->Doc partly
@@ -6970,10 +6968,10 @@
 		}
 		else
 		{
-			Query* dia = new Query(this, "New", 1, 0, tr("&Shade:"), tr("Shade"));
-			if (dia->exec())
-			{
-				c = dia->getEditText().toInt(&ok);
+			Query dia(this, "New", 1, 0, tr("&Shade:"), tr("Shade"));
+			if (dia.exec())
+			{
+				c = dia.getEditText().toInt(&ok);
 				if (ok)
 				{
 					if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::PathText))
@@ -6982,10 +6980,8 @@
 						doc->itemSelection_SetItemBrushShade(c);
 				}
 			}
-			delete dia;
-		}
-	}
-// 	slotDocCh();
+		}
+	}
 }
 
 #if 0

Modified: trunk/Scribus/scribus/ui/javadocs.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17235&path=/trunk/Scribus/scribus/ui/javadocs.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/javadocs.cpp (original)
+++ trunk/Scribus/scribus/ui/javadocs.cpp Wed Jan 25 21:11:35 2012
@@ -76,12 +76,12 @@
 void JavaDocs::slotAdd()
 {
 	QString nam;
-	Query *dia = new Query(this, "tt", 1, 0, tr("&New Script:"), tr("New Script"));
-	dia->setEditText( tr("New Script"), false );
-	dia->setTestList(Doc->JavaScripts.keys());
+	Query dia(this, "tt", 1, 0, tr("&New Script:"), tr("New Script"));
+	dia.setEditText( tr("New Script"), false );
+	dia.setTestList(Doc->JavaScripts.keys());
 	if (dia->exec())
 	{
-		nam = dia->getEditText();
+		nam = dia.getEditText();
 		nam.replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" );
 		Editor* dia2 = new Editor(this, "", View);
 		dia2->EditTex->setText("function "+nam+"()\n{\n}");
@@ -95,7 +95,6 @@
 		}
 		delete dia2;
 	}
-	delete dia;
 }
 
 void JavaDocs::slotEdit()

Modified: trunk/Scribus/scribus/ui/scrapbookpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17235&path=/trunk/Scribus/scribus/ui/scrapbookpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scrapbookpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/scrapbookpalette.cpp Wed Jan 25 21:11:35 2012
@@ -1076,18 +1076,13 @@
 	BibView* bv = (BibView*)Frame3->widget(id);
 	if (bv->objectMap.contains(nam))
 	{
-		Query *dia = new Query(this, "tt", 1, 0, tr("&Name:"), tr("New Entry"));
-		dia->setEditText(nam, true);
-		dia->setTestList(activeBView->objectMap.keys());
-		if (dia->exec())
-		{
-			nam = dia->getEditText();
-		}
+		Query dia(this, "tt", 1, 0, tr("&Name:"), tr("New Entry"));
+		dia.setEditText(nam, true);
+		dia.setTestList(activeBView->objectMap.keys());
+		if (dia.exec())
+			nam = dia.getEditText();
 		else
-		{
-			delete dia;
 			return false;
-		}
 	}
 	QPixmap pm;
 	QByteArray cf;
@@ -1269,19 +1264,13 @@
 	QPixmap ObjPreview;
 	QListWidgetItem *ite = actItem;
 	QString OldName = ite->text();
-	Query *dia = new Query(this, "tt", 1, 0, tr("&Name:"), tr("New Name"));
-	dia->setEditText(ite->text(), true);
-	dia->setTestList(activeBView->objectMap.keys());
-	if (dia->exec())
-	{
-		nam = dia->getEditText();
-	}
+	Query dia(this, "tt", 1, 0, tr("&Name:"), tr("New Name"));
+	dia.setEditText(ite->text(), true);
+	dia.setTestList(activeBView->objectMap.keys());
+	if (dia.exec())
+		nam = dia.getEditText();
 	else
-	{
-		delete dia;
 		return;
-	}
-	delete dia;
 	ite->setText(nam);
 	ObjData = activeBView->objectMap[OldName].Data;
 	ObjPreview = activeBView->objectMap[OldName].Preview;
@@ -1404,16 +1393,13 @@
 				nam += "("+ tmp.setNum(tempCount) + ")";
 		}
 		qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-		Query *dia = new Query(this, "tt", 1, 0, tr("&Name:"), tr("New Entry"));
-		dia->setEditText(nam, true);
-		dia->setTestList(activeBView->objectMap.keys());
-		if (dia->exec())
-			nam = dia->getEditText();
+		Query dia(this, "tt", 1, 0, tr("&Name:"), tr("New Entry"));
+		dia.setEditText(nam, true);
+		dia.setTestList(activeBView->objectMap.keys());
+		if (dia.exec())
+			nam = dia.getEditText();
 		else
-		{
-			delete dia;
 			return;
-		}
 		QImage img;
 		if (testResult == 9999)
 		{
@@ -1534,19 +1520,13 @@
 			nam += "("+ tmp.setNum(tempCount) + ")";
 	}
 	qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-	Query *dia = new Query(this, "tt", 1, 0, tr("&Name:"), tr("New Entry"));
-	dia->setEditText(nam, true);
-	dia->setTestList(activeBView->objectMap.keys());
-	if (dia->exec())
-	{
-		nam = dia->getEditText();
-	}
+	Query dia(this, "tt", 1, 0, tr("&Name:"), tr("New Entry"));
+	dia.setEditText(nam, true);
+	dia.setTestList(activeBView->objectMap.keys());
+	if (dia.exec())
+		nam = dia.getEditText();
 	else
-	{
-		delete dia;
 		return;
-	}
-	delete dia;
 	QString ff = text;
 	activeBView->checkAndChange(ff, QDir::cleanPath(QDir::toNativeSeparators(activeBView->ScFilename + "/" + nam + ".sce")), QDir::cleanPath(QDir::toNativeSeparators(activeBView->ScFilename)));
 	ScPreview *pre = new ScPreview();
@@ -1701,19 +1681,13 @@
 	if (actBView->objectMap.contains(nam))
 		nam += "("+ tmp.setNum(tempCount) + ")";
 	qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-	Query *dia = new Query(this, "tt", 1, 0, tr("&Name:"), tr("New Entry"));
-	dia->setEditText(nam, true);
-	dia->setTestList(actBView->objectMap.keys());
-	if (dia->exec())
-	{
-		nam = dia->getEditText();
-	}
+	Query dia(this, "tt", 1, 0, tr("&Name:"), tr("New Entry"));
+	dia.setEditText(nam, true);
+	dia.setTestList(activeBView->objectMap.keys());
+	if (dia.exec())
+		nam = dia.getEditText();
 	else
-	{
-		delete dia;
 		return;
-	}
-	delete dia;
 	QString ff = text;
 	actBView->checkAndChange(ff, QDir::cleanPath(QDir::toNativeSeparators(actBView->ScFilename + "/" + nam + ".sce")), QDir::cleanPath(QDir::toNativeSeparators(actBView->ScFilename)));
 	ScPreview *pre = new ScPreview();

Modified: trunk/Scribus/scribus/ui/shadebutton.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17235&path=/trunk/Scribus/scribus/ui/shadebutton.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/shadebutton.cpp (original)
+++ trunk/Scribus/scribus/ui/shadebutton.cpp Wed Jan 25 21:11:35 2012
@@ -46,21 +46,17 @@
 	
 	if (c == 0)
 	{
-		Query* dia = new Query(this, "New", 1, 0, tr("&Shade:"), tr("Shade"));
+		Query dia(this, "New", 1, 0, tr("&Shade:"), tr("Shade"));
 		if (dia->exec())
     	{
-			c = dia->getEditText().toInt(&ok);
+			c = dia.getEditText().toInt(&ok);
 			if (ok)
 				b = qMax(qMin(c, 100),0);
 			else
 				b = 100;
-			delete dia;
 		}
 		else
-		{
-			delete dia;
 			return;
-		}
 	}
 	setText(QString::number(b)+" %");
 	emit clicked();




More information about the scribus-commit mailing list