[education/rkward] rkward/rbackend: Now that we have loose coupling, relax the version requirements for graphics engine

Thomas Friedrichsmeier null at kde.org
Fri May 10 17:04:24 BST 2024


Git commit bf202baa36215aef72203c00a884dca9ea64181e by Thomas Friedrichsmeier.
Committed on 09/05/2024 at 21:43.
Pushed by tfry into branch 'master'.

Now that we have loose coupling, relax the version requirements for graphics engine

M  +6    -0    rkward/rbackend/rkrapi.h
M  +11   -4    rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp

https://invent.kde.org/education/rkward/-/commit/bf202baa36215aef72203c00a884dca9ea64181e

diff --git a/rkward/rbackend/rkrapi.h b/rkward/rbackend/rkrapi.h
index fb4d26ed3..b768ad94d 100644
--- a/rkward/rbackend/rkrapi.h
+++ b/rkward/rbackend/rkrapi.h
@@ -49,6 +49,12 @@ effect during the lifetime of an executable.
 4e. We cd back to where we were before 4c.
 5. do_main() is resolved from librkward.rbackend.lib.so, and called with a handle to libR.so to resolve all required R symbols.
 
+Now it may stand out that most of this is really just about Linux, and in particular about AppImage. Is it even worth it?
+- On Mac, while libs-references are usually absolute, this same fact prevents us from bundling R, which means we need to rely on libs outside of our
+  bundle. Signing gets throun by this. dlopen()ing, instead, helps (I think).
+- On all platforms, this allows us more flexibility to support more than just one version of R. E.g. when running with an R version older than that
+  used a compile-time, we can simply skip setting up certain graphics engine callbacks. The same would not be possible using regular linking.
+
 ---
 
 All this written, I don't quite trust this scheme to be perfect, yet, and so one design goal is to keep the old (link all shared libs to rkward.rbackend, directly)
diff --git a/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp b/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp
index 4720a93e5..8be6be5a5 100644
--- a/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp
+++ b/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp
@@ -49,8 +49,15 @@ void RKStartGraphicsDevice (double width, double height, double pointsize, const
 	desc->height = height;
 
 	if (RFn::R_GE_getVersion() != R_GE_version) {
-		RKRBackend::this_pointer->graphicsEngineMismatchMessage(R_GE_version, RFn::R_GE_getVersion());
-		RFn::Rf_error("Graphics version mismatch");
+		if (RFn::R_GE_getVersion() < 14) {
+			RKRBackend::this_pointer->graphicsEngineMismatchMessage(R_GE_version, RFn::R_GE_getVersion());
+			RFn::Rf_error("Graphics version mismatch");
+		} else {
+			// All other cases currently thought ot be acceptible?
+			// GE version 17 adds capabilities(), so higher GE version should no longer be a problem.
+			// Lower GE version should be ok (down to 14, ATM), because we simply behave as though that was the case.
+			RK_DEBUG(RBACKEND, DL_WARNING, "GE version compile time: %d, GE version runtime %d", R_GE_version, RFn::R_GE_getVersion());
+		}
 	}
 	RFn::R_CheckDeviceAvailable();
 	pDevDesc dev;
@@ -183,7 +190,7 @@ bool RKGraphicsDeviceDesc::init (pDevDesc dev, double pointsize, const QStringLi
 	dev->newFrameConfirm = RKD_NewFrameConfirm;
 	dev->holdflush = RKD_HoldFlush;
 
-#if R_VERSION >= R_Version (4, 2, 0)
+#if R_VERSION >= R_Version (4, 1, 0)
 	// NOTE: We need both a compiletime and a runtime check, in order to support running with an R older than what was used at compile time
 	if (RFn::R_GE_getVersion() >=  15) {
 		// patterns and gradients
@@ -195,7 +202,7 @@ bool RKGraphicsDeviceDesc::init (pDevDesc dev, double pointsize, const QStringLi
 		// masks
 		dev->setMask = RKD_SetMask;
 		dev->releaseMask = RKD_ReleaseMask;
-		dev->deviceVersion = qMin(15, R_GE_version);
+		dev->deviceVersion = qMin(qMin(15, R_GE_version), RFn::R_GE_getVersion());
 		dev->deviceClip = TRUE; // for now
 	}
 #endif



More information about the rkward-tracker mailing list