Help with Macintosh programming

macintosh programming, mac programming, mac os programming, mac os x programming, mac programming language, mac programing

Strange compiler problem

I am having a really weird problem. I am using PowerPlant and CW Pro 8.3 ( I
have 9 bit I don’t have the time to update to it yet)

I have an app that has an assistant window that helps users do some specific
tasks. This assistant window and different panes are all C++ based. Mainly
off of PowerPlant classes. What is happening in one of the pane classes in
the assistant window is that when I call my function to start the panel (
set up the panel correctly) it is jumping to a different class and different
method name within that class. Here is what I mean:

void
CXOBrowserCacheRemovalAssistantWindow::FinishCreateSelf()
{

// now get the panel items
    mCurrentPanel = (CXOAssitantView*) (mMultiPanleView->GetCurrentPanel());
    ThrowIfNil_( mCurrentPanel );

    mCurrentPanelIndex = mMultiPanleView->GetCurrentIndex();

    mCurrentPanel->SetWindowObject( this );

    mCurrentPanel->StartPanel();        <—– code jumps to wrong place

    MoveWindowTo( kCXOAssistantWindow_HorizStartPos,
                    kCXOAssistantWindow_VertStartPos);

}

So in the above code :

    mCurrentPanel->StartPanel();

It should jump to my class CXOBrowserCacheRemovalSelectPanel and class
method StartPanel():

CXOBrowserCacheRemovalSelectPanel::StartPanel();

Because that is the type that this panel is, but for some reason it is
jumping to

LPane*
LPane::FindPaneByID(
    PaneIDT    inPaneID)
{
    return (inPaneID == mPaneID) ? this : nil;

}

And not too the method that it should. The class
CXOBrowserCacheRemovalSelectPanel is based on LView which is based on LPane.
Here is the class hierarchy for CXOBrowserCacheRemovalSelectPanel

CXOBrowserCacheRemovalSelectPanel
CXOBrowserCacheRemovalAssitantView
CXOAssitantView
LView
LPane

The really weird thing is that it works fine in several other assistant
views that I have already. For the life of me I can not figure out why this
is doing this. I have recompiled the whole program, I have even tried
changing the name of this method just for this class and calling it directly
but that still jumps to the wrong place.

Has anyone else ever seen this? I have CW Pro 9, but have not ventured to
use it yet, because I don’t want a bunch of errors cropping up and having to
fix compile errors right at the moment. But I guess I am going to have to
give that a try. Does anyone else have any suggestions?

Thanks,
Scott Mitchell

.
posted by admin in Uncategorized and have Comments (3)

3 Responses to “Strange compiler problem”

  1. admin says:

    In article <BC0C6BCE.237F%scott.marymi…@verizon.net>,
     Scott Mitchell <scott.marymi…@verizon.net> wrote:

    - Hide quoted text — Show quoted text -

    > void
    > CXOBrowserCacheRemovalAssistantWindow::FinishCreateSelf()
    > {
    > …

    > // now get the panel items
    >     mCurrentPanel = (CXOAssitantView*) (mMultiPanleView->GetCurrentPanel());
    >     ThrowIfNil_( mCurrentPanel );

    >     mCurrentPanelIndex = mMultiPanleView->GetCurrentIndex();

    >     mCurrentPanel->SetWindowObject( this );

    >     mCurrentPanel->StartPanel();        <—– code jumps to wrong place

    >     MoveWindowTo( kCXOAssistantWindow_HorizStartPos,
    >                     kCXOAssistantWindow_VertStartPos);

    > }

    > It should jump to my class CXOBrowserCacheRemovalSelectPanel and class
    > method StartPanel():

    > CXOBrowserCacheRemovalSelectPanel::StartPanel();

    > Because that is the type that this panel is, but for some reason it is
    > jumping to

    > LPane*
    > LPane::FindPaneByID(
    >     PaneIDT    inPaneID)

    It looks to me as though the pointer you are getting back from
    GetCurrentPanel() is not in fact to a CXOAssitantView.  Try replacing
    the C-style cast with a dynamic one:

    mCurrentPanel =
    dynamic_cast<CXOAssitantView*>(mMultiPanelView->GetCurrentPanel());

    It should then either work correctly or squeal at the ThrowIfNil_.

    > Here is the class hierarchy for CXOBrowserCacheRemovalSelectPanel

    > CXOBrowserCacheRemovalSelectPanel
    > CXOBrowserCacheRemovalAssitantView
    > CXOAssitantView
    > LView
    > LPane

    There are no other "mix-in" bases?  Multiple inheritance might cause a C
    cast to give you a pointer to the wrong part of the object, consistent
    with the symptoms you describe.

    Best wishes,
    Matthew Collett


    Those who assert that the mathematical sciences have nothing to say
    about the good or the beautiful are mistaken.          – Aristotle

  2. admin says:

    - Hide quoted text — Show quoted text -

    Matthew Collett <m.coll…@auckland.ac.nz> wrote in message <news:m.collett-B39177.08480423122003@lust.ihug.co.nz>…

    > >     mCurrentPanel->StartPanel();        <—– code jumps to wrong place

    > >     MoveWindowTo( kCXOAssistantWindow_HorizStartPos,
    > >                     kCXOAssistantWindow_VertStartPos);

    > > }

    > > It should jump to my class CXOBrowserCacheRemovalSelectPanel and class
    > > method StartPanel():

    > > CXOBrowserCacheRemovalSelectPanel::StartPanel();

    > > Because that is the type that this panel is, but for some reason it is
    > > jumping to

    > > LPane*
    > > LPane::FindPaneByID(
    > >     PaneIDT    inPaneID)

    > It looks to me as though the pointer you are getting back from
    > GetCurrentPanel() is not in fact to a CXOAssitantView.  Try replacing
    > the C-style cast with a dynamic one:

    Also, make sure you have all compiler inlining and optimizations turned off.

  3. admin says:

    On 12/22/03 11:48 AM, in article
    m.collett-B39177.08480423122…@lust.ihug.co.nz, "Matthew Collett"

    - Hide quoted text — Show quoted text -

    <m.coll…@auckland.ac.nz> wrote:
    > In article <BC0C6BCE.237F%scott.marymi…@verizon.net>,
    > Scott Mitchell <scott.marymi…@verizon.net> wrote:

    >> void
    >> CXOBrowserCacheRemovalAssistantWindow::FinishCreateSelf()
    >> {
    >> …

    >> // now get the panel items
    >>     mCurrentPanel = (CXOAssitantView*) (mMultiPanleView->GetCurrentPanel());
    >>     ThrowIfNil_( mCurrentPanel );

    >>     mCurrentPanelIndex = mMultiPanleView->GetCurrentIndex();

    >>     mCurrentPanel->SetWindowObject( this );

    >>     mCurrentPanel->StartPanel();        <—– code jumps to wrong place

    >>     MoveWindowTo( kCXOAssistantWindow_HorizStartPos,
    >>                     kCXOAssistantWindow_VertStartPos);

    >> }

    >> It should jump to my class CXOBrowserCacheRemovalSelectPanel and class
    >> method StartPanel():

    >> CXOBrowserCacheRemovalSelectPanel::StartPanel();

    >> Because that is the type that this panel is, but for some reason it is
    >> jumping to

    >> LPane*
    >> LPane::FindPaneByID(
    >>     PaneIDT    inPaneID)

    > It looks to me as though the pointer you are getting back from
    > GetCurrentPanel() is not in fact to a CXOAssitantView.  Try replacing
    > the C-style cast with a dynamic one:

    > mCurrentPanel =
    > dynamic_cast<CXOAssitantView*>(mMultiPanelView->GetCurrentPanel());

    > It should then either work correctly or squeal at the ThrowIfNil_.

    Well you where right. The problem was somehow, my ClassID in my PPob, got
    messed up, and was completely wrong. So it was not even registering this
    Class. Once I fixed it, it worked fine. I should have checked that first.
    Sorry for the use of the bandwidth.

    >> Here is the class hierarchy for CXOBrowserCacheRemovalSelectPanel

    >> CXOBrowserCacheRemovalSelectPanel
    >> CXOBrowserCacheRemovalAssitantView
    >> CXOAssitantView
    >> LView
    >> LPane

    > There are no other "mix-in" bases?  Multiple inheritance might cause a C
    > cast to give you a pointer to the wrong part of the object, consistent
    > with the symptoms you describe.

    > Best wishes,
    > Matthew Collett

    Thanks,
    Scott Mitchell