SNHookClass::Register and C4D Exit Crash!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/09/2006 at 17:05, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   9.102 
    Platform:   Windows  ;   Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    This is an urgent problem!

    This is the full code of my main.cpp (minus stuff that wouldn't be good out in public).

    Here's the situation: Only if the user does not run my plugin (or the dialog isn't restored in the layout during startup), C4D is guaranteed to crash on exit Windows/MacOS R8.2-R9.6 confirmed.

    I've narrowed this down to one line (marked below) : the SNHookClass::Register() method. Could it be that the plugin_id in Register() must be different that the main plugin id (doesn't seem to make a difference)? If you see anything that seems out of place otherwise, please do not hesitate to mention it as well.

    // Includes  
    #include "c4d.h"  
    #include "lib_sn.h"  
    #include "general.h"  
      
    // IPPSerial: Serial Number Hook Class  
    class IPPSerial : public SNHookClass  
    {  
         private:  
              // Data  
              String               SNPluginName;  
              // Methods  
              // - IPPSerial.checkSerial  
              //*---------------------------------------------------------------------------*  
              bool               checkSerial(const String& c4dsn, const String& sn)  
              //*---------------------------------------------------------------------------*  
              {  
                   // Code removed for obvious reasons  
      
                   return true;  
              }  
         public:  
              // Data  
              bool               registered;  
              UCHAR               mode;  
              UCHAR               time;  
              // Methods  
              // - Constructor  
              //*---------------------------------------------------------------------------*  
              IPPSerial()  
              //*---------------------------------------------------------------------------*  
              {  
                   registered = false;  
                   SNPluginName = GeLoadString(IPPS_PLUGIN_NAME)+" "+GeLoadString(IPPS_PLUGIN_EDITION);  
              }  
              // - SNHookClass.SNCheck  
              //*---------------------------------------------------------------------------*  
              LONG               SNCheck(const String& c4dsn, const String& sn, LONG regdate, LONG curdate)  
              //*---------------------------------------------------------------------------*  
              {  
                   if (!regdate && !sn.Content())               return SN_WRONGNUMBER;  
      
                   // Code removed for obvious reasons!!  
      
                   return SN_WRONGNUMBER;  
              }  
              // - SNHookClass.GetTitle  
              //*---------------------------------------------------------------------------*  
              const String&     GetTitle()  
              //*---------------------------------------------------------------------------*  
              {  
                   return SNPluginName;  
              }  
    } *ippSerial = NULL;  
      
      
    // Plugin Functions ==================================================================================================  
      
    #include "interPoserPro.h"  
      
    // Declare Global Plugin Registrants  
    interPoserPro* RegisterInterPoserProCommand();  
    Bool RegisterIPPBase();  
    Bool RegisterIPPFigureTag();  
    Bool RegisterIPPObjectTag();  
    Bool RegisterIPPDialTag();  
    Bool RegisterIPPJointTag();  
    Bool RegisterC4DFigureTag();  
    Bool RegisterIPPTool();  
      
    //*---------------------------------------------------------------------------*  
    Bool PluginStart()  
    //*---------------------------------------------------------------------------*  
    {  
         BOOL     network;  
         LONG     vtype = GeGetVersionType();  
         if ((vtype & VERSION_SERVER) || (vtype & VERSION_NET))     network = TRUE;  
         else                                                                 network = FALSE;  
         if (!((vtype & VERSION_DEMO) || network))  
         {  
              // serial number check  
              if (!(ippSerial && ippSerial->registered)) return FALSE;  
         }  
      
         GePrint(" ");  
         GePrint(GeLoadString(IPPS_PLUGIN_BANNER));  
         GePrint("-- "+GeLoadString(IPPS_PLUGIN_NAME)+" "+GeLoadString(IPPS_PLUGIN_EDITION)+" v"+GeLoadString(IPPS_PLUGIN_VERSION)+" "+GeLoadString(IPPS_PLUGIN_COPYRIGHT));  
         GePrint(GeLoadString(IPPS_PLUGIN_BANNER));  
         GePrint(" ");  
      
         // register hooks and return  
         interPoserPro* ipp =          RegisterInterPoserProCommand();  
         if (!ipp)                         return FALSE;  
         if (ippSerial && !network)     ipp->SetDemoInfo(ippSerial->mode, ippSerial->time);  
         return RegisterIPPFigureTag() && RegisterIPPObjectTag() && RegisterIPPBase() && RegisterIPPDialTag() && RegisterIPPJointTag() && RegisterC4DFigureTag() && RegisterIPPTool();  
    }  
      
    //*---------------------------------------------------------------------------*  
    void PluginEnd()  
    //*---------------------------------------------------------------------------*  
    {  
         gDelete(ippSerial);  
    }  
      
    //*---------------------------------------------------------------------------*  
    Bool PluginMessage(LONG id, void* data)  
    //*---------------------------------------------------------------------------*  
    {  
         if          (id == C4DPL_INIT_SYS)  
         {  
              // initialize global resource object  
              if (!resource.Init())     return FALSE;  
      
              // initialize and register Serial Number Hook  
              LONG vtype = GeGetVersionType();  
              if ((vtype & VERSION_SERVER) || (vtype & VERSION_NET))     return TRUE;  
              ippSerial =     gNew IPPSerial();  
              if (!ippSerial)     return FALSE;  
              // THIS CRASHES C4D ON EXIT  
              return ippSerial->Register(ID_INTERPOSERPRO, SNFLAG_OWN);  
              // ************************  
              //return TRUE;  
         }  
         else if (id == C4DMSG_PRIORITY)          return TRUE;  
         return FALSE;  
    }
    

    Thank you,



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/09/2006 at 22:45, xxxxxxxx wrote:

    After all of that, I traced the problem to the instantiation of the main dialog. If it is only done in CommandData::Execute() and CommandData::RestoreLayout(), then the crash-on-exit disappears.


Log in to reply