[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kspread/plugins/scripting
From: Sebastian Sauer <mail () dipe ! org>
Date: 2007-08-13 21:23:23
Message-ID: 1187040203.742512.29429.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 699674 by sebsauer:
* fix crash if KCmdLineArgs==NULL. Thanks to dfaure for pointing it out.
* show errormessage rather then eating them
M +43 -36 ScriptingPart.cpp
--- trunk/koffice/kspread/plugins/scripting/ScriptingPart.cpp #699673:699674
@@ -31,6 +31,8 @@
#include <kactioncollection.h>
#include <kcmdlineargs.h>
#include <kurl.h>
+#include <klocale.h>
+#include <kmessagebox.h>
// KSpread
#include <Doc.h>
#include <View.h>
@@ -50,47 +52,52 @@
: KoScriptingPart(new ScriptingModule(parent), list)
, d(new Private())
{
- setComponentData(ScriptingPart::componentData());
- setXMLFile(KStandardDirs::locate("data","kspread/kpartplugins/scripting.rc"), \
true);
- kDebug() <<"Scripting plugin. Class:" << metaObject()->className() <<", Parent:" << \
parent->metaObject()->className(); + \
setComponentData(ScriptingPart::componentData()); + \
setXMLFile(KStandardDirs::locate("data","kspread/kpartplugins/scripting.rc"), true); \
+ kDebug() <<"Scripting plugin. Class:" << metaObject()->className() <<", Parent:" \
<< parent->metaObject()->className();
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- foreach(QString ba, args->getOptionList("scriptfile")) {
- QUrl url(ba);
- QFileInfo fi(url.path());
- const QString file = fi.absoluteFilePath();
- if( ! fi.exists() ) {
- kWarning() << QString("ScriptingPart: scriptfile \"%1\" does not \
exist.").arg(file);
- continue;
- }
- if( ! fi.isExecutable() ) {
- kWarning() << QString("ScriptingPart: scriptfile \"%1\" is not executable. Please \
set the executable-attribute on that file.").arg(file);
- continue;
- }
- { // check whether file is not in some temporary directory.
- QStringList tmpDirs = KGlobal::dirs()->resourceDirs("tmp");
- tmpDirs += KGlobal::dirs()->resourceDirs("cache");
- tmpDirs.append("/tmp/");
- tmpDirs.append("/var/tmp/");
- bool inTemp = false;
- foreach(QString tmpDir, tmpDirs)
- if( file.startsWith(tmpDir) ) {
- inTemp = true;
- break;
- }
- if( inTemp ) {
- kWarning() << QString("ScriptingPart: scriptfile \"%1\" is in a temporary \
directory. Execution denied.").arg(file);
- continue;
- }
- }
- if( ! Kross::Manager::self().executeScriptFile(url) )
- kWarning() << QString("ScriptingPart: Failed to execute scriptfile \
\"%1\"").arg(file);
- }
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+ if( args ) {
+ QStringList errors;
+ foreach(QString ba, args->getOptionList("scriptfile")) {
+ QUrl url(ba);
+ QFileInfo fi(url.path());
+ const QString file = fi.absoluteFilePath();
+ if( ! fi.exists() ) {
+ errors << i18n("Scriptfile \"%1\" does not exist.", file);
+ continue;
+ }
+ if( ! fi.isExecutable() ) {
+ errors << i18n("Scriptfile \"%1\" is not executable. Please set the \
executable-attribute on that file.", file); + continue;
+ }
+ { // check whether file is not in some temporary directory.
+ QStringList tmpDirs = KGlobal::dirs()->resourceDirs("tmp");
+ tmpDirs += KGlobal::dirs()->resourceDirs("cache");
+ tmpDirs.append("/tmp/");
+ tmpDirs.append("/var/tmp/");
+ bool inTemp = false;
+ foreach(QString tmpDir, tmpDirs)
+ if( file.startsWith(tmpDir) ) {
+ inTemp = true;
+ break;
+ }
+ if( inTemp ) {
+ errors << i18n("Scriptfile \"%1\" is in a temporary directory. \
Execution denied.", file); + continue;
+ }
+ }
+ if( ! Kross::Manager::self().executeScriptFile(url) )
+ errors << i18n("ScriptingPart: Failed to execute scriptfile \"%1\"", \
file); + }
+ if( errors.count() > 0 )
+ KMessageBox::errorList(module()->view(), i18n("Errors on execution of \
scripts."), errors); + }
}
ScriptingPart::~ScriptingPart()
{
- kDebug() <<"ScriptingPart::~ScriptingPart()";
+ //kDebug() <<"ScriptingPart::~ScriptingPart()";
delete d;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic