release png,jpeg resources in destructor#22250
Conversation
|
There should be separation of roles to avoid creation of GOD classes with unclear API:
|
|
@alalek, I think, removal close() from ReadData(), so that it's only called in destructor or in 'open()' does not relate to GOD concept, as you call it. close() will be called in any case. |
The GOD concept is about this. |
|
@ocpalo Please pay attention that Decoder classes are not designed to call methods multiple times and it;s not tested. |
|
@asmorkalov I see. Yet this calls are still unnecessary. Consider |
Releasing resources should be done in the destructor. The user might call this method more than once.
auto res = decoder.readData(mat); ... res = decoder.readData(mat);This is not efficient but it is possible. In this case, behavior is undefined because of the
close()call.