From 8f1be368e9ca5ec1e8d682511354dab8a91101d4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 16 Oct 2021 17:01:48 +0200 Subject: [PATCH] Add some comments to wxGtkImage Document which pointers can, and can't, be null and when exactly is the stored bitmap valid, as this is far from being immediately obvious. No real changes. --- include/wx/gtk/private/image.h | 4 ++++ src/gtk/image_gtk.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/include/wx/gtk/private/image.h b/include/wx/gtk/private/image.h index c346cd7919..ce664c6d86 100644 --- a/include/wx/gtk/private/image.h +++ b/include/wx/gtk/private/image.h @@ -23,9 +23,13 @@ public: static GtkWidget* New(wxWindow* win = NULL); void Set(const wxBitmap& bitmap); + // This pointer is never null and is owned by this class. BitmapProvider* m_provider; wxDECLARE_NO_COPY_CLASS(wxGtkImage); + + // This class is constructed by New() and destroyed by its GObject + // finalizer, so neither its ctor nor dtor can ever be used. wxGtkImage() wxMEMBER_DELETE; ~wxGtkImage() wxMEMBER_DELETE; }; diff --git a/src/gtk/image_gtk.cpp b/src/gtk/image_gtk.cpp index 9f370500ef..29d9297766 100644 --- a/src/gtk/image_gtk.cpp +++ b/src/gtk/image_gtk.cpp @@ -24,8 +24,17 @@ struct BitmapProviderDefault: wxGtkImage::BitmapProvider BitmapProviderDefault(wxWindow* win) : m_win(win) { } virtual wxBitmap Get() const wxOVERRIDE; virtual void Set(const wxBitmap& bitmap) wxOVERRIDE; + + // This pointer can be null if there is no associated window. wxWindow* const m_win; + + // The bitmap stored here is only valid if it uses scale factor > 1, + // otherwise we leave it invalid to indicate the drawing the bitmap should + // be left to GtkImage itself. wxBitmap m_bitmap; + + // This bitmap is only valid if m_bitmap is and if we have the associated + // window (as otherwise it would never be used at all). wxBitmap m_bitmapDisabled; };