File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 14
14
#include " R_ext/Utils.h" // for R_CheckUserInterrupt
15
15
#include " Rversion.h" // for R_VERSION, R_Version
16
16
17
+ #include < iostream>
18
+
17
19
#if defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0)
18
20
#define HAS_UNWIND_PROTECT
19
21
#endif
@@ -288,8 +290,18 @@ static struct {
288
290
// The .preserve_list singleton is a member of cpp11::: and is managed by the R
289
291
// runtime. It cannot be constructed a header since many translation units may be
290
292
// compiled, resulting in unrelated instances of each static variable.
291
- SEXP ns = safe[Rf_findVarInFrame](R_NamespaceRegistry, safe[Rf_install](" cpp11" ));
292
- list_singleton = safe[Rf_findVar](safe[Rf_install](" .preserve_list" ), ns);
293
+
294
+ // FIXME how can we create the cpp11 namespace when it doesn't already exist?
295
+ SEXP list_singleton_sym = safe[Rf_install](" .cpp11_preserve_list" );
296
+
297
+ list_singleton = safe[Rf_findVarInFrame](R_GlobalEnv, list_singleton_sym);
298
+
299
+ if (list_singleton == R_UnboundValue) {
300
+ list_singleton = PROTECT (Rf_cons (R_NilValue, R_NilValue));
301
+ R_PreserveObject (list_singleton);
302
+ UNPROTECT (1 );
303
+ safe[Rf_defineVar](list_singleton_sym, list_singleton, R_GlobalEnv);
304
+ }
293
305
}
294
306
295
307
return list_singleton;
Original file line number Diff line number Diff line change @@ -766,7 +766,9 @@ inline r_vector<T>::r_vector(const r_vector<T>& rhs)
766
766
767
767
template <typename T>
768
768
inline r_vector<T>::r_vector(r_vector<T>&& rhs)
769
- : cpp11::r_vector<T>(rhs), protect_(preserved.insert(data_)), capacity_(rhs.capacity_) {
769
+ : cpp11::r_vector<T>(rhs),
770
+ protect_ (preserved.insert(data_)),
771
+ capacity_(rhs.capacity_) {
770
772
rhs.data_ = R_NilValue;
771
773
rhs.protect_ = R_NilValue;
772
774
}
You can’t perform that action at this time.
0 commit comments