]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/cursor.cpp
don't lock the gs_prevCS critical section recursively (replaces patch 1857581)
[wxWidgets.git] / src / gtk / cursor.cpp
index 265b98cd3b6f8266afc66e914a18d6c7ab71eaf0..f9b707075326fa47d7d30a79a7c732ff4823be23 100644 (file)
 // wxCursor
 //-----------------------------------------------------------------------------
 
-class wxCursorRefData: public wxObjectRefData
+class wxCursorRefData: public wxGDIRefData
 {
-  public:
-
+public:
     wxCursorRefData();
     virtual ~wxCursorRefData();
 
+    virtual bool IsOk() const { return m_cursor != NULL; }
+
     GdkCursor *m_cursor;
 };
 
@@ -47,13 +48,12 @@ wxCursorRefData::~wxCursorRefData()
 
 //-----------------------------------------------------------------------------
 
-#define M_CURSORDATA ((wxCursorRefData *)m_refData)
+#define M_CURSORDATA wx_static_cast(wxCursorRefData*, m_refData)
 
-IMPLEMENT_DYNAMIC_CLASS(wxCursor,wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxGDIObject)
 
 wxCursor::wxCursor()
 {
-
 }
 
 wxCursor::wxCursor( int cursorId )
@@ -65,8 +65,8 @@ wxCursor::wxCursor( int cursorId )
     {
         case wxCURSOR_BLANK:
             {
-                static const gchar bits[] = { 0 };
-                static /* const -- not in GTK1 */ GdkColor color = { 0, 0, 0, 0 };
+                const char bits[] = { 0 };
+                const GdkColor color = { 0, 0, 0, 0 };
 
                 GdkPixmap *pixmap = gdk_bitmap_create_from_data(NULL, bits, 1, 1);
                 M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap(pixmap,
@@ -74,6 +74,7 @@ wxCursor::wxCursor( int cursorId )
                                                                     &color,
                                                                     &color,
                                                                     0, 0);
+                g_object_unref(pixmap);
             }
             return;
 
@@ -360,14 +361,19 @@ wxCursor::~wxCursor()
 {
 }
 
-bool wxCursor::IsOk() const
+GdkCursor *wxCursor::GetCursor() const
+{
+    return M_CURSORDATA->m_cursor;
+}
+
+wxGDIRefData *wxCursor::CreateGDIRefData() const
 {
-    return (m_refData != NULL);
+    return new wxCursorRefData;
 }
 
-GdkCursor *wxCursor::GetCursor() const
+wxGDIRefData *wxCursor::CloneGDIRefData(const wxGDIRefData *data) const
 {
-    return M_CURSORDATA->m_cursor;
+    return new wxCursorRefData(*wx_static_cast(const wxCursorRefData *, data));
 }
 
 //-----------------------------------------------------------------------------