Bug 85209 - Using indirect file as datasource causes crash
Summary: Using indirect file as datasource causes crash
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR crash
Target Milestone: ---
Assignee: George Staikos
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-14 22:15 UTC by D. V. Wiebe
Modified: 2004-07-15 06:41 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description D. V. Wiebe 2004-07-14 22:15:46 UTC
Version:           0.98 (using KDE 3.2 BRANCH >= 20040204, Mandrake Linux Cooker i586 - Cooker)
Compiler:          gcc version 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)
OS:                Linux (i686) release 2.6.3-7mdk

kst crashes with a command line such as

kst -y FASTSAMP /data/etc/defile.cur

where /data/etc/defile.cur is an indirect data source pointing to a dirfile.  (I mean, like, it's a text file with the path to a dirfile.)  Specifying the dirfile itself works fine.  Using the curfile as the data source in the data wizard also causes crash.
Comment 1 George Staikos 2004-07-15 05:06:21 UTC
Reproduced, working on it.
Comment 2 George Staikos 2004-07-15 06:41:40 UTC
CVS commit by staikos: 

don't crash
CCMAIL: 85209-done@bugs.kde.org


  M +14 -4     kstdatasource.cpp   1.23


--- kdeextragear-2/kst/kst/kstdatasource.cpp  #1.22:1.23
@@ -26,4 +26,5 @@
 #include <kservicetype.h>
 
+#include <qdeepcopy.h>
 #include <qfile.h>
 #include <qstylesheet.h>
@@ -42,7 +43,13 @@ namespace KST {
         assert(service);
         _plugLib = service->property("X-Kst-Plugin-Library").toString();
+        //kdDebug() << "Create plugin " << (void*)this << " " << service->property("Name").toString() << endl;
       }
 
-      virtual ~Plugin() { if (_lib) { _lib->unload(); } }
+      virtual ~Plugin() {
+        //kdDebug() << "Destroy plugin " << (void*)this << " " << service->property("Name").toString() << endl;
+        if (_lib) {
+          _lib->unload();
+        }
+      }
 
       KstDataSource *create(const QString& filename, const QString& type = QString::null) const {
@@ -144,5 +151,6 @@ static void scanPlugins() {
   // This cleans up plugins that have been uninstalled and adds in new ones.
   // Since it is a shared pointer it can't dangle anywhere.
-  pluginInfo = tmpList;
+  pluginInfo.clear();
+  pluginInfo = QDeepCopy<KST::PluginInfoList>(tmpList);
 }
 
@@ -168,6 +176,8 @@ static KstDataSourcePtr findPluginFor(co
   scanPlugins();
 
+  KST::PluginInfoList info = QDeepCopy<KST::PluginInfoList>(pluginInfo);
+
   if (!type.isEmpty()) {
-    for (KST::PluginInfoList::ConstIterator it = pluginInfo.begin(); it != pluginInfo.end(); ++it) {
+    for (KST::PluginInfoList::ConstIterator it = info.begin(); it != info.end(); ++it) {
       if ((*it)->provides(type)) {
         plugin = (*it)->create(filename, type);
@@ -179,5 +189,5 @@ static KstDataSourcePtr findPluginFor(co
   }
 
-  for (KST::PluginInfoList::ConstIterator it = pluginInfo.begin(); it != pluginInfo.end(); ++it) {
+  for (KST::PluginInfoList::ConstIterator it = info.begin(); it != info.end(); ++it) {
     if ((*it)->understands(filename)) {
       plugin = (*it)->create(filename);