Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / December 2003



Tip: Looking for answers? Try searching our database.

Strange compiler problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Scott Mitchell - 22 Dec 2003 17:37 GMT
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
Matthew Collett - 22 Dec 2003 19:48 GMT
> void
> CXOBrowserCacheRemovalAssistantWindow::FinishCreateSelf()
[quoted text clipped - 27 lines]
> 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
>
[quoted text clipped - 3 lines]
> 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

Signature

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

Lally Singh - 23 Dec 2003 02:01 GMT
> >     mCurrentPanel->StartPanel();        <----- code jumps to wrong place
> >    
[quoted text clipped - 18 lines]
> 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.
Scott Mitchell - 23 Dec 2003 04:31 GMT
On 12/22/03 11:48 AM, in article
m.collett-B39177.08480423122003@lust.ihug.co.nz, "Matthew Collett"
<m.collett@auckland.ac.nz> wrote:

>> void
>> CXOBrowserCacheRemovalAssistantWindow::FinishCreateSelf()
[quoted text clipped - 36 lines]
>
> 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
>>
[quoted text clipped - 10 lines]
> Best wishes,
> Matthew Collett

Thanks,
Scott Mitchell
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.