File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -288,8 +288,18 @@ static struct {
288
288
// The .preserve_list singleton is a member of cpp11::: and is managed by the R
289
289
// runtime. It cannot be constructed a header since many translation units may be
290
290
// 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);
291
+
292
+ // FIXME how can we create the cpp11 namespace when it doesn't already exist?
293
+ SEXP list_singleton_sym = safe[Rf_install](" .cpp11_preserve_list" );
294
+
295
+ list_singleton = safe[Rf_findVarInFrame](R_GlobalEnv, list_singleton_sym);
296
+
297
+ if (list_singleton == R_UnboundValue) {
298
+ list_singleton = PROTECT (Rf_cons (R_NilValue, R_NilValue));
299
+ R_PreserveObject (list_singleton);
300
+ UNPROTECT (1 );
301
+ safe[Rf_defineVar](list_singleton_sym, list_singleton, R_GlobalEnv);
302
+ }
293
303
}
294
304
295
305
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