-
-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some safety improvement changes #59
Conversation
Regarding Nevertheless this case should be handled, of course, although I'm not convinced that simply returning from the |
Yes, I agree with you, exception throwing is a good idea. |
…e it creates useless damaged object, internal use only constructor is protected now
I started digging into wxSQLite3NamedCollection and found than default constructor creates damaged object (no methods to correct it) so I removed it. I looked existing exceptions and didn't find something like "corrupted object state". |
The problem here is that we need a default constructor. And if a default constructor is not explicitly defined, the compiler will implicitly define one - that's why the sample application is built and run successfully. Maybe a method Regarding the exception I would use a |
Done. About default constructor: it is true only if you don't define any alternative (with parameters or not) except move/copy constructors (https://en.cppreference.com/w/cpp/language/default_constructor). Now attempt to build wxSQLite3NamedCollection or derivatives will fail. |
Just a few remarks:
|
|
Thanks for applying most of my proposed modifications. PR looks good now.
This is on purpose, because the errors are not related to SQLite, but to loading a DLL. Personally, I no longer use the option to separate the wrapper, wxSQLite3, from the SQLite library itself by dynamically loading a SQLite DLL. Using a SQLite DLL makes it difficult to keep the supported features in sync between the wrapper and the SQLite library. Therefore the preferred method is to link the SQLite library statically with the wrapper. Most likely I will remove the option to dynamically load a SQLite DLL in a future version. However, I will not do it without asking for opinions from users of the component.
Well, in one of my applications I have a class using collections where the collection objects are members of the class. However, it is not always possible to initialize the collection objects on creation of a class instance, because the actual database is not yet known. Therefore I fear it is necessary to have default constructors at hand.
Yes, the code of wxSQLite3 has not been moved to using C++11 (or above) yet, since there exist several legacy applications based on C++98. However, I intend to upgrade the wxSQLite3 code to a more recent C++ version in the future - no fixed schedule yet, though. Regarding exceptions I was asked several times in the past, whether it would be possible to provide an exception free version of wxSQLite3. However, it would be a major change to abandon exceptions from wxSQLite3, and I'm not convinced that that would really be a desirable approach. |
…tives classes have been recovered
I recommend unique_ptr or raw pointer, or even placement new in this cases. But I have a question: does wxSQLite3NamedCollection should have a public constructor? As I see it is just a base class only for internal purposes, am I right? Maybe we should prevent its direct building? |
Yes, |
wxSQLite3NamedCollection::wxSQLite3NamedCollection() is protected now, so wxSQLite3NamedCollection objects can not be constructed any more. All proposed modifications is done as I see. What do you think? |
Thanks for your efforts. I'm now going to merge your PR. |
Thank you for a constructive dialogue. |
wxSQLite3StringCollection::Bind should return if m_data is nullptr otherwise it will fail. Sign/length mismatch was fixed in chacha20_xor.