Resolved issues with original sample app.#13
Resolved issues with original sample app.#13peterv959 wants to merge 2 commits intoZebraDevs:masterfrom
Conversation
1) Memory leaks because delete was never called on the images containing a barcode. Both in ImageVideoDlg.cpp and in ScanToConnect.Dlg.cpp 2) Memory leak when the ScannerEventSink was being released. The pointer was assigned a NULL value but the memory itself was never deleted. That may be fine in C#, but not in C++. Also, the variable was assigned NULL (correct) and 0 (incorrect and redundant). 3) DWORD values were getting implicitly cast to ints. While this was acceptable since the values would always be within an int range, I added static_cast<int>() around the values to suppress the warnings. 4) Soon to be deprecated /Gm compile switch was removed. Multiprocessor build MP was enabled in its place. Unless a platform older than VS 2015 is to be used, this should be backward compatible.
1) The _itow_s() method was being passed buffers that were adequate, but COULD be too short for the conversion. There are predefined macros that specify a maximum possible length for typical data types and radices. I changed all found uses to allocate that buffer size. That value is something like 11 or 12 so it's not a radical changed. Also, there were some older uses which specified the length being passed. I converted them from four parameters to three parameters since everything is C++. 2) In the COM interface, there are two places where a SAFEARRAY is created. However, in neither place was that SAFEARRAY destroyed. 3) The return value of the GetItemData() method for lists & combo boxes is a DWORD_PTR. However, an int type is being stored there. Inherently, there's nothing wrong with that, per se. But it could lead to future headaches. I adjusted those use cases to call static_cast<int>() on the method and changed the returned data type to an int to match that. The old-style (int) cast is fine, but the newer staatic_cast<int>() is a safer approach. Those were the issues I recall seeing. peterv959
|
I found a few more cleanup things that should improve the overall app. There's nothing new, per se. However, there are updates to the build process that helped find small issues that might cause a problem. I recognize that a) this is a sample app, not a production app, and b) as such it is meant to show HOW to use the SDK. Given that most people seem to have gravitated to C#, perhaps it's moot, but I'm an old C++ dinosaur. The next major task to accomplish would be to modernize the whole UI and migrate towards a different paradigm. Something like XAML which is a pretty exciting interface to use. Be that as it may, if you have the inclination to review what I did and accept or reject this request I would be gratefull. And next time I'll create a branch for my changes. I'm still kind of new to the whole collaboration process. Thanks again for your time. peterv959 |
|
@zebradcs plz merg this |
This should resolve issue #12