@@ -241,6 +241,7 @@ RC2::RSession::~RSession()
241241void
242242RC2::RSession::consoleCallback (const string &text, bool is_error)
243243{
244+ if (!_impl->open && !is_error) return ;
244245 if (stringHasPrefix (text, " rc2.imgstart=" )) {
245246 auto imgname = text.substr (13 );
246247 boost::algorithm::trim (imgname);
@@ -253,7 +254,7 @@ RC2::RSession::consoleCallback(const string &text, bool is_error)
253254 _impl->currentImageName = " " ;
254255 return ;
255256 }
256- LOG (INFO) << " write cb: " << text << " (ignore=" << _impl->ignoreOutput << " ,vis=" << R_Visible << " ,sip=" << _impl->sourceInProgress << " )" ;
257+ LOG (INFO) << " write cb: " << text << " (ignore=" << _impl->ignoreOutput << " ,vis=" << R_Visible << " ,sip=" << _impl->sourceInProgress << " ,err= " << is_error << " )" ;
257258 if (_impl->captureStdOut ) {
258259 _impl->stdOutCapture += text;
259260 return ;
@@ -486,8 +487,6 @@ RC2::RSession::handleOpenCommand(JsonCommand &cmd)
486487 LOG (INFO) << " wd=" << _impl->tmpDir ->getPath ();
487488 auto connection = make_shared<PGDBConnection>();
488489 connection->connect (connectString.str ());
489- _impl->fileManager ->initFileManager (workDir, connection, _impl->wspaceId , _impl->sessionRecId );
490- bool haveRData = _impl->fileManager ->loadRData ();
491490 setenv (" TMPDIR" , workDir.c_str (), 1 );
492491 setenv (" TEMP" , workDir.c_str (), 1 );
493492 setenv (" R_DEFAULT_DEVICE" , " png" , 1 );
@@ -499,6 +498,8 @@ RC2::RSession::handleOpenCommand(JsonCommand &cmd)
499498 _impl->R ->parseEvalQNT (" rm(argv)" ); // RInside creates this even though we passed NULL
500499 _impl->R ->parseEvalQNT (" options(device = \" rc2.pngdev\" , bitmapType = \" cairo\" )" );
501500 _impl->R ->parseEvalQNT (" source(\" " + escape_quotes (ourCodePath) + " \" , keep.source=FALSE)" );
501+ _impl->fileManager ->initFileManager (workDir, connection, _impl->wspaceId , _impl->sessionRecId );
502+ bool haveRData = _impl->fileManager ->loadRData ();
502503 if (haveRData) {
503504 LOG (INFO) << " loading .RData" ;
504505 _impl->R ->parseEvalQNT (" load(\" .RData\" )" );
0 commit comments