GCCe(release) 编译的时候出现的问题(转)

GCCe(release) 编译的时候出现的问题

发布: 2010-4-15 17:47 | 作者: fys85 | 来源: DevDiv 移动开发社区

在模拟器环境先编译的时候没有错误,换到GCCE (release )的时候出现了
note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.[..//..//..//Symbian//9.1//S60_3rd_MR//EPOC32//include/e32base.inl]
不知道这样的错误是怎么回事?怎么解决?请高手帮忙!
2010-4-15 17:57:09
代码传上来看看
2010-4-15 19:20:43
//CustomTabControl.h

#ifndef ___CUSTOMTABCONTROL_H__
#define ___CUSTOMTABCONTROL_H__
#include <coecntrl.h>
#include <AknsDrawUtils.h>// skin
#include <AknsBasicBackgroundControlContext.h> //skin
#include <AknsSkinInstance.h>

// FORWARD DECLARATIONS
class CGulIcon;

/////////////////////////////////////////////////////////////////////////////////////////////////

// custom tab control
/////////////////////////////////////////////////////////////////////////////////////////////////

typedef enum
{
  SHIFT_LEFT=0,
  SHIFT_RIGHT
} SHIFT_DIR;


class CCustomTabControl: public CCoeControl, MCoeControlObserver
{
public:

    static CCustomTabControl* NewL(const TRect& aRect,const CCoeControl* aParent);
    ~CCustomTabControl();
        TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
        void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);

    CCustomTabControl(const TRect& aRect):iRect(aRect),iCreated(EFalse)
    {
    }

        TTypeUid::Ptr MopSupplyObject(TTypeUid aId);

        void Draw(const TRect& aRect) const;
        
        void SetFocusedBackgroundImage(CFbsBitmap* aBackgroundImage) // takes the ownership
        {
                iFocusedBackgroundImage=aBackgroundImage;
        }
        void SetDeFocusedBackgroundImage(CFbsBitmap* aBackgroundImage) // takes the ownership
        {
                iDeFocusedBackgroundImage=aBackgroundImage;
        }

        TInt ActiveTabIndex()
        {
                return iActiveTabIndex;
        }

    void SetDefaultTabByIndex(TInt aIndex);        

        void SetIconArray(CArrayPtr<CGulIcon>*         aIconArray) // takes the ownership
        {
                if(iIconArray != NULL)
                {
                        iIconArray->ResetAndDestroy();
                }
                iIconArray=aIconArray;
        }

        void SetTabTitleArray(CDesCArrayFlat* aTabTitleArray)// takes the ownership
        {
                if(iTabTitleArray != NULL)
                {
                        iTabTitleArray->Reset();
                }
                iTabTitleArray=aTabTitleArray;
        }

        void SetNumberOfTabsToBeShown(TInt aCount)
        {
                //if(aCount>0)
                //        iNumberOfTabsToBeShown=aCount;
        }

        void SetFocus(TBool aFocus)
        {
                iFocused=aFocus;
                DrawDeferred();
        }

        TBool IsFocused()
        {
                return iFocused;
        }
        void MakeVisible(TBool aVisible)
        {
                iVisible=aVisible;
                CCoeControl::MakeVisible(aVisible);
        }
        TBool IsVisible()
        {
                return iVisible;
        }
        
        TInt TabCount()        
        {
                if(iIconArray)
                        return iIconArray->Count();
                else
                        return 0;
        }
        
        TInt TabIdFromIndex(TInt aIndex)
        {
                return aIndex;
        }
        void ShiftTabsBack();
private:
    void ConstructL(const TRect& aRect,const CCoeControl* aParent);
    void ShiftTabs(SHIFT_DIR aDir);
    static TInt Period(TAny* aPtr);

private:
        MAknsControlContext*         iBackGround;
        TRect                                        iRect;
        //CFbsBitmap*                     iBackgroundImage;
        
        CFbsBitmap*                     iFocusedBackgroundImage;
        CFbsBitmap*                     iDeFocusedBackgroundImage;

        TInt                                        iActiveTabIndex; // Currently active tab
        TInt                                        iActiveTabPosition; // Position of the active tab; currently assumed to be 2
        CArrayPtr<CGulIcon>*         iIconArray;
        CDesCArrayFlat*                 iTabTitleArray;
        TInt                                        iNumberOfTabsToBeShown;
        TBool                                          iFocused;
        TBool                                          iVisible;
        CPeriodic*  iPeriodicTimer; 
        TBool                                         iCreated;
        
};

#endif ___CUSTOMTABCONTROL_H__
2010-4-15 19:21:12
回复 2# Vincent 


    ///////CustomTabControl.cpp


////////////////////////////////////////////////////////////////////////////////////////////////

// custom tab control
/////////////////////////////////////////////////////////////////////////////////////////////////
#include <gulicon.h>
#include <eikenv.h>
#include <AknAppUi.h>
//#include "Uishow.mbg"
#include "CustomTabControl.h"

_LIT(KTitle,"testTitle");
CCustomTabControl* CCustomTabControl::NewL(const TRect& aRect,const CCoeControl* aParent)
{
    CCustomTabControl* self = new(ELeave) CCustomTabControl(aRect);
    CleanupStack::PushL(self);
    self->ConstructL(aRect,aParent);
    CleanupStack::Pop(); // self
    return self;
}

CCustomTabControl::~CCustomTabControl()
{
    if(iBackGround)
    {
        delete iBackGround;
        iBackGround = NULL;
    }
    if(iFocusedBackgroundImage)
    {
            delete iFocusedBackgroundImage;
            iFocusedBackgroundImage=NULL;
    }
    if(iDeFocusedBackgroundImage)
    {
            delete iDeFocusedBackgroundImage;
            iDeFocusedBackgroundImage=NULL;
    }
    if(iIconArray)
    {
            iIconArray->ResetAndDestroy();
    }
    if(iTabTitleArray)
    {
            iTabTitleArray->Reset();
    }
    
    if(iPeriodicTimer != NULL)           
           {
            iPeriodicTimer->Cancel();
           }  
       delete iPeriodicTimer;
       
       if( iCreated )
               iAvkonAppUi->RemoveFromStack( this);
}

void CCustomTabControl::ConstructL(const TRect& aRect,const CCoeControl* aParent)
{
        iFocusedBackgroundImage=NULL;
        iDeFocusedBackgroundImage=NULL;
        iIconArray=NULL;
        iTabTitleArray=NULL;
        //iNumberOfTabsToBeShown=5;
        iNumberOfTabsToBeShown=4;
        iActiveTabPosition=2;
        iActiveTabIndex=2;
        if (aParent == NULL)
        {
                CreateWindowL();
                iAvkonAppUi->AddToStackL( this);
                iCreated = ETrue;
        }
    else
    {
            // Part of a compound control, so just share
            // the parent's window
            SetContainerWindowL(*aParent);
    }
        SetRect(aRect);
    iBackGround = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, iRect, EFalse );
    SetRect(aRect);
    ActivateL();
    
    iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard);
    iPeriodicTimer->Start(0*1000,1000*500,TCallBack(CCustomTabControl::Period,this));

}

TInt CCustomTabControl::Period(TAny* aPtr)
        {
        ((CCustomTabControl*)aPtr)->DrawDeferred();
                return ETrue;
        }


TTypeUid::Ptr CCustomTabControl::MopSupplyObject(TTypeUid aId)
{
    if(aId.iUid == MAknsControlContext::ETypeId && iBackGround)
       {
        return MAknsControlContext::SupplyMopObject( aId, iBackGround);
       }
    return CCoeControl::MopSupplyObject( aId );
}

void CCustomTabControl::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}

void CCustomTabControl::ShiftTabsBack()
{
        if(iActiveTabIndex>0)
        {
                iActiveTabIndex--;
        }

        else
        {
                iActiveTabIndex=iIconArray->Count()-1;
        }

        ShiftTabs(SHIFT_LEFT);
        DrawNow();
}

TKeyResponse CCustomTabControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
        //KN_UI_LOG((KN_UI_LOG_TYPE_DEBUG,"CCustomTabControl::OfferKeyEventL\n"));

        TKeyResponse ret=EKeyWasNotConsumed;
        if(IsFocused() && EEventKeyUp == aType)
        {
                switch (aKeyEvent.iScanCode)
                {
                        case EStdKeyLeftArrow:
                        {
                                if(iActiveTabIndex>0)
                                        iActiveTabIndex--;
                                else
                                        iActiveTabIndex=iIconArray->Count()-1;
                                ShiftTabs(SHIFT_LEFT);
                                DrawNow();
                                ret=EKeyWasConsumed;
                        }
                        break;
                        case EStdKeyRightArrow:
                        {
                                if(iActiveTabIndex<iIconArray->Count()-1)
                                        iActiveTabIndex++;
                                else
                                        iActiveTabIndex=0;
                                ShiftTabs(SHIFT_RIGHT);
                                DrawNow();
                                ret=EKeyWasConsumed;
                        }
                        break;
                        default:
                        break;
                }
        }
        //this->DrawDeferred();//JASON TEST
    return ret;
}

void CCustomTabControl::ShiftTabs(SHIFT_DIR aDir)
{
        if(iIconArray && iIconArray->Count()>0)
        {
                CGulIcon* icon=NULL;
                if(aDir==SHIFT_RIGHT)
                {
                        icon=iIconArray->At(0);
                        iIconArray->Delete(0);
                        iIconArray->Compress();
                        if(icon)
                                iIconArray->AppendL(icon);
                }
                else
                {
                        icon=iIconArray->At(iIconArray->Count()-1);
                        iIconArray->Delete(iIconArray->Count()-1);
                        iIconArray->Compress();
                        if(icon)
                                iIconArray->InsertL(0,icon);
                }
        }
}

void CCustomTabControl::SetDefaultTabByIndex(TInt aIndex)
{
        if(aIndex>=0 && aIndex<iActiveTabPosition) 
        {
                for(TInt i=0;i<iActiveTabPosition-aIndex;i++)
                {
                        ShiftTabs(SHIFT_LEFT);
                }
        }
        if(aIndex>iActiveTabPosition && aIndex<iIconArray->Count())
        {
                for(TInt i=0;i<aIndex-iActiveTabPosition;i++)
                {
                        ShiftTabs(SHIFT_RIGHT);
                }
        }
        if(iIconArray && aIndex>=0 && aIndex<iIconArray->Count())
        {
                iActiveTabIndex=aIndex;
                DrawNow();
        }
}
void CCustomTabControl::Draw(const TRect& aRect) const
{
        CWindowGc& gc = SystemGc();
        //TRect aRect(aaRect);
        //aRect.iTl.iX=0;
        //aRect.iTl.iY=0;
        gc.Clear(aRect);
        gc.SetPenStyle(CGraphicsContext::ESolidPen);
        TSize pensize(2,2);
        gc.SetPenSize(pensize);
        gc.SetPenColor(KRgbBlack);
        gc.SetBrushStyle(CGraphicsContext::ENullBrush);
        gc.DrawRect(aRect);
        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
        MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
        AknsDrawUtils::Background( skin, cc, this, gc, aRect );
/*        if(iFocused)
        {
                if(iFocusedBackgroundImage)
                {                
                        gc.DrawBitmap(aRect, iFocusedBackgroundImage);
                }
        }
        else
        {*/
                if(iDeFocusedBackgroundImage)
                {                
                        gc.DrawBitmap(aRect, iDeFocusedBackgroundImage);
                }
//        }*/

        if(iIconArray && iIconArray->Count()>0 && iNumberOfTabsToBeShown>0
                && iNumberOfTabsToBeShown<=iIconArray->Count())
        {
                TInt tabWidth=aRect.Width()/iNumberOfTabsToBeShown;
                TSize tabSize(tabWidth,aRect.Height());
                TRect tabRect(tabSize);
                tabRect.Shrink(4,4);
                tabRect.iTl.iY-=3;
                tabRect.iBr.iY-=3;
                TInt dX=tabRect.Width()+3;

                #ifdef __UI_FRAMEWORKS_V2
                dX=tabRect.Width()+5;
                #endif

                for(TInt i=0;i<iNumberOfTabsToBeShown;i++)
                {
                        CFbsBitmap* tab=NULL;
                        CGulIcon* icon=NULL;
                        if(i<iIconArray->Count())
                                icon = iIconArray->At(i);
                        if(icon)
                                tab = icon->Bitmap();
                        // to adjust the middle tab (middle tab is bigger than other tabs)
                        if(i==2)
                        {

                #ifdef __UI_FRAMEWORKS_V2
                                tabRect.iTl.iX+=5;
                                tabRect.iBr.iX+=5;
                #else

                                tabRect.iTl.iX+=9;
                                tabRect.iBr.iX+=9;
                #endif
                        }
                        if(tab)
                        {
                                TRect rect;
                                rect.iTl.iX=0;
                                rect.iTl.iY=0;
                                rect.iBr.iX=tabRect.Width();
                                rect.iBr.iY=tabRect.Height();
                                if( i==2 )
                                {
                                        TRgb KTabSelectedColor(142,163,184);
                                        gc.SetPenColor( KTabSelectedColor );
                                        gc.SetPenStyle(CGraphicsContext::ESolidPen);
                                        gc.SetPenSize(TSize(1,1));
                                        gc.SetBrushColor( KTabSelectedColor );
                                        gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
                                        TRect aRect(tabRect.iTl,tabRect.iBr);
                                        gc.DrawRoundRect(aRect,TSize(3,3));        
                                        
                                        gc.SetPenColor(KRgbBlack);
                                        const CFont* font = CEikonEnv::Static()->LegendFont();
                                        gc.UseFont(font);
                                        gc.DrawText(KTitle,aRect,aRect.iTl.iY+30 , CGraphicsContext::ECenter, 1);
                                        gc.DiscardFont();
                                }
                                gc.BitBltMasked(tabRect.iTl,tab,rect,icon->Mask(),EFalse);
                                        
                        //}
                        
                        
                
                        }
                        tabRect.iTl.iX+=dX;
                        tabRect.iBr.iX+=dX;
                        // to adjust the middle tab (middle tab is bigger than other tabs)
                        if(i==2)
                        {
                                tabRect.iTl.iX+=10;
                                tabRect.iBr.iX+=10;
                        }
                        
                }
        }

        /*if(iTabTitleArray && iTabTitleArray->Count()>0 && iActiveTabIndex>=0
                && iActiveTabIndex<iTabTitleArray->Count())
        {
                gc.SetPenStyle(CGraphicsContext::ESolidPen);
                //gc.SetPenColor(KRgbWhite);//test
                gc.SetPenColor(KRgbBlack);
                const CFont* font = CEikonEnv::Static()->LegendFont();
                gc.UseFont(font);
                TRect textRect(aRect);
                TInt baseline =        textRect.iBr.iY - 5;
                TBuf<200> titleText;
                titleText.FillZ();
                titleText.Copy(iTabTitleArray->MdcaPoint(iActiveTabIndex));
                gc.DrawText(titleText,textRect, baseline, CGraphicsContext::ECenter, 1);
        }*/

}

上面是写好的一个TAB控件,在一个VIEW里面NEW 一个控件的对象,在GCCE(release)环境下编译就可以看到编译的错误了,很是不解...
2010-4-15 19:23:04
测试的程序已经写好,请高手帮忙。

jason.zip
(2010-04-15 19:22:36, Size: 62.7 KB, Downloads: 2)

2010-4-15 20:03:07
好长的代码呀。
2010-4-16 10:22:04
问题查到了。出现在
     void SetIconArray(CArrayPtr<CGulIcon>*         aIconArray) // takes the ownership
        {
                if(iIconArray != NULL)
                {
                        iIconArray->ResetAndDestroy();
                }
                iIconArray=aIconArray;
        }这个函数的IconArray->ResetAndDestroy();这一句
2010-4-16 10:43:53
这一句什么问题啊?
2010-4-16 10:58:55
模拟器编译的过去,但是在GCCE( release )下就是编译不过去,本人认为这个也没有什么问题,但就是注释掉(或者改为 iIconArray->Reset() )以后编译的过去,不做任何修改就是编译不过。请高手指导
2010-4-16 11:05:41
测试的程序放在了上面的附件里面,请高手指导。。
2010-6-07 15:06:39
老大,你的问题太犀利了~~~你是怎么想到把ResetAndDestroy改为Reset,从而能成功编译的呢?
2010-6-07 15:35:54
模拟器编译没问题,真机编译有问题,可以试试这个方法    
http://sluttery.spaces.live.com/ ... C717FD4!5046.entry:
Symbian 编译的诡异问题出得多了之后,我找到一个成功概率极其高的解决办法:把 SDK 的 epoc32 目录下的 BUILD 目录整个删除,然后再编译,十有八九可以搞定。
原文地址:https://www.cnblogs.com/yaoliang11/p/1858971.html