r19484 by jghali - #12670: Edit/Delete crashes Scribus using JavaScripts
scribus-commit
scribus-commit at lists.scribus.net
Sat Sep 6 12:06:33 UTC 2014
Author: jghali
Date: Sat Sep 6 12:06:32 2014
New Revision: 19484
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19484
Log:
#12670: Edit/Delete crashes Scribus using JavaScripts
Modified:
branches/Version14x/Scribus/scribus/javadocs.cpp
branches/Version14x/Scribus/scribus/javadocs.h
Modified: branches/Version14x/Scribus/scribus/javadocs.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19484&path=/branches/Version14x/Scribus/scribus/javadocs.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/javadocs.cpp (original)
+++ branches/Version14x/Scribus/scribus/javadocs.cpp Sat Sep 6 12:06:32 2014
@@ -70,6 +70,7 @@
connect(DeleteScript, SIGNAL(clicked()), this, SLOT(slotDelete()));
connect(ExitDia, SIGNAL(clicked()), this, SLOT(accept()));
connect(Scripts, SIGNAL(itemActivated (QListWidgetItem *)), this, SLOT(slotEdit()));
+ connect(Scripts, SIGNAL(itemSelectionChanged()), this, SLOT(slotSelectionChanged()));
AddScript->setToolTip( "<qt>" + tr( "Adds a new Script, predefines a function with the same name. If you want to use this script as an \"Open Action\" script be sure not to change the name of the function." ) + "</qt>" );
}
@@ -87,10 +88,9 @@
dia2->EditTex->setText("function "+nam+"()\n{\n}");
if (dia2->exec())
{
- EditScript->setEnabled(true);
- DeleteScript->setEnabled(true);
Doc->JavaScripts[nam] = dia2->EditTex->toPlainText();
Scripts->addItem(nam);
+ Scripts->setCurrentRow(Scripts->count() - 1);
emit docChanged(false);
}
delete dia2;
@@ -99,11 +99,14 @@
void JavaDocs::slotEdit()
{
- QString nam = Scripts->currentItem()->text();
- Editor* dia2 = new Editor(this, Doc->JavaScripts[nam], View);
+ QListWidgetItem* currentItem = Scripts->currentItem();
+ if (!currentItem)
+ return;
+ QString name = currentItem->text();
+ Editor* dia2 = new Editor(this, Doc->JavaScripts[name], View);
if (dia2->exec())
{
- Doc->JavaScripts[nam] = dia2->EditTex->toPlainText();
+ Doc->JavaScripts[name] = dia2->EditTex->toPlainText();
emit docChanged(false);
}
delete dia2;
@@ -111,14 +114,18 @@
void JavaDocs::slotDelete()
{
+ QListWidgetItem* currentItem = Scripts->currentItem();
+ if (!currentItem)
+ return;
+
int exit = QMessageBox::warning(this,
CommonStrings::trWarning,
tr("Do you really want to delete this script?"),
QMessageBox::Yes | QMessageBox::No);
if (exit == QMessageBox::Yes)
{
- QString nam = Scripts->currentItem()->text();
- Doc->JavaScripts.remove(nam);
+ QString name = currentItem->text();
+ Doc->JavaScripts.remove(name);
Scripts->clear();
QMap<QString,QString>::Iterator it;
for (it = Doc->JavaScripts.begin(); it != Doc->JavaScripts.end(); ++it)
@@ -131,3 +138,10 @@
emit docChanged(false);
}
}
+
+void JavaDocs::slotSelectionChanged()
+{
+ QListWidgetItem* currentItem = Scripts->currentItem();
+ EditScript->setEnabled(currentItem != 0);
+ DeleteScript->setEnabled(currentItem != 0);
+}
Modified: branches/Version14x/Scribus/scribus/javadocs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19484&path=/branches/Version14x/Scribus/scribus/javadocs.h
==============================================================================
--- branches/Version14x/Scribus/scribus/javadocs.h (original)
+++ branches/Version14x/Scribus/scribus/javadocs.h Sat Sep 6 12:06:32 2014
@@ -37,6 +37,7 @@
void slotAdd();
void slotEdit();
void slotDelete();
+ void slotSelectionChanged();
signals:
void docChanged(bool);
More information about the scribus-commit
mailing list