diff options
author | Patrick Ruoff <c14-radioactive@19e81ba0-9b1a-49c3-bd6c-561e1906d5fb> | 2012-09-21 14:00:34 +0000 |
---|---|---|
committer | Patrick Ruoff <c14-radioactive@19e81ba0-9b1a-49c3-bd6c-561e1906d5fb> | 2012-09-21 14:00:34 +0000 |
commit | ab0d60becc2d1b89c812193c179892d6acd4912f (patch) | |
tree | 2dae7d2c10e1cc3a5bd73ee8ae2ee609c69a1b7b /FaceTrackNoIR | |
parent | ddc63cdda186fe31435fde839c3d5b68040a0d0f (diff) |
RAII-style dll management 1: Replaced autoptr and release with virtual destructors
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@155 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FaceTrackNoIR')
-rw-r--r-- | FaceTrackNoIR/FaceTrackNoIR.cpp | 14 | ||||
-rw-r--r-- | FaceTrackNoIR/FaceTrackNoIR.h | 24 | ||||
-rw-r--r-- | FaceTrackNoIR/FaceTrackNoIR_vc9.vcproj | 12 | ||||
-rw-r--r-- | FaceTrackNoIR/tracker.h | 14 |
4 files changed, 24 insertions, 40 deletions
diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index d6fa5ce4..00e3a87c 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -50,7 +50,10 @@ // Setup the Main Dialog
//
FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) :
-QMainWindow(parent, flags)
+QMainWindow(parent, flags),
+pTrackerDialog(NULL),
+pProtocolDialog(NULL),
+pFilterDialog(NULL)
{
cameraDetected = false;
@@ -63,7 +66,6 @@ QMainWindow(parent, flags) _curve_config = 0;
tracker = 0;
- pTrackerDialog = NULL;
// _display = 0;
l = 0;
trayIcon = 0;
@@ -995,7 +997,7 @@ QString libName; // Delete the existing QDialog
//
if (pProtocolDialog) {
- pProtocolDialog.Release();
+ delete pProtocolDialog;
}
// Show the appropriate Protocol-server Settings
@@ -1050,7 +1052,8 @@ QString libName; // Delete the existing QDialog
//
if (pFilterDialog) {
- pFilterDialog.Release();
+ delete pFilterDialog;
+ pFilterDialog = NULL;
}
// Show the appropriate Protocol-server Settings
@@ -1174,7 +1177,8 @@ ITrackerDll *pTrackerDll; // Pointer to Filter info instance (in DLL) // Delete the existing QDialog
//
if (pProtocolDialog) {
- pProtocolDialog.Release();
+ delete pProtocolDialog;
+ pProtocolDialog = NULL;
}
// Show the appropriate Protocol-server Settings
diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index d2b9cdde..e3cf798e 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -42,26 +42,16 @@ #include "ui_FTNoIR_Preferences.h"
#include "ui_FTNoIR_Curves.h"
-//
#include "..\ftnoir_protocol_base\FTNoIR_Protocol_base.h"
#include "..\ftnoir_tracker_base\FTNoIR_Tracker_base.h"
#include "..\ftnoir_filter_base\FTNoIR_Filter_base.h"
-#include "AutoClosePtr.h"
-// 1a. COM-Like usage with smart pointer.
-// No need to call `ITracker::Release'; the instance will
-// be released automatically in destructor of the smart pointer.
-//typedef AutoClosePtr<ITrackerDialog, void, &ITrackerDialog::Release> ITrackerDialogPtr;
-typedef ITrackerDialog *(WINAPI *importGetTrackerDialog)(void);
-typedef ITrackerDll *(WINAPI *importGetTrackerDll)(void);
-
-typedef AutoClosePtr<IProtocolDialog, void, &IProtocolDialog::Release> IProtocolDialogPtr;
-typedef IProtocolDialog *(WINAPI *importGetProtocolDialog)(void);
-typedef AutoClosePtr<IFilterDialog, void, &IFilterDialog::Release> IFilterDialogPtr;
-typedef IFilterDialog *(WINAPI *importGetFilterDialog)(void);
-
-typedef AutoClosePtr<IFilterDll, void, &IFilterDll::Release> IFilterDllPtr;
-typedef IFilterDll *(WINAPI *importGetFilterDll)(void);
+typedef ITrackerDialogPtr (WINAPI *importGetTrackerDialog)(void);
+typedef ITrackerDllPtr (WINAPI *importGetTrackerDll)(void);
+typedef IProtocolDialogPtr (WINAPI *importGetProtocolDialog)(void);
+//typedef IProtocolDllPtr (WINAPI *importGetProtocolDll)(void);
+typedef IFilterDialogPtr (WINAPI *importGetFilterDialog)(void);
+typedef IFilterDllPtr (WINAPI *importGetFilterDll)(void);
#include <Dshow.h>
@@ -93,7 +83,7 @@ private: QStringList filterFileList; // List of Filter-DLL-files, that are present in the program-folder
QStringList trackerFileList; // List of Tracker-DLL-files, that are present in the program-folder
- ITrackerDialog *pTrackerDialog; // Pointer to Tracker dialog instance (in DLL)
+ ITrackerDialogPtr pTrackerDialog; // Pointer to Tracker dialog instance (in DLL)
IProtocolDialogPtr pProtocolDialog; // Pointer to Protocol dialog instance (in DLL)
IFilterDialogPtr pFilterDialog; // Pointer to Filter dialog instance (in DLL)
diff --git a/FaceTrackNoIR/FaceTrackNoIR_vc9.vcproj b/FaceTrackNoIR/FaceTrackNoIR_vc9.vcproj index 1d27b1e8..d7540dce 100644 --- a/FaceTrackNoIR/FaceTrackNoIR_vc9.vcproj +++ b/FaceTrackNoIR/FaceTrackNoIR_vc9.vcproj @@ -191,10 +191,6 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
- RelativePath=".\AutoClosePtr.h"
- >
- </File>
- <File
RelativePath=".\ExcelServer.cpp"
>
</File>
@@ -310,8 +306,8 @@ >
<Tool
Name="VCCustomBuildTool"
- Description="Moc'ing $(InputFileName)..."
- CommandLine=""$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_OPENGL_LIB -DQT_NETWORK_LIB -DQT_DLL -I".\GeneratedFiles\." -I"$(QTDIR)\include\." -I".\GeneratedFiles\$(ConfigurationName)\." -I"$(QTDIR)\include\QtCore\." -I"$(QTDIR)\include\QtNetwork\." -I"$(QTDIR)\include\QtGui\." -I"$(QTDIR)\include\QtOpenGL\." -I"$(QTDIR)\include\QtWebKit\." -I"$(QTDIR)\include\QtTest\." -I"$(SolutionDir)\FTNoIR_Tracker_UDP\." -I"$(SolutionDir)\FTNoIR_Tracker_UDP\GeneratedFiles\." -I"$(SolutionDir)\FTNoIR_Filter_EWMA2\." -I"C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Include\." ".\FTNoIR_cxx_protocolserver.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp"
"
+ Description="Moc'ing FTNoIR_cxx_protocolserver.h..."
+ CommandLine=""$(QTDIR)\bin\moc.exe" "$(InputPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_OPENGL_LIB -DQT_NETWORK_LIB -DQT_DLL "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtOpenGL" "-I$(QTDIR)\include\QtWebKit" "-I$(QTDIR)\include\QtTest" "-I$(SolutionDir)\QFunctionConfigurator\QFunctionConfigurator" "-I$(DXSDK_DIR)\Include"
"
AdditionalDependencies=""$(QTDIR)\bin\moc.exe";$(InputPath)"
Outputs="".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp""
/>
@@ -321,8 +317,8 @@ >
<Tool
Name="VCCustomBuildTool"
- Description="Moc'ing $(InputFileName)..."
- CommandLine=""$(QTDIR)\bin\moc.exe" "$(InputPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" -DQT_CORE_LIB -DQT_DLL -DQT_GUI_LIB -DQT_LARGEFILE_SUPPORT -DQT_OPENGL_LIB -DQT_THREAD_SUPPORT -DUNICODE -DWIN32 -I"$(QTDIR)\include\." -I"$(QTDIR)\include\QtCore\." -I"$(QTDIR)\include\QtGui\." -I"$(QTDIR)\include\QtNetwork\." -I"$(QTDIR)\include\QtOpenGL\." -I"$(QTDIR)\include\QtTest\." -I"$(QTDIR)\include\QtWebKit\." -I".\." -I".\GeneratedFiles\$(ConfigurationName)\." -I".\GeneratedFiles\."
"
+ Description="Moc'ing FTNoIR_cxx_protocolserver.h..."
+ CommandLine=""$(QTDIR)\bin\moc.exe" "$(InputPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_CORE_LIB -DQT_GUI_LIB -DQT_OPENGL_LIB -DQT_DLL "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtOpenGL" "-I$(QTDIR)\include\QtWebKit" "-I$(QTDIR)\include\QtTest" "-I$(SolutionDir)\QFunctionConfigurator\QFunctionConfigurator" "-I$(DXSDK_DIR)\Include"
"
AdditionalDependencies=""$(QTDIR)\bin\moc.exe";$(InputPath)"
Outputs="".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp""
/>
diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index d7c0506e..fd5c1d61 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -46,16 +46,10 @@ #include "..\ftnoir_tracker_base\FTNoIR_Tracker_base.h"
#include "..\ftnoir_protocol_base\FTNoIR_Protocol_base.h"
#include "..\ftnoir_filter_base\FTNoIR_Filter_base.h"
-//#include "AutoClosePtr.h"
-
-// 1a. COM-Like usage with smart pointer.
-// No need to call `ITracker::Release'; the instance will
-// be released automatically in destructor of the smart pointer.
-//typedef AutoClosePtr<ITracker, void, &ITracker::Release> ITrackerPtr;
-typedef ITracker *(WINAPI *importGetTracker)(void);
-typedef AutoClosePtr<IProtocol, void, &IProtocol::Release> IProtocolPtr;
-typedef IProtocol *(WINAPI *importGetProtocol)(void);
+typedef ITrackerPtr (WINAPI *importGetTracker)(void);
+typedef IProtocolPtr (WINAPI *importGetProtocol)(void);
+typedef IFilterPtr (WINAPI *importGetFilter)(void);
// include the DirectX Library files
#pragma comment (lib, "dinput8.lib")
@@ -179,7 +173,7 @@ private: static T6DOF new_camera;
static T6DOF output_camera;
- ITracker *pTracker; // Pointer to Tracker instance (in DLL)
+ ITrackerPtr pTracker; // Pointer to Tracker instance (in DLL)
static IProtocolPtr pProtocol; // Pointer to Protocol instance (in DLL)
static IFilterPtr pFilter; // Pointer to Filter instance (in DLL)
|