mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Fixes R GC.activity when the data frames list don't match the activities list
The names attribute length must be equal to the vector size Fixes #2542
This commit is contained in:
@@ -2361,10 +2361,6 @@ RTool::activity(SEXP datetime, SEXP pCompare, SEXP pSplit, SEXP pJoin)
|
||||
// get multiple responses
|
||||
QList<SEXP> f;
|
||||
|
||||
// names
|
||||
SEXP names;
|
||||
PROTECT(names=Rf_allocVector(STRSXP, activities.count()));
|
||||
|
||||
// create a data.frame for each and add to list
|
||||
int index=0;
|
||||
foreach(RideItem *item, activities) {
|
||||
@@ -2375,9 +2371,6 @@ RTool::activity(SEXP datetime, SEXP pCompare, SEXP pSplit, SEXP pJoin)
|
||||
QApplication::processEvents();
|
||||
if (rtool->cancelled) break;
|
||||
|
||||
// give it a name
|
||||
SET_STRING_ELT(names, index, Rf_mkChar(QString("%1").arg(index+1).toLatin1().constData()));
|
||||
|
||||
// we open, if it wasn't open we also close
|
||||
// to make sure we don't exhause memory
|
||||
bool close = (item->isOpen() == false);
|
||||
@@ -2394,7 +2387,7 @@ RTool::activity(SEXP datetime, SEXP pCompare, SEXP pSplit, SEXP pJoin)
|
||||
// we have to give a name to each row
|
||||
SEXP rownames;
|
||||
PROTECT(rownames = Rf_allocVector(STRSXP, f.count()));
|
||||
for(int i=0; i<activities.count(); i++) {
|
||||
for(int i=0; i<f.count(); i++) {
|
||||
QString rownumber=QString("%1").arg(i+1);
|
||||
SET_STRING_ELT(rownames, i, Rf_mkChar(rownumber.toLatin1().constData()));
|
||||
}
|
||||
@@ -2403,7 +2396,7 @@ RTool::activity(SEXP datetime, SEXP pCompare, SEXP pSplit, SEXP pJoin)
|
||||
//XXX Do not create a dataframe of dataframes, R doesn't like these
|
||||
//XXX Rf_setAttrib(list, R_ClassSymbol, Rf_mkString("data.frame"));
|
||||
Rf_setAttrib(list, R_RowNamesSymbol, rownames);
|
||||
Rf_namesgets(list, names);
|
||||
Rf_namesgets(list, rownames);
|
||||
|
||||
UNPROTECT(3); // list and names and rownames
|
||||
|
||||
|
||||
Reference in New Issue
Block a user