Giter VIP home page Giter VIP logo

Comments (5)

vadz avatar vadz commented on June 5, 2024 1

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.

vadz avatar vadz commented on June 5, 2024

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.

ukoz avatar ukoz commented on June 5, 2024
--- 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 

vstest.diff.patch

from wxwidgets.

ukoz avatar ukoz commented on June 5, 2024

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.

vadz avatar vadz commented on June 5, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.