[Rd] Object are not destroy while using error (Rf_error)

2023-01-21 Thread Antoine Lucas
Dear all,

I try to understand why on my computer I do not clear all data with this
code:


#include 
static int count = 0;

class A {
public:
  A(){  printf("c %d\n", count);
count++;  }

  ~A(){count--;
printf("d %d\n", count);  }
};

extern "C" {
  void testAL(){
A a;
{
  A b;
}
error("does not write [d 0]");
  }
}

To run with R: I build  gcc -shared -I/opt/R-202301/lib/R/include/
myError.cpp -o myError.so

then in R: dyn.load("myError.so")
.C("testAL")

This writes c0, c1, d1 but not d0.
If I comment line "error", I does write latest d0.

How could I get all my objects destroy while sending en error message to R ?

Regards,

Antoine Lucas.

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Object are not destroy while using error (Rf_error)

2023-01-21 Thread Dirk Eddelbuettel


Antoine,

I think there are few things going on here.  One is that actual _R_ objects
may only get destroyed when gc() gets called.  Which we applications writer
do not control.  Another thing that may have an effect is the use of .C()
which we all more or less moved away from.  Anyway, if we make your example a
proper C++ one with proper C++ scope (by trivial Rcpp wrapping for ease, but
that should not be a requirement) we see the four message you desire:


 Code

#include 

static int count = 0;

class A {
public:
  A(){  printf("c %d\n", count);
count++;  }

  ~A(){count--;
printf("d %d\n", count);  }
};

// [[Rcpp::export]]
void testAL(){
  A a;
  {
A b;
  }
  Rcpp::stop("does not write [d 0]");
}

/*** R
testAL()
*/


 Output

> Rcpp::sourceCpp("/tmp/ctorDemo.cpp")

> testAL()
c 0
c 1
d 1
d 0
Error in eval(ei, envir) : does not write [d 0]
> 


Hope this helps,  Dirk

-- 
dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] about RGui HighDPI awareness on windows

2023-01-21 Thread yu gong
Continually working on this,  System DPI awareness implemented improved and 
almost finished.

Now the modify includes: Window, Dialogs and Toolbar implemented use graphapp. 
which related to Multiple places in the R windows front end and R base package 
and modules. Now most of them modified to DPI awareness(some of them, 
surprisingly DPI awareness ready, do not need to mod,) .

I test on two PCS168-dpi and 192 dpi, RGUI windows(include console, editor, 
pagers), dialogs (include download, repo related , preference), and most 
important, plotting Windows, All of them work smoothly on my test PCS.

The patch url is 
https://github.com/armgong/misc-r-patch/blob/main/dpi-c-code.diff and two test 
picture of my PCS are also in the repo.

Looking forward to any feedback or feedback from you.

Best regards,
Yu Gong





From: R-devel  on behalf of yu gong 

Sent: Friday, January 20, 2023 17:23
To: r-devel@r-project.org 
Subject: [Rd] about RGui HighDPI awareness on windows

Dear all:

Now RGui on windows no HighDPI awareness.try add HighDPI awareness to RGui in 
last  two days.

I write an initial POC(just for verify and only SystemDPI awareness  partial 
implemented) , try to mod graphapp used in  R  to implemented DPI scaling.
it seems works on my laptop , but need  further test.

So I post the patch 
https://github.com/armgong/misc-r-patch/blob/main/dpi-c-code.diff

if you interested in this ,please read or  try the patch.

Looking forward to hear your thoughts about this patch.

Best regards,
Yu Gong




[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel