[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Fri Jun 24 23:19:44 CEST 2005


SVN commit 428667 by staikos:

add a key to plugins that must be recent in order for the plugin
to be loaded.  It's presently set to 1, but dropping it to 0 will
load old plugins again.  The benefit is that we can break binary
compatibility inside kstdatasource and not worry about broken
plugins everywhere.  This will likely be the only choice we have
in order to implement matrices and other types from datasources.

Requires plugin developers to add a 1-line macro call to their
source.  All Kst SVN plugins were updated.


 M  +2 -0      datasources/ascii/ascii.cpp  
 M  +2 -0      datasources/cdf/cdf.cpp  
 M  +2 -0      datasources/dirfile/dirfile.cpp  
 M  +2 -0      datasources/hpic/hpic.cpp  
 M  +2 -0      datasources/indirect/indirect.cpp  
 M  +2 -0      datasources/lfiio/lfiio.cpp  
 M  +2 -0      datasources/netcdf/netcdf.cpp  
 M  +2 -0      datasources/planck/planck.cpp  
 M  +2 -0      datasources/template/template.cpp  
 M  +16 -1     kstdatasource.cpp  
 M  +4 -0      kstdatasource.h  


--- trunk/extragear/graphics/kst/kst/datasources/ascii/ascii.cpp #428666:428667
@@ -861,4 +861,6 @@
 
 }
 
+KST_KEY_DATASOURCE_PLUGIN(ascii)
+
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/datasources/cdf/cdf.cpp #428666:428667
@@ -323,4 +323,6 @@
 
 }
 
+KST_KEY_DATASOURCE_PLUGIN(cdf)
+
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/datasources/dirfile/dirfile.cpp #428666:428667
@@ -199,4 +199,6 @@
 
 }
 
+KST_KEY_DATASOURCE_PLUGIN(dirfile)
+
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/datasources/hpic/hpic.cpp #428666:428667
@@ -563,5 +563,7 @@
 
 }
 
+KST_KEY_DATASOURCE_PLUGIN(hpic)
 
+
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/datasources/indirect/indirect.cpp #428666:428667
@@ -179,4 +179,6 @@
 
 }
 
+KST_KEY_DATASOURCE_PLUGIN(indirect)
+
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/datasources/lfiio/lfiio.cpp #428666:428667
@@ -398,4 +398,6 @@
 
 }
 
+KST_KEY_DATASOURCE_PLUGIN(lfiio)
+
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/datasources/netcdf/netcdf.cpp #428666:428667
@@ -310,4 +310,6 @@
 
 }
 
+KST_KEY_DATASOURCE_PLUGIN(netcdf)
+
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/datasources/planck/planck.cpp #428666:428667
@@ -376,4 +376,6 @@
 
 }
 
+KST_KEY_DATASOURCE_PLUGIN(planck)
+
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/datasources/template/template.cpp #428666:428667
@@ -119,4 +119,6 @@
 
 }
 
+KST_KEY_DATASOURCE_PLUGIN(template)
+
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/kstdatasource.cpp #428666:428667
@@ -153,6 +153,15 @@
         return QStringList();
       }
 
+      Q_UINT32 key() const {
+        Q_UINT32 (*sym)() = (Q_UINT32(*)())symbol("key");
+        if (sym) {
+          return (sym)();
+        }
+
+        return Q_UINT32();
+      }
+
       bool hasConfigWidget() const {
         return 0L != symbol("widget");
       }
@@ -198,8 +207,14 @@
         _lib = KLibLoader::self()->library(libname);
         if (!_lib) {
           KstDebug::self()->log(i18n("Error loading data-source plugin [%1]: %2").arg(libname).arg(KLibLoader::self()->lastErrorMessage()), KstDebug::Error);
+          return false;
         }
-        return _lib != 0L;
+
+        if (key() != KST_CURRENT_DATASOURCE_KEY) {
+          KstDebug::self()->log(i18n("Error loading data-source plugin [%1]: %2").arg(libname).arg(i18n("Plugin is too old and needs to be recompiled.")), KstDebug::Error);
+          return false;
+        }
+        return true;
       }
 
       QString _plugLib;
--- trunk/extragear/graphics/kst/kst/kstdatasource.h #428666:428667
@@ -30,6 +30,10 @@
 #include "kstobject.h"
 #include "kst_export.h"
 
+#define KST_CURRENT_DATASOURCE_KEY 0x00000001 
+
+#define KST_KEY_DATASOURCE_PLUGIN(x) extern "C" Q_UINT32 key_##x() { return KST_CURRENT_DATASOURCE_KEY; }
+
 namespace KST {
   class Plugin;
 }


More information about the Kst mailing list