Browse Source

Fixed memory leak due to forgetting to move initializer code.

Hynak 4 năm trước cách đây
mục cha
commit
520ceddf48
1 tập tin đã thay đổi với 3 bổ sung và 2 xóa
  1. 3 2
      src/WallpaperEngine/Render/CContext.cpp

+ 3 - 2
src/WallpaperEngine/Render/CContext.cpp

@@ -37,6 +37,9 @@ void CContext::initializeViewports ()
 
     int fullWidth = DisplayWidth (m_display, DefaultScreen (m_display));
     int fullHeight = DisplayHeight (m_display, DefaultScreen (m_display));
+
+    m_pm = XCreatePixmap(m_display, DefaultRootWindow(m_display), fullWidth, fullHeight, 24);
+    m_gc = XCreateGC(m_display, m_pm, 0, NULL);
     XRRScreenResources* screenResources = XRRGetScreenResources (m_display, DefaultRootWindow (m_display));
 
     // there are some situations where xrandr returns null (like screen not using the extension)
@@ -96,8 +99,6 @@ void CContext::render ()
         int fullWidth = DisplayWidth (m_display, DefaultScreen (m_display));
         int fullHeight = DisplayHeight (m_display, DefaultScreen (m_display));
 
-        m_pm = XCreatePixmap(m_display, root, fullWidth, fullHeight, 24);
-        m_gc = XCreateGC(m_display, m_pm, 0, NULL);
         XFillRectangle(m_display, m_pm, m_gc, 0, 0, fullWidth, fullHeight);
 
         char* image_data;