Commit e0a8a3e
[DataHelper] Change default access of vector data buffer (#318)
* [DataHelper] Change behaviour of toBufferInfo for empty vectors
Until now, no difference was made in the toBufferInfo method depending
of the size of the handled data, in particular if this data was an empty
vector (with size = 0). Accessing such a vector through Python code
would called a trigger to the toBufferInfo method, resulting in a call
to the getValuePtr method and an access to the first element (data[0]),
which in this case doesn't exist.
We change this default behaviour by calling the getValuePtr method only
if the vector is not empty, and by returning a null pointer otherwise.
* Update Plugin/src/SofaPython3/DataHelper.cpp
Co-authored-by: Camille Krewcun <camille.krewcun@inria.fr>
Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>1 parent 2d62f4e commit e0a8a3e
1 file changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
338 | 341 | | |
339 | 342 | | |
340 | 343 | | |
| |||
0 commit comments