Repository navigation
[FIX] fix return a reference to local variable. - #2855
Conversation
|
mhh.. both solutions are illegal C++ if the name is not found :/ (segfault as you mentioned) Why not use the iterator and provide another (less efficient) interface for pyOpenMS? Or would Raw pointers be any better? |
|
@hroest is there any way we could use the iterator solution? would this mean that autowrap needs to be extended or only some addon file for pyOpenMS |
|
(another (bad) solution would be to return a reference to a static instance of an empty vector. Not really though as changing it will surprise the user...) |
|
since the return value is not const, how does the user tell if he got the real array or the 'does not exist' dummy version? People might even start to fill in data... this gets messy quickly... |
|
Yep. These are no real solutions. Iterator would be best or we need a has/get combination |
|
there are ways to get an iterator, but its quite ugly and also there is a chance that it will point to an invalid |
this fixes the build issue so I would like to merge this quickly. @enetz it currently doesn't check for the presence of the name and if it is missing we probably get a segfault. Best way would probably be to return the iterator but then the function is not easily wrapped with pyOpenMS.