gssettingsuis/Gs/GSFramework/inc/GSPluginWrapper.h
branchGCC_SURGE
changeset 45 f48d04161a92
parent 27 572294aa6075
parent 43 3341fe7c643a
equal deleted inserted replaced
27:572294aa6075 45:f48d04161a92
     1 /*
       
     2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef GSPLUGINWRAPPER_H
       
    20 #define GSPLUGINWRAPPER_H
       
    21 
       
    22 // System includes
       
    23 #include <e32base.h>
       
    24 
       
    25 // Classes referenced
       
    26 class CGSBaseDocument;
       
    27 
       
    28 
       
    29 /**
       
    30  *  Utility class for separating ECOM plugin destruction from view-framework
       
    31  *  view cleanup.
       
    32  *
       
    33  *  Owned by CGSBaseDocument which has the longest lifetime during GS
       
    34  *  application run. This will ensure that ECOM resources are not deleted
       
    35  *  before view cleanup.
       
    36  *
       
    37  *  Problem/rationale:
       
    38  *  Before the functionality provided by this class, GS would occasionally
       
    39  *  crash in exit. This was caused by the dual nature of CGSPluginInterface
       
    40  *  class: It is both ECOM-plugin having individual dll and view-framework
       
    41  *  dependant CAknView owned by CCoeAppUi. When exiting GS, it was possible
       
    42  *  that a  plugin still had local views (CAknViews) which were owned
       
    43  *  by view-framework.
       
    44  *
       
    45  *  When the view framework destroys the registered views, it would cause
       
    46  *  the ECOM plugin dll to be unloaded. Should this happen before all the views
       
    47  *  owned and implemented by the plugin have been destroyed, an access
       
    48  *  violation would occur because the code needed to call the view's destructor
       
    49  *  was no longer loaded into memory within the GS process.
       
    50  *
       
    51  *  Solution:
       
    52  *  Purpose of CGSPluginWrapper is to move ECOM-related memory cleanup outside
       
    53  *  the scope of CGSPluginInterface destructor. This way view-framework can
       
    54  *  call destructor in an arbitrary order on all it's owned views even though
       
    55  *  plugins which had local views were already deleted.
       
    56  *
       
    57  */
       
    58 NONSHARABLE_CLASS( CGSPluginWrapper ) : public CBase
       
    59     {
       
    60     public:
       
    61         CGSPluginWrapper( CGSBaseDocument& aDocument );
       
    62         IMPORT_C ~CGSPluginWrapper();
       
    63 
       
    64     public:
       
    65         IMPORT_C void SetDetails( TUid aDestructorIdKey );
       
    66         inline CGSBaseDocument& Document() { return iDocument; }
       
    67 
       
    68     private:
       
    69         TUid iDestructorIdKey;
       
    70         CGSBaseDocument& iDocument;
       
    71     };
       
    72 
       
    73 
       
    74 
       
    75 
       
    76 #endif // GSPLUGINWRAPPER_H
       
    77 // End of File