Jump to content

[Metin2 Fix] ImageBox memory leak fix


ALLex
 Share

Recommended Posts

  • Moderator
EterPythonLib\PythonWindowManagerModule.cpp

// Search for this function
PyObject* wndImageLoadImage(PyObject* poSelf, PyObject* poArgs)
{
    // ... existing code ...
}

// Add below
PyObject* wndImageUnloadImage(PyObject* poSelf, PyObject* poArgs)
{
    UI::CWindow* pWindow;
    if (!PyTuple_GetWindow(poArgs, 0, &pWindow)) {
        return Py_BuildException();
    }

    if (!((UI::CImageBox*)pWindow)->UnloadImage()) {
        return Py_BuildException("Failed to unload image");
    }

    return Py_BuildNone();
}

// Search for this method registration
{ "LoadImage", wndImageLoadImage, METH_VARARGS },

// Add below
{ "UnloadImage", wndImageUnloadImage, METH_VARARGS },


EterPythonLib\PythonWindow.cpp

// Search for this method
BOOL CImageBox::LoadImage(const char* c_szFileName)
{
    // ... existing code ...
}

// Add below
BOOL CImageBox::UnloadImage()
{
    if (!m_pImageInstance)
        return FALSE;

    OnDestroyInstance();
    return TRUE;
}

EterPythonLib\PythonWindow.h

// Search for this method declaration
BOOL LoadImage(const char* c_szFileName);

// Add below
BOOL UnloadImage();


root/ui.py

# Search for this class definition
class ImageBox(Window):
    # ... existing members ...

    # Find these lines
    self.eventFunc = {}
    self.eventArgs = {}

    # Add below
    self.imageLoaded = False

# ...

# Search for this line where you load the image
wndMgr.LoadImage(self.hWnd, imageName)

# Add below
self.imageLoaded = True

# ...

# Search for this destructor definition
def __del__(self):
    # ... existing code ...

    # Add below
    if self.imageLoaded:
        self.UnloadImage()
  • Like 1
Link to comment
Share on other sites

  • Metin2PServers Bot

Thank you for the post Metin2Downloads
Now we will take care that your topic reaches many people by adding tags

Forum Description : Metin2 Server Files, Server Files, Metin2 Private Servers, Metin2, Metin2 Systems, C++ and Python, Metin2 Home Pages, Metin2 Private Server, Metin2 Download, Metin2 Support, Metin2 Forum, Metin2 Pvp Servers, Errors, Bugs, Requests, Metin2 Pvp Forum, Everything About Metin2.

Tags:  #Metin2 Server Files, #Server Files, #Metin2 Private Servers, #Metin2, #Metin2 Systems, #C++ and Python, #Metin2 Home Pages, #Metin2 Private Server, #Metin2 Download, #Metin2 Support, #Metin2 Forum, #Metin2 Pvp Servers, #Errors, #Bugs, #Requests, #Metin2 Pvp #Forum .

Link to comment
Share on other sites

  • 3 months later...
  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

Terms of Service