The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Vista CRT Exception problem

In the following code fragment a bad_typeid was thrown in all versions of Windows prior to Vista. In Vista I'm picking up the ... unhandled exception. The pWnd in this case doesn't have RTTI info, so the exception is expected.

I can't find any info (so far) on MSDN that anything has changed with the typeid operator. And anyway I'm using the same MFC/VC6 libraries I use on XP etc.

This is happening in a release build. I'm reasonably sure I'm getting bad_typeid in a DEBUG Build.

Any thoughts?

--------

/** Returns true if the specified pWnd is a CSGTreeCtrl
 */
bool
CMainFrame::IsSGTreeCtrl( CWnd* pWnd ) const
{
bool bStat = false;

    // If the spec'd pWnd is for a class that hasn't been compiled
    // with C++ RTTI we'll get an exception, hence the try/catch.
    // The Stingray Color Selector is such a class. 8 Oct 2001
    try
    {
        if ( pWnd && ::IsWindow( pWnd->m_hWnd ) )  // 20 Feb 2007
            if ( typeid( *pWnd ) == typeid( CSGTreeCtrl ) )
                bStat = true;
    }
    catch( __non_rtti_object )
    {
        TRACE( "In CMainFrame::IsSGTreeCtrl() and __non_rtti_object exception raised." );
    }
    catch( bad_typeid )  // On WinXP and earlier we get bad_typeid
    {
        TRACE( "In CMainFrame::IsSGTreeCtrl() and bad_typeid exception raised." );
    }
    catch( bad_cast )
    {
        TRACE( "In CMainFrame::IsSGTreeCtrl() and bad_cast exception raised." );
    }
    catch( exception& e )
    {
        TRACE( "Exception in CMainFrame::IsSGTreeCtrl() %s\n", e.what() );
    }
    catch( ... )  // On Vista we don't get bad_typeid, we arrive here!! 20 Feb 2007
    {
        TRACE( "UnHandled Exception in CMainFrame::IsSGTreeCtrl()\n"  );
    }
    return bStat;
}

---
Neville Franks Send private email
Monday, February 19, 2007
 
 
Not exactly an answer but... did you try to remove catch(...) block and set your Debug->Exceptions in Visual Studio IDE to 'break' (into debugger)?

At least you should be able to see what kind of exception gets thrown.

Tuesday, February 20, 2007
 
 
Thanks but I'm running Vista in VMWare and don't have Visual Studio installed in Vista.
Neville Franks Send private email
Tuesday, February 20, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz