
here is my complete test program.
// TestMemBis.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "CloneAppRecipe.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int main()
{
CloneAppRecipe t;
// cree un leak
t.connectPtrTestMem();
getchar();
return 0;
}
// CloneAppRecipe.h: interface for the CloneAppRecipe class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CLONEAPPREC__INCLUDED_)
#define AFX_CLONEAPPREC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "TestMem.h"
class CloneAppRecipe
{
public:
CloneAppRecipe();
~CloneAppRecipe();
private:
// desactive constructeur copie et operateur=
CloneAppRecipe( const CloneAppRecipe& rhs );
CloneAppRecipe& operator=( const CloneAppRecipe& rhs );
// slot pour connecter
void test() const;
public:
void connectPtrTestMem();
boost::shared_ptr<TestMem> m_ptrTestMem;
};
#endif
// CloneAppRecipe.cpp: implementation of the CloneAppRecipe class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CloneAppRecipe.h"
#include "TestTab.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CloneAppRecipe::CloneAppRecipe() : m_ptrTestMem( new TestMem() )
{
}
CloneAppRecipe::~CloneAppRecipe()
{
}
void CloneAppRecipe::test() const
{
}
void CloneAppRecipe::connectPtrTestMem()
{
m_ptrTestMem->ConnectSignal(boost::bind(&CloneAppRecipe::test, this));
}
// TestMem.h: interface for the TestMem class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TESTMEM__INCLUDED_)
#define AFX_TESTMEM__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class TestTab;
class TestMem
{
public:
typedef boost::signal0<void> TypeSignalTest;
TestMem();
~TestMem();
void ConnectSignal(const TypeSignalTest::slot_type& slot) const;
private:
// desactive constructeur copie et operateur=
TestMem( const TestMem& rhs );
TestMem& operator=( const TestMem& rhs );
boost::shared_ptr<TestTab> m_ptrTestTab1;
boost::shared_ptr<TestTab> m_ptrTestTab2;
boost::shared_ptr<TestTab> m_ptrTestTab3;
};
#endif //
!defined(AFX_VISIONPARAMTABMANAGER_H__F0F26B98_D7D0_489E_AD5F_0DDEBF9A2D4F__INCLUDED_)
// TestMem.cpp: implementation of the TestMem class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TestMem.h"
#include "TestTab.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
TestMem::TestMem()
: m_ptrTestTab1( new TestTab() ),
m_ptrTestTab2( new TestTab() ),
m_ptrTestTab3( new TestTab() )
{
}
TestMem::~TestMem()
{
}
void TestMem::ConnectSignal(const TypeSignalTest::slot_type& slot) const
{
m_ptrTestTab1->ConnectSignal(slot);
m_ptrTestTab2->ConnectSignal(slot);
m_ptrTestTab3->ConnectSignal(slot);
}
// VisionParamGenericTab.h: interface for the CVisionParamGenericTab class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TEST_TAB)
#define AFX_TEST_TAB
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
typedef boost::signal0<void> TypeSignalTest;
class TestTab
{
public:
TestTab();
~TestTab();
void ConnectSignal(const TypeSignalTest::slot_type& slot);
private:
// desactive constructeur copie
TestTab( const TestTab& rhs );
TestTab& operator=( const TestTab& rhs );
TypeSignalTest m_SignalTest;
};
#endif
// TestTab.cpp: implementation of the TestTab class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TestTab.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
TestTab::TestTab()
{
}
TestTab::~TestTab()
{
m_SignalTest.disconnect_all_slots();
}
void TestTab::ConnectSignal(const TypeSignalTest::slot_type& slot)
{
m_SignalTest.connect(slot);
}
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__4BC26E01_A411_43B7_9129_B453770CBE84__INCLUDED_)
#define AFX_STDAFX_H__4BC26E01_A411_43B7_9129_B453770CBE84__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include