Ticket #846: CJSObject_memleak_fixes.patch

File CJSObject_memleak_fixes.patch, 4.7 KB (added by historic_bruno, 11 years ago)

Alternate solution that calls ScriptingShutdown explicitly

  • source/graphics/GameView.cpp

     
    205205    {
    206206    }
    207207
     208    ~CGameViewImpl();
     209
    208210    CGame* Game;
    209211    CColladaManager ColladaManager;
    210212    CMeshManager MeshManager;
     
    412414    CJSObject<CGameViewImpl>::ScriptingInit("GameView");
    413415}
    414416
     417CGameViewImpl::~CGameViewImpl()
     418{
     419    CJSObject<CGameViewImpl>::ScriptingShutdown();
     420}
     421
    415422int CGameView::Initialize()
    416423{
    417424    CFG_GET_VAL("view.scroll.speed", Float, m->ViewScrollSpeed);
  • source/renderer/Renderer.cpp

     
    501501{
    502502    UnregisterFileReloadFunc(ReloadChangedFileCB, this);
    503503
     504    CJSObject<CRenderer>::ScriptingShutdown();
     505
    504506    // we no longer UnloadAlphaMaps / UnloadWaterTextures here -
    505507    // that is the responsibility of the module that asked for
    506508    // them to be loaded (i.e. CGameView).
  • source/scripting/ScriptableObject.h

     
    249249        g_ScriptingHost.DefineCustomObjectType( &JSI_class, Constructor, ConstructorMinArgs, JSI_props, JSI_methods, NULL, NULL );
    250250
    251251        delete[]( JSI_methods );
    252 
    253         atexit( ScriptingShutdown );
    254252    }
    255253    static void ScriptingShutdown()
    256254    {
  • source/soundmanager/js/AmbientSound.cpp

     
    3232{
    3333}
    3434
     35JAmbientSound::~JAmbientSound()
     36{
     37    CJSObject<JAmbientSound>::ScriptingShutdown();
     38}
     39
    3540// start playing the sound, all ambient sounds loop
    3641bool JAmbientSound::Play(JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv))
    3742{
  • source/soundmanager/js/AmbientSound.h

     
    2525{
    2626public:
    2727    JAmbientSound(const VfsPath& pathname);
     28    ~JAmbientSound();
    2829   
    2930    CStr ToString(JSContext* cx, uintN argc, jsval* argv);
    3031   
  • source/soundmanager/js/MusicList.cpp

     
    3838#endif
    3939}
    4040
     41JMusicList::~JMusicList()
     42{
     43    CJSObject<JMusicList>::ScriptingShutdown();
     44}
     45
    4146bool JMusicList::AddItem(JSContext* cx, uintN UNUSED(argc), jsval* vp)
    4247{
    4348  CStrW filename;
  • source/soundmanager/js/MusicList.h

     
    3939{
    4040public:
    4141  JMusicList();
     42  ~JMusicList();
    4243
    4344  // Script-bound functions
    4445
  • source/soundmanager/js/MusicSound.cpp

     
    3333{
    3434}
    3535
     36JMusicSound::~JMusicSound()
     37{
     38    CJSObject<JMusicSound>::ScriptingShutdown();
     39}
     40
    3641bool JMusicSound::Play(JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv))
    3742{
    3843#if CONFIG2_AUDIO
  • source/soundmanager/js/MusicSound.h

     
    3939{
    4040public:
    4141    JMusicSound(const VfsPath& pathname);
     42    ~JMusicSound();
    4243   
    4344    // Script-bound functions
    4445   
  • source/soundmanager/js/Sound.cpp

     
    4646        m_SndItem = 0;
    4747    }
    4848#endif // CONFIG2_AUDIO
     49
     50    CJSObject<JSound>::ScriptingShutdown();
    4951}
    5052
    5153bool JSound::ClearSoundItem()
  • source/soundmanager/js/SoundPlayer.cpp

     
    3333
    3434JSoundPlayer::~JSoundPlayer()
    3535{
     36    CJSObject<JSoundPlayer>::ScriptingShutdown();
    3637}
    3738
    3839bool JSoundPlayer::StartMusic(JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv))