Kaydet (Commit) 6850e9b8 authored tarafından Noel Grandin's avatar Noel Grandin

first step towards removing LazyDeletor

convert it from a template to a concrete class, since we only have one
use-site for it anyway

Change-Id: I7209243cc744c7ddb727d6136795d8628b91ff6f
üst 274c836c
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <vcl/dllapi.h> #include <vcl/dllapi.h>
#include <vcl/vclptr.hxx> #include <vcl/vclptr.hxx>
#include <vcl/window.hxx>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
...@@ -95,14 +96,13 @@ namespace vcl ...@@ -95,14 +96,13 @@ namespace vcl
virtual ~LazyDeletorBase(); virtual ~LazyDeletorBase();
}; };
template < typename T >
class VCL_DLLPUBLIC LazyDeletor : public LazyDeletorBase class VCL_DLLPUBLIC LazyDeletor : public LazyDeletorBase
{ {
static LazyDeletor< T >* s_pOneInstance; static LazyDeletor* s_pOneInstance;
struct DeleteObjectEntry struct DeleteObjectEntry
{ {
VclPtr<T> m_pObject; VclPtr<vcl::Window> m_pObject;
bool m_bDeleted; bool m_bDeleted;
DeleteObjectEntry() : DeleteObjectEntry() :
...@@ -110,7 +110,7 @@ namespace vcl ...@@ -110,7 +110,7 @@ namespace vcl
m_bDeleted( false ) m_bDeleted( false )
{} {}
DeleteObjectEntry( T* i_pObject ) : DeleteObjectEntry( vcl::Window* i_pObject ) :
m_pObject( i_pObject ), m_pObject( i_pObject ),
m_bDeleted( false ) m_bDeleted( false )
{} {}
...@@ -123,7 +123,7 @@ namespace vcl ...@@ -123,7 +123,7 @@ namespace vcl
/** strict weak ordering function to bring objects to be destroyed lazily /** strict weak ordering function to bring objects to be destroyed lazily
in correct order, e.g. for Window objects children before parents in correct order, e.g. for Window objects children before parents
*/ */
static bool is_less( T* left, T* right ); static bool is_less( vcl::Window* left, vcl::Window* right );
LazyDeletor() { LazyDelete::addDeletor( this ); } LazyDeletor() { LazyDelete::addDeletor( this ); }
virtual ~LazyDeletor() virtual ~LazyDeletor()
...@@ -137,7 +137,7 @@ namespace vcl ...@@ -137,7 +137,7 @@ namespace vcl
// do the actual work // do the actual work
unsigned int nCount = m_aObjects.size(); unsigned int nCount = m_aObjects.size();
std::vector< VclPtr < T > > aRealDelete; std::vector< VclPtr < vcl::Window > > aRealDelete;
aRealDelete.reserve( nCount ); aRealDelete.reserve( nCount );
for( unsigned int i = 0; i < nCount; i++ ) for( unsigned int i = 0; i < nCount; i++ )
{ {
...@@ -167,10 +167,10 @@ namespace vcl ...@@ -167,10 +167,10 @@ namespace vcl
public: public:
/** mark an object for lazy deletion /** mark an object for lazy deletion
*/ */
static void Delete( T* i_pObject ) static void Delete( vcl::Window* i_pObject )
{ {
if( s_pOneInstance == NULL ) if( s_pOneInstance == NULL )
s_pOneInstance = new LazyDeletor<T>(); s_pOneInstance = new LazyDeletor();
// is this object already in the list ? // is this object already in the list ?
// if so mark it as not to be deleted; else insert it // if so mark it as not to be deleted; else insert it
...@@ -187,7 +187,7 @@ namespace vcl ...@@ -187,7 +187,7 @@ namespace vcl
} }
/** unmark an object already marked for lazy deletion /** unmark an object already marked for lazy deletion
*/ */
static void Undelete( T* i_pObject ) static void Undelete( vcl::Window* i_pObject )
{ {
if( s_pOneInstance ) if( s_pOneInstance )
{ {
......
...@@ -33,7 +33,7 @@ LazyDeletorBase::~LazyDeletorBase() ...@@ -33,7 +33,7 @@ LazyDeletorBase::~LazyDeletorBase()
} }
// instantiate instance pointer for LazyDeletor<Window> // instantiate instance pointer for LazyDeletor<Window>
template<> LazyDeletor<vcl::Window>* LazyDeletor<vcl::Window>::s_pOneInstance = NULL; LazyDeletor* LazyDeletor::s_pOneInstance = NULL;
// a list for all LazyeDeletor<T> singletons // a list for all LazyeDeletor<T> singletons
static std::vector< LazyDeletorBase* > lcl_aDeletors; static std::vector< LazyDeletorBase* > lcl_aDeletors;
...@@ -54,7 +54,7 @@ void LazyDelete::flush() ...@@ -54,7 +54,7 @@ void LazyDelete::flush()
} }
// specialized is_less function for Window // specialized is_less function for Window
template<> bool LazyDeletor<vcl::Window>::is_less( vcl::Window* left, vcl::Window* right ) bool LazyDeletor::is_less( vcl::Window* left, vcl::Window* right )
{ {
return left != right && right->IsChild( left, true ); return left != right && right->IsChild( left, true );
} }
......
...@@ -578,7 +578,7 @@ void Window::dispose() ...@@ -578,7 +578,7 @@ void Window::dispose()
Window::~Window() Window::~Window()
{ {
// FIXME: we should kill all LazyDeletor usage. // FIXME: we should kill all LazyDeletor usage.
vcl::LazyDeletor<vcl::Window>::Undelete( this ); vcl::LazyDeletor::Undelete( this );
disposeOnce(); disposeOnce();
} }
...@@ -1892,7 +1892,7 @@ void Window::doLazyDelete() ...@@ -1892,7 +1892,7 @@ void Window::doLazyDelete()
Show( false ); Show( false );
SetParent( ImplGetDefaultWindow() ); SetParent( ImplGetDefaultWindow() );
} }
vcl::LazyDeletor<vcl::Window>::Delete( this ); vcl::LazyDeletor::Delete( this );
} }
KeyIndicatorState Window::GetIndicatorState() const KeyIndicatorState Window::GetIndicatorState() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment