Summary: | plugin error returns need to be enhanced | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Andrew Walker <arwalker> |
Component: | plugins | Assignee: | kst |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Andrew Walker
2004-08-26 00:45:50 UTC
We should have errors for at least the following: memory allocation plugin specific failure invalid input It would also be useful to be able to return a string that gives more information about the error, and which could be displayed in the debug log. Will add support for returning a string shortly, then close. CVS commit by staikos: 1) get rid of symbol warnings in KstDataSource 2) add support for custom strings in plugin errors BUG: 88086 M +5 -1 kstdatasource.cpp 1.45 M +10 -0 kstplugin.cpp 1.77 M +10 -0 plugin.cpp 1.28 M +2 -1 plugin.h 1.33 M +4 -0 pluginloader.cpp 1.16 --- kdeextragear-2/kst/kst/kstdatasource.cpp #1.44:1.45 @@ -143,5 +143,9 @@ namespace KST { // FIXME: might be a good idea to cache this per-symbol - return _lib->symbol(QFile::encodeName(sym + "_" + _plugLib)); + QCString s = QFile::encodeName(sym + "_" + _plugLib); + if (_lib->hasSymbol(s)) { + return _lib->symbol(s); + } + return 0L; } --- kdeextragear-2/kst/kst/kstplugin.cpp #1.76:1.77 @@ -323,4 +323,14 @@ KstObject::UpdateType KstPlugin::update( } _lastError = QString::null; + } else if (rc > 0) { + if (_lastError.isEmpty()) { + const char *err = _plugin->errorCode(rc); + if (err && *err) { + _lastError = err; + KstDebug::self()->log(i18n("Plugin %1 produced error: %2.").arg(tagName()).arg(_lastError), KstDebug::Error); + } else { + _lastError = QString::null; + } + } } else { bool doSend = _lastError.isEmpty() ? true : false; --- kdeextragear-2/kst/kst/plugin.cpp #1.27:1.28 @@ -30,4 +30,5 @@ Plugin::Plugin() : KstShared() { _symbol = 0L; _freeSymbol = 0L; + _errorSymbol = 0L; _parameterName = 0L; //kdDebug() << "Creating Plugin: " << long(this) << endl; @@ -38,4 +39,5 @@ Plugin::~Plugin() { _symbol = 0L; _freeSymbol = 0L; + _errorSymbol = 0L; _parameterName = 0L; @@ -198,3 +200,11 @@ bool Plugin::freeLocalData(void **local) } + +const char *Plugin::errorCode(int code) const { + if (_errorSymbol) { + return ((const char *(*)(int))_errorSymbol)(code); + } + return 0L; +} + // vim: ts=2 sw=2 et --- kdeextragear-2/kst/kst/plugin.h #1.32:1.33 @@ -58,4 +58,5 @@ class Plugin : public KstShared { QString parameterName(int index) const; bool freeLocalData(void **local) const; + const char *errorCode(int code) const; static const int CallError; @@ -143,5 +144,5 @@ class Plugin : public KstShared { KLibrary *_lib; - void *_symbol, *_freeSymbol; + void *_symbol, *_freeSymbol, *_errorSymbol; void *_parameterName; --- kdeextragear-2/kst/kst/pluginloader.cpp #1.15:1.16 @@ -76,4 +76,8 @@ Plugin *PluginLoader::loadPlugin(const Q } + if (plug->_lib->hasSymbol("errorCode")) { + plug->_errorSymbol = plug->_lib->symbol("errorCode"); + } + if (!plug->_symbol) { KstDebug::self()->log(i18n("Could not find symbol '%1' in plugin %2.").arg(plug->_data._name).arg(object), KstDebug::Error); |