wxMaxima
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
test_WorksheetTeardown.cpp File Reference

Events that reach a Worksheet while its wxWindow base is being destroyed. More...

#include <wx/app.h>
#include <wx/bitmap.h>
#include <wx/dcmemory.h>
#include <wx/frame.h>
#include <wx/log.h>
#include "Configuration.h"
#include "worksheet/Worksheet.h"
#include <catch2/catch.hpp>
Include dependency graph for test_WorksheetTeardown.cpp:

Data Structures

class  TestApp
 

Functions

 SCENARIO ("A worksheet ignores events that arrive while its window dies")
 
 wxDECLARE_APP (TestApp)
 
int main (int argc, char **argv)
 

Detailed Description

Events that reach a Worksheet while its wxWindow base is being destroyed.

On wxGTK4, ~wxWindow detaches the widget from its parent, GTK unmaps it and emits a leave event - after ~Worksheet has already run and set m_configuration to null. Worksheet::OnMouseExit() then crashed wxMaxima on close. GTK3 doesn't do that, so the test recreates the situation another way: a child window of the worksheet is destroyed by the same base class destructor, and its destroy event sends the worksheet mouse, focus and size events at that very moment. Without the fix this dereferences the null configuration (and, under ASan, the already destroyed members).