Resolves: tdf#91880 Invalidate graphics when the gtk window is destroyed

not just when the GtkSalFrame is dtored

Change-Id: Iec33f4de39224f9b1e60d72c02164402196aaac0
(cherry picked from commit 6dcd81f81be0067425f42f0898316d7f52e279d6)
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 5792efa..9268eb0e 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -231,6 +231,7 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider
    void Init( SalFrame* pParent, sal_uLong nStyle );
    void Init( SystemParentData* pSysData );
    void InitCommon();
    void InvalidateGraphics();

    // signals
    static gboolean     signalButton( GtkWidget*, GdkEventButton*, gpointer );
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
index 5ed6465..e687d2b 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -845,17 +845,23 @@ void GtkSalFrame::EnsureAppMenuWatch()
#endif
}

GtkSalFrame::~GtkSalFrame()
void GtkSalFrame::InvalidateGraphics()
{
    for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); ++i )
    for (unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); ++i)
    {
        if( !m_aGraphics[i].pGraphics )
            continue;
#if !GTK_CHECK_VERSION(3,0,0)
        m_aGraphics[i].pGraphics->SetDrawable( None, m_nXScreen );
        m_aGraphics[i].pGraphics->SetWindow(NULL);
#endif
        m_aGraphics[i].bInUse = false;
    }
}

GtkSalFrame::~GtkSalFrame()
{
    InvalidateGraphics();

    if( m_pParent )
        m_pParent->m_aChildren.remove( this );
@@ -1317,8 +1323,10 @@ void GtkSalFrame::Init( SalFrame* pParent, sal_uLong nStyle )
        }
    }
    else
    {
        m_pWindow = gtk_widget_new( GTK_TYPE_WINDOW, "type", eWinType,
                                    "visible", FALSE, NULL );
    }
    g_object_set_data( G_OBJECT( m_pWindow ), "SalFrame", this );
    g_object_set_data( G_OBJECT( m_pWindow ), "libo-version", (gpointer)LIBO_VERSION_DOTTED);

@@ -3071,11 +3079,7 @@ void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Scre
    }
    if( m_pRegion )
    {
#if GTK_CHECK_VERSION(3,0,0)
        cairo_region_destroy( m_pRegion );
#else
        gdk_region_destroy( m_pRegion );
#endif
    }
    if( m_pFixedContainer )
        gtk_widget_destroy( GTK_WIDGET(m_pFixedContainer) );
@@ -4005,6 +4009,7 @@ void GtkSalFrame::signalDestroy( GtkWidget* pObj, gpointer frame )
    {
        pThis->m_pFixedContainer = NULL;
        pThis->m_pWindow = NULL;
        pThis->InvalidateGraphics();
    }
}