Comments (5)
Thanks, I can indeed reproduce the crash, but I don't think there is anything we can do about it: you're destroying the window containing the event handler from this event handler (because e.g. VarScrollFrame::OnModeHVScroll()
calls m_scrollWindow->Destroy()
), so it's not really surprising that it crashes.
The simplest workaround is, as usual, to use CallAfter()
to postpone the event handling until the next event loop iteration or postpone deleting the window instead, but you do need to be careful when deleting the handler in its own event handlers.
from wxwidgets.
Could you please make a patch to the sample with your changes as explained in our submission instructions? This would make it much simpler to test/reproduce/debug this. TIA!
from wxwidgets.
--- vstest-original.cpp Thu Mar 21 07:28:49 2024
+++ vstest-edit.cpp Thu Mar 21 07:42:22 2024
@@ -47,6 +47,26 @@
#define MAX_LINES 10000
// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// IDs for the controls and the menu commands
+enum
+{
+ // menu items
+ VScroll_Quit = wxID_EXIT,
+
+ // it is important for the id corresponding to the "About" command to have
+ // this standard value as otherwise it won't be handled properly under Mac
+ // (where it is special and put into the "Apple" menu)
+ VScroll_About = wxID_ABOUT,
+
+ VScroll_VScrollMode = wxID_HIGHEST,
+ VScroll_HScrollMode,
+ VScroll_HVScrollMode
+};
+
+// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
@@ -160,6 +180,12 @@
void OnMouse(wxMouseEvent& event)
{
+ if (event.RightDown())
+ {
+ wxMenu menuPopup;
+ menuPopup.Append(VScroll_HVScrollMode, "&HV\tH");
+ PopupMenu(&menuPopup, event.GetPosition());
+ }
if(event.LeftDown())
CaptureMouse();
else if(event.LeftUp())
@@ -377,6 +403,12 @@
void OnMouse(wxMouseEvent& event)
{
+ if (event.RightDown())
+ {
+ wxMenu menuPopup;
+ menuPopup.Append(VScroll_VScrollMode, "&HV\tH");
+ PopupMenu(&menuPopup, event.GetPosition());
+ }
if(event.LeftDown())
CaptureMouse();
else if(event.LeftUp())
@@ -415,26 +447,6 @@
EVT_SCROLLWIN(HVScrollWindow::OnScroll)
EVT_MOUSE_EVENTS(HVScrollWindow::OnMouse)
wxEND_EVENT_TABLE()
-
-// ----------------------------------------------------------------------------
-// constants
-// ----------------------------------------------------------------------------
-
-// IDs for the controls and the menu commands
-enum
-{
- // menu items
- VScroll_Quit = wxID_EXIT,
-
- // it is important for the id corresponding to the "About" command to have
- // this standard value as otherwise it won't be handled properly under Mac
- // (where it is special and put into the "Apple" menu)
- VScroll_About = wxID_ABOUT,
-
- VScroll_VScrollMode = wxID_HIGHEST,
- VScroll_HScrollMode,
- VScroll_HVScrollMode
-};
// ----------------------------------------------------------------------------
// event tables and other macros for wxWidgets
from wxwidgets.
That's is clear bug or missing feature in wxWidgets since postpone till next ain't guarantee wxMenu not had one more item in. So only correct option is to fix event handler.
When you switch frames via other hotkeys that already in vscroll sample there is no direct crash (like in sample code) then you add methods to populate data into frames and whatever else and click via menu (Alt-Z, Alt-H, Alt-V see vstest.cpp) they will also crash.
from wxwidgets.
I think you misunderstand: this has nothing to do with the number of menu items, but with the fact that you delete the (scrolled) window, which is handling the mouse event whose handler is showing the menu, from this event handler itself. You could remove the menu entirely and just execute the code from VarScrollFrame::OnModeHVScroll()
directly from the mouse handler and it would crash in exactly the same way.
from wxwidgets.
Related Issues (20)
- most samples build failed in universal build: mnemonics.cpp and notifmsg had not been compiled HOT 4
- Creating a non-modal window from wxHtmlHelpController HOT 3
- [macOS] widgets sample crashes immediately HOT 2
- [macOS?] Sizers are not setting the size of windows correctly HOT 2
- [macOS] Alignment of a slider's current value looks strange HOT 1
- [macOS] Ugly drawing of slider's ticks HOT 4
- Calendar reports invalid date format when using ca_ES locale HOT 4
- [macOS] Wrong calculation of slider's vertical label positions (in case of a horizontal slider)
- [macOS] Slider value and value label do not match
- [regex] wxRegex::Compile will always popup a message box if the pattern was not valid HOT 1
- Documentation typo - wxListColumnFormat HOT 8
- wxGridBagSizer item clipping when vgap/hgap are different and some items span multiple rows/cols HOT 3
- regression: 3.2.5 kicad/gtk plot window is not shown correct. HOT 16
- `wxDialog` ignores the specified position with GTK3 HOT 4
- Memory leak in wxSearchCtrl with autocomplete HOT 8
- [macOS] wxRichTextCtrl doesn't position and show candidate of IME correctly on macOS HOT 2
- wxBitmapComboBox flickers on Windows.
- wxGrid should disable ime input on read-only cells HOT 8
- Unpredictable crash when assigning a toolbar to a frame on macOS 14 (Sonoma) HOT 8
- wxBitmapComboBox bitmaps are rendered at x4 size at x2 window scaling on wxGTK HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wxwidgets.