[education/rkward] rkward/rbackend: Fix mysterious NULL objects appearing.

Thomas Friedrichsmeier null at kde.org
Fri Jun 10 17:24:34 BST 2022


Git commit b5885544e7172fa8bfb2035f3feafa3370c6f6a3 by Thomas Friedrichsmeier.
Committed on 10/06/2022 at 16:24.
Pushed by tfry into branch 'master'.

Fix mysterious NULL objects appearing.

M  +3    -3    rkward/rbackend/rkrsupport.cpp

https://invent.kde.org/education/rkward/commit/b5885544e7172fa8bfb2035f3feafa3370c6f6a3

diff --git a/rkward/rbackend/rkrsupport.cpp b/rkward/rbackend/rkrsupport.cpp
index 7d40112c..4cb232c4 100644
--- a/rkward/rbackend/rkrsupport.cpp
+++ b/rkward/rbackend/rkrsupport.cpp
@@ -165,10 +165,10 @@ SEXP RKRSupport::QVariantToSEXP(const QVariant& var) {
 
 QVariant RKRSupport::SEXPToNestedStrings(SEXP from_exp) {
 	RK_TRACE (RBACKEND);
-	if (Rf_isList(from_exp)) {
+	if (Rf_isVectorList(from_exp)) {  // NOTE: list() in R is a vectorlist in the C API...
 		QVariantList ret;
-		for(SEXP cons = from_exp; cons != R_NilValue; cons = CDR(cons)) {
-			SEXP el = CAR(cons);
+		for(int i = 0; i < Rf_length(from_exp); ++i) {
+			SEXP el = VECTOR_ELT(from_exp, i);
 			ret.append(SEXPToNestedStrings(el));
 		}
 		return ret;


More information about the rkward-tracker mailing list