Added the sample management tools back into the SGMAppController. Started to track down memory issues in the sample tracking routines that Ethan wrote. Took the memory usage down from 20.1 percent (starting 2.5) to 3.4 percent (starting 2.5) for a list of 4 move and rotate actions.
Reenabled sample management in SGMAppController for testing. Starting moving to properly instantiated QVectors and replacing append calls. Did some testing. Found that AMShapeData::copy() can be called when the other AMShapeData has either 0 or -1 count; therefore, needed to protect the QVector instantiation from being called with size <=0. Tested and appears to work.
Merge branch 'Issue949' into Issue954
Removed some unneeded debugging.
Using Instruments with the Leaks/Allocations combo I found that SGMFastScanActionController was leaking a lot of memory in the createInitializationActions and createCleanupActions. It appears that while loop actions are cleaning up after themselves by deleting subaction as they go, list actions were not doing the same. I tried to use the same paradigm, but the list action seemed unhappy as it crashed in internalAllActionsHaveExpectedDuration(). I expect this might be a difference based on the fact that list can be sequential or parallel. So I added the destruction of the whole list of subactions back into the destructor using a foreach and deleteLater() calls. I am checking to make sure the action pointer is valid before doing so. We may need to invest a little more effort into cleaning this up. I've tested and it appears to work and it gets rid of the memory leak I was seeing.
Using Instruments with the Leaks/Allocations combo I found that memory was being leaked by AMSampleCamera::createMoveToSampleAction. This was actually a leak in AMSampleMoveAction, which use the AMSampleCamera call to get a list action, but never cleaned it up. Clean up is now done in the destructor of AMSampleMoveAction using a deleteLater() call protected by a check on the moveListAction_ pointer.
Continued QVector fixes in AMSampleCamera. Not yet tested. Needs to be checked on my Mac.
Merge branch 'Issue954' of github.com:acquaman/acquaman into Issue954
Using Instruments with the Leaks/Allocations combo I found some leaks in the loadCamera/Beam/RotationalOffset() calls. Fixed up some hanging bools that weren't cleaned up. Also made sure that AMSampleCamera cleans up the old beam model if a new one is set.
Fixed a few more instances of QVectors being allocated incorrectly and appended to. Done some simple testing and appears to be working.
Using Instruments with the Leaks/Allocations combo I found the motherload. Finally figured out how to get the call tree and found that AMSampleCameraView::drawSamplePlate() and AMSampleCameraView::createIntersectionShapes() were orphaning all of the QGraphicsPolygonItem pointers they were creating. The call was being made to the scene to remove them using removeItem(), but this leaves the caller responsible for cleaning up the memory, which was never happening. I've implemented the deletion in AMSampleCameraView::clearIntersections() (which does the clearing for AMSampleCameraView::createIntersectionShapes()) and directly in AMSampleCameraView::drawSamplePlate(). I've tested it and it appears to work just fine and the memory leaking is down dramatically.
Completely removed the AMShapeData from QVector3D AMSampleCamera::beamIntersectionPoint(). As @dretrex pointed out, it appears to be entirely superfluous. Removed it and everything appears to work with simple testing. Looks like the vast majority of the sample management leaks are gone.
Moved a pointer to the file writer object to AMScanActionController as a QObject*. This way we can add it to the chain of deletion for cleaning up scan controllers. It's now placed to call deleteLater on the fileWriter pointer (if there is one) and connect its destroyed signal to cleaning up the file writer thread. Tested for fast scans and XAS scan on SGM and it appears to be working correctly.Also fixed a minor memory issue in AMScanView where the exclusiveView and multiView were newing an MPlotPoint called plotCursor, but never cleaning them up. Also fixed a minor cleanup issue for AMBeamlineSampleManagementView which didn't clean up its samplePlateBrowserView_, which now happens in the destructor.
Fixed up an incorrect parent/layout issue in AMControlInfoListTableView and also added code to delete the allocated QTableWidgetItems. Fixed a memory leak in AMRunSelected where the itemDelegate_ and newRunDialog_ were not getting cleaned up (now in the desctructor). Fixed up a memory leak in AMScan with regard to an AMScanDictionary. I think the dictionary might still be in use, that's why I didn't remove it entirely.
In trying to tackle the action deletion problem there were two areas that needed clean up: scheduleForDeletion() in the AMAction3 inheritance tree and action logging to databases.
Modified:
- AMAction3::scheduleForDeletion() now has an implementation function. There is a default in AMAction3 and the only subclass that needs something different right now is AMScanAction.
- AMAction3 now has some boolean flag info for the scheduleForDeletion() calls so checking can be done. The scheduleForDeletion() call also makes sure it doesn't get run twice. Now AMListAction will only call scheduleForDeletion on its item in the destructor for items that need it.

Added:
- AMAction3 now has a loggingIsFinished flag and related signals. This is used to make sure that logging is completed before actually deleting (or deleteLater-ing) in scheduleForDeletion
- AMListAction3 and AMActionRunner3 are now responsible for setting this flag when they start an action (if it's going to be logged) and flagging completion when it's either completed or upddated (in the case of lists and loops).

I've done testing to make sure this still works. The action state machine seems to work fine. Scans work fine. Memory leak testing shows no leaks. Should be ready to go.
Altered:
- Found a couple places where I could optimize it a bit more.
Performance shouldn't be affected.
Removed:
- Commented out code.  General clean up for the issue.
Merge pull request #961 from acquaman/Issue576

Pull Request for Issue576: AMLoopAction3/AMListAction3 Destructor
Removed:
- Removed all the commented out code. General cleanup.
Merge pull request #956 from acquaman/Issue954

Pull Request for Issue954:  Sample Management and Fast Scan Memory Leak Issues