Daniel Reetz, the founder of the DIY Book Scanner community, has recently started making videos of prototyping and shop tips. If you are tinkering with a book scanner (or any other project) in your home shop, these tips will come in handy. https://www.youtube.com/channel/UCn0gq8 ... g_8K1nfInQ

Mac problem - contextual menus cause crash

Scan Tailor specific announcements, releases, workflows, tips, etc. NO FEATURE REQUESTS IN THIS FORUM, please.
User avatar
n9yty
Posts: 72
Joined: 25 Jul 2010, 22:13

Re: Mac problem - contextual menus cause crash

Post by n9yty » 27 Oct 2010, 22:39

gdb steps....

This may or may not be useful. I set the breakpoint at menuAboutToHide(). One is with just invoking the zone menu and the letting it go away. The other is with invoking the zone menu and selecting an option.

[UPDATE: I also had a breakpoint set at ZoneContextMenuInteraction::menuItemTriggered, but it was not hit before menuAboutToHide(). I also set one on QtSignalForwarder::handleSignal() just to verify the logic flow but that was not called first either. It was called *after* menuAboutToHide().

Code: Select all

Menu call without selection:

Breakpoint 1, ZoneContextMenuInteraction::menuAboutToHide (this=0x25b4c50) at /usr/local/src/scantailor/scantailor-9224b0d/zones/ZoneContextMenuInteraction.cpp:193
193		if (m_menuItemTriggered) {
(gdb) n
197		InteractionHandler* next_handler = m_rContext.createDefaultInteraction();
(gdb) 
198		if (next_handler) {
(gdb) 
199			makePeerPreceeder(*next_handler);
(gdb) 
202		unlink();
(gdb) 
203		m_rContext.imageView().update();
(gdb) 
204		deleteLater();
(gdb) 
205	}
(gdb) 
ZoneContextMenuInteraction::qt_metacall (this=0x25b4c50, _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0x25e8390) at ZoneContextMenuInteraction.h.moc:81
81	        _id -= 2;
(gdb) 
83	    return _id;
(gdb) 
84	}
(gdb) 
0x01cfd799 in QMetaObject::metacall ()
(gdb) 
Single stepping until exit from function _ZN11QMetaObject8metacallEP7QObjectNS_4CallEiPPv, 
which has no line number information.
0x01e0bc85 in QMetaCallEvent::placeMetaCall ()
(gdb) 
Single stepping until exit from function _ZN14QMetaCallEvent13placeMetaCallEP7QObject, 
which has no line number information.
0x01e11fe6 in QObject::event ()
(gdb) 
Single stepping until exit from function _ZN7QObject5eventEP6QEvent, 
which has no line number information.
0x009bfac8 in QApplicationPrivate::notify_helper ()
(gdb) 
Single stepping until exit from function _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent, 
which has no line number information.
0x009c7af8 in QApplication::notify ()
(gdb) 
Single stepping until exit from function _ZN12QApplication6notifyEP7QObjectP6QEvent, 
which has no line number information.
0x01cf95fe in QCoreApplication::notifyInternal ()
(gdb) 
Single stepping until exit from function _ZN16QCoreApplication14notifyInternalEP7QObjectP6QEvent, 
which has no line number information.
0x01cfba81 in QCoreApplication::sendEvent ()
(gdb) 
Single stepping until exit from function _ZN16QCoreApplication9sendEventEP7QObjectP6QEvent, 
which has no line number information.
0x01dfde07 in QCoreApplicationPrivate::sendPostedEvents ()
(gdb) 
Single stepping until exit from function _ZN23QCoreApplicationPrivate16sendPostedEventsEP7QObjectiP11QThreadData, 
which has no line number information.
0x0094fe88 in processPostedEvents ()
(gdb) 
Single stepping until exit from function _Z19processPostedEventsP26QEventDispatcherMacPrivateb, 
which has no line number information.
0x0094fed7 in QEventDispatcherMacPrivate::postedEventsSourcePerformCallback ()
(gdb) 
Single stepping until exit from function _ZN26QEventDispatcherMacPrivate33postedEventsSourcePerformCallbackEPv, 
which has no line number information.
0x972154cb in __CFRunLoopDoSources0 ()
(gdb) 
Single stepping until exit from function __CFRunLoopDoSources0, 
which has no line number information.
0x97212f8f in __CFRunLoopRun ()
(gdb) 
Single stepping until exit from function __CFRunLoopRun, 
which has no line number information.

0x97212464 in CFRunLoopRunSpecific ()
(gdb) 
Single stepping until exit from function CFRunLoopRunSpecific, 
which has no line number information.
0x97212291 in CFRunLoopRunInMode ()
(gdb) 
Single stepping until exit from function CFRunLoopRunInMode, 
which has no line number information.
0x90d5ff58 in RunCurrentEventLoopInMode ()
(gdb) 
Single stepping until exit from function RunCurrentEventLoopInMode, 
which has no line number information.
0x90d5fc4b in ReceiveNextEventCommon ()
(gdb) 
Single stepping until exit from function ReceiveNextEventCommon, 
which has no line number information.
0x90ee81ed in ReceiveNextEvent ()
(gdb) 
Single stepping until exit from function ReceiveNextEvent, 
which has no line number information.
0x00951c01 in QEventDispatcherMac::processEvents ()
(gdb) 
Single stepping until exit from function _ZN19QEventDispatcherMac13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE, 
which has no line number information.
0x01dfaa6e in QEventLoop::processEvents ()
(gdb) 
Single stepping until exit from function _ZN10QEventLoop13processEventsE6QFlagsINS_17ProcessEventsFlagEE, 
which has no line number information.
0x01dfacf8 in QEventLoop::exec ()
(gdb) 
Single stepping until exit from function _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE, 
which has no line number information.
0x00eefd86 in QMenuPrivate::hideUpToMenuBar ()
(gdb) 
Single stepping until exit from function _ZN12QMenuPrivate15hideUpToMenuBarEv, 
which has no line number information.
0x00ef3077 in QMenu::mousePressEvent ()
(gdb) 
Single stepping until exit from function _ZN5QMenu15mousePressEventEP11QMouseEvent, 
which has no line number information.
0x00a33d89 in QWidget::event ()
(gdb) 
Single stepping until exit from function _ZN7QWidget5eventEP6QEvent, 
which has no line number information.
0x00eef765 in QMenu::event ()
(gdb) 
Single stepping until exit from function _ZN5QMenu5eventEP6QEvent, 
which has no line number information.
0x009bfac8 in QApplicationPrivate::notify_helper ()
(gdb) 
Single stepping until exit from function _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent, 
which has no line number information.
0x009c88be in QApplication::notify ()
(gdb) 
Single stepping until exit from function _ZN12QApplication6notifyEP7QObjectP6QEvent, 
which has no line number information.
0x01cf95fe in QCoreApplication::notifyInternal ()
(gdb) 
Single stepping until exit from function _ZN16QCoreApplication14notifyInternalEP7QObjectP6QEvent, 
which has no line number information.
0x0093755f in QCoreApplication::sendSpontaneousEvent ()
(gdb) 
Single stepping until exit from function _ZN16QCoreApplication20sendSpontaneousEventEP7QObjectP6QEvent, 
which has no line number information.
0x00935c65 in QApplicationPrivate::globalEventProcessor ()
(gdb) 
Single stepping until exit from function _ZN19QApplicationPrivate20globalEventProcessorEP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv, 
which has no line number information.
0x90d32eef in DispatchEventToHandlers ()
(gdb) 
Single stepping until exit from function _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec, 
which has no line number information.
0x90d321b6 in SendEventToEventTargetInternal ()
(gdb) 
Single stepping until exit from function _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec, 
which has no line number information.
0x90d5497b in SendEventToEventTarget ()
(gdb) 
Single stepping until exit from function SendEventToEventTarget, 
which has no line number information.
0x0094808c in QWidgetPrivate::qt_window_event ()
(gdb) 
Single stepping until exit from function _ZN14QWidgetPrivate15qt_window_eventEP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv, 
which has no line number information.
0x90d32eef in DispatchEventToHandlers ()
(gdb) 
Single stepping until exit from function _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec, 
which has no line number information.
0x90d321b6 in SendEventToEventTargetInternal ()
(gdb) 
Single stepping until exit from function _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec, 
which has no line number information.
0x90d5497b in SendEventToEventTarget ()
(gdb) 
Single stepping until exit from function SendEventToEventTarget, 
which has no line number information.
0x90d66497 in ToolboxEventDispatcherHandler ()
(gdb) 
Single stepping until exit from function _ZL29ToolboxEventDispatcherHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv, 
which has no line number information.
0x90d33340 in DispatchEventToHandlers ()
(gdb) 
Single stepping until exit from function _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec, 
which has no line number information.
0x90d321b6 in SendEventToEventTargetInternal ()
(gdb) 
Single stepping until exit from function _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec, 
which has no line number information.
0x90d5497b in SendEventToEventTarget ()
(gdb) 
Single stepping until exit from function SendEventToEventTarget, 
which has no line number information.
0x0094fd49 in qt_mac_send_event ()
(gdb) 
Single stepping until exit from function _Z17qt_mac_send_event6QFlagsIN10QEventLoop17ProcessEventsFlagEEP14OpaqueEventRefP15OpaqueWindowPtr, 
which has no line number information.
0x00951cd0 in QEventDispatcherMac::processEvents ()
(gdb) 
Single stepping until exit from function _ZN19QEventDispatcherMac13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE, 
which has no line number information.
0x01dfaa6e in QEventLoop::processEvents ()
(gdb) 
Single stepping until exit from function _ZN10QEventLoop13processEventsE6QFlagsINS_17ProcessEventsFlagEE, 
which has no line number information.
0x01dfacf8 in QEventLoop::exec ()
(gdb) 
Single stepping until exit from function _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE, 
which has no line number information.

Code: Select all

Menu called with selection:

Breakpoint 1, ZoneContextMenuInteraction::menuAboutToHide (this=0x19a15670) at /usr/local/src/scantailor/scantailor-9224b0d/zones/ZoneContextMenuInteraction.cpp:193
193		if (m_menuItemTriggered) {
(gdb) n
197		InteractionHandler* next_handler = m_rContext.createDefaultInteraction();
(gdb) 
198		if (next_handler) {
(gdb) 
199			makePeerPreceeder(*next_handler);
(gdb) 
202		unlink();
(gdb) 
203		m_rContext.imageView().update();
(gdb) 
204		deleteLater();
(gdb) 
205	}
(gdb) 
ZoneContextMenuInteraction::qt_metacall (this=0x19a15670, _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0x25e3a50) at ZoneContextMenuInteraction.h.moc:81
81	        _id -= 2;
(gdb) 
83	    return _id;
(gdb) 
84	}
(gdb) 
0x01cfd799 in QMetaObject::metacall ()
(gdb) 
Single stepping until exit from function _ZN11QMetaObject8metacallEP7QObjectNS_4CallEiPPv, 
which has no line number information.
0x01e0bc85 in QMetaCallEvent::placeMetaCall ()
(gdb) 
Single stepping until exit from function _ZN14QMetaCallEvent13placeMetaCallEP7QObject, 
which has no line number information.
0x01e11fe6 in QObject::event ()
(gdb) 
Single stepping until exit from function _ZN7QObject5eventEP6QEvent, 
which has no line number information.
0x009bfac8 in QApplicationPrivate::notify_helper ()
(gdb) 
Single stepping until exit from function _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent, 
which has no line number information.
0x009c7af8 in QApplication::notify ()
(gdb) 
Single stepping until exit from function _ZN12QApplication6notifyEP7QObjectP6QEvent, 
which has no line number information.
0x01cf95fe in QCoreApplication::notifyInternal ()
(gdb) 
Single stepping until exit from function _ZN16QCoreApplication14notifyInternalEP7QObjectP6QEvent, 
which has no line number information.
0x01cfba81 in QCoreApplication::sendEvent ()
(gdb) 
Single stepping until exit from function _ZN16QCoreApplication9sendEventEP7QObjectP6QEvent, 
which has no line number information.
0x01dfde07 in QCoreApplicationPrivate::sendPostedEvents ()
(gdb) 
Single stepping until exit from function _ZN23QCoreApplicationPrivate16sendPostedEventsEP7QObjectiP11QThreadData, 
which has no line number information.
0x0094fe88 in processPostedEvents ()
(gdb) 
Single stepping until exit from function _Z19processPostedEventsP26QEventDispatcherMacPrivateb, 
which has no line number information.
0x0094fed7 in QEventDispatcherMacPrivate::postedEventsSourcePerformCallback ()
(gdb) 
Single stepping until exit from function _ZN26QEventDispatcherMacPrivate33postedEventsSourcePerformCallbackEPv, 
which has no line number information.
0x972154cb in __CFRunLoopDoSources0 ()
(gdb) 
Single stepping until exit from function __CFRunLoopDoSources0, 
which has no line number information.
0x97212f8f in __CFRunLoopRun ()
(gdb) 
Single stepping until exit from function __CFRunLoopRun, 
which has no line number information.

0x97212464 in CFRunLoopRunSpecific ()
(gdb) 
Single stepping until exit from function CFRunLoopRunSpecific, 
which has no line number information.
0x97212291 in CFRunLoopRunInMode ()
(gdb) 
Single stepping until exit from function CFRunLoopRunInMode, 
which has no line number information.
0x90d5ff58 in RunCurrentEventLoopInMode ()
(gdb) 
Single stepping until exit from function RunCurrentEventLoopInMode, 
which has no line number information.
0x90d5fc4b in ReceiveNextEventCommon ()
(gdb) 
Single stepping until exit from function ReceiveNextEventCommon, 
which has no line number information.
0x90ee81ed in ReceiveNextEvent ()
(gdb) 
Single stepping until exit from function ReceiveNextEvent, 
which has no line number information.
0x00951c01 in QEventDispatcherMac::processEvents ()
(gdb) 
Single stepping until exit from function _ZN19QEventDispatcherMac13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE, 
which has no line number information.
0x01dfaa6e in QEventLoop::processEvents ()
(gdb) 
Single stepping until exit from function _ZN10QEventLoop13processEventsE6QFlagsINS_17ProcessEventsFlagEE, 
which has no line number information.
0x01dfacf8 in QEventLoop::exec ()
(gdb) 
Single stepping until exit from function _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE, 
which has no line number information.
0x00eefd86 in QMenuPrivate::hideUpToMenuBar ()
(gdb) 
Single stepping until exit from function _ZN12QMenuPrivate15hideUpToMenuBarEv, 
which has no line number information.
0x00eeff0b in QMenuPrivate::activateAction ()
(gdb) 
Single stepping until exit from function _ZN12QMenuPrivate14activateActionEP7QActionNS0_11ActionEventEb, 
which has no line number information.

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0xffffffff
0xffffffff in ?? ()
(gdb)

 - program continued normally -

Last edited by n9yty on 28 Oct 2010, 09:15, edited 1 time in total.

Tulon
Posts: 687
Joined: 03 Oct 2009, 06:13
Number of books owned: 0
Location: London, UK
Contact:

Re: Mac problem - contextual menus cause crash

Post by Tulon » 28 Oct 2010, 02:43

n9yty wrote: As to the timing of the signals, is the hide or trigger supposed to fire first? If I am in the debugger and I do a return as soon as it enters the menuAboutToHide() call, and then continue, the trigger is called and then works, but menuAboutToHide() is not called after that again.
You said you can reproduce the crash without clicking any menu items, in which scenario menuItemTriggered() will not be called at all. I suggest you concentrate on this scenario, as it's the most simple one.
If you do click a menu item, menuAboutToHide() will either be called after menuItemTriggered() or not at all. Both options are fine and should work.
Scan Tailor experimental doesn't output 96 DPI images. It's just what your software shows when DPI information is missing. Usually what you get is input DPI times the resolution enhancement factor.

User avatar
n9yty
Posts: 72
Joined: 25 Jul 2010, 22:13

Re: Mac problem - contextual menus cause crash

Post by n9yty » 28 Oct 2010, 09:04

Tulon wrote:You said you can reproduce the crash without clicking any menu items, in which scenario menuItemTriggered() will not be called at all. I suggest you concentrate on this scenario, as it's the most simple one.
If you do click a menu item, menuAboutToHide() will either be called after menuItemTriggered() or not at all. Both options are fine and should work.
The crash of the menu without selecting items was only when I had been messing around with removingthe connect() to menuAboutToHide() and some other things, I probably shouldn't have posted that without better clarification. As the source code comes from the repository, I can not crash it when just bringing a menu up and letting it go away. However, your statement above is in contradiction to what I see here --- You say that menuAboutToHide() will either be called AFTER menuItemTriggered() or not at all. On my system, menuAboutToHide() is always called BEFORE menuItemTriggered().
Last edited by n9yty on 28 Oct 2010, 10:35, edited 2 times in total.

Tulon
Posts: 687
Joined: 03 Oct 2009, 06:13
Number of books owned: 0
Location: London, UK
Contact:

Re: Mac problem - contextual menus cause crash

Post by Tulon » 28 Oct 2010, 10:16

n9yty wrote:On my system, menuAboutToHide() is always called BEFORE menuItemTriggered().
Quite strange. menuAboutToHide() was specifically put on a queued connection to make it go after menuItemTriggered() even if Qt dispatches them in the other order. If your observation is correct, the only hope to handle this situation will be not using aboutToHide() signal at all, but rather subclass QMenu and override its hideEvent(), hoping that one is dispatched after the triggered() signal. If you feel you can try that by yourself, please do so, otherwise I'll try it a bit later.
Scan Tailor experimental doesn't output 96 DPI images. It's just what your software shows when DPI information is missing. Usually what you get is input DPI times the resolution enhancement factor.

User avatar
n9yty
Posts: 72
Joined: 25 Jul 2010, 22:13

Re: Mac problem - contextual menus cause crash

Post by n9yty » 28 Oct 2010, 10:38

Tulon wrote:
n9yty wrote:On my system, menuAboutToHide() is always called BEFORE menuItemTriggered().
Quite strange. menuAboutToHide() was specifically put on a queued connection to make it go after menuItemTriggered() even if Qt dispatches them in the other order. If your observation is correct, the only hope to handle this situation will be not using aboutToHide() signal at all, but rather subclass QMenu and override its hideEvent(), hoping that one is dispatched after the triggered() signal. If you feel you can try that by yourself, please do so, otherwise I'll try it a bit later.
So, it is at least nice to get to the bottom, the logic flow is not what is expected so that explains the crash. :) Looking at the QMenu source, this is not unique to the Mac. However, I don't know about how the QueuedConnection stuff may affect timing of signals, based on when the event loop is re-engaged for the emitter/receiver.

I did also verify this using the Qt menu sample that aboutToHide() precedes the signal triggered(). When the contextual menu is built in that sample, I made a connect using Qt:QueuedConnection to the aboutToHide() signal, and it is called before the triggered() signal. I changed it to a Qt::AutoConnection with no change in behavior.

I am not sure if I will be able to do as you suggest, but it is worth a shot so I will start on it and see how far I get.

UPDATE: Seems not so good...

I created a ZoneQMenu.h/cpp class that subclasses QMenu. I changed ZoneContextMenuInteraction to use this instead of QMenu. I overrode the hideEvent() method, and created a custom signal didHide() in the subclass. I then changed ZoneContextMenuInteraction to connect didHide to the renamed slot menuAboutToHide() (renamed to menuDidHide()). So, all of this should have made a new signal that fires in the hideEvent(), and then logic should be the same as originally intended. However, it does not work. :( This new signal is still firing and calling the assigned slot before the triggered() signal calls menuItemTriggered().

I could have done something wrong, so don't take this as definitive.

Maybe the subclass has to set a flag as to whether or not an action was selected so that menuAboutToHide() can figure that out when it is called, and if so, do nothing like it checks the triggered flag now... Hmmm... How to find it? I tried in mousePressEvent using activeAction(), but if you move the mouse off the action before releasing it then it would be invalid. However, in mouseReleasedEvent() I do not know how to determine if it is valid or not because actionAt(point) always returns 0 because the menu has gone away before it is called, or so it seems...

Before I tried that, though, I thought, well, why not do it synchronously... Something like:

Code: Select all

	// The queued connection is used to ensure it gets called *after*
	// QAction::triggered().
	//	connect(
	//		m_ptrMenu.get(), SIGNAL(aboutToHide()),
	//		SLOT(menuAboutToHide()), Qt::QueuedConnection
	//	);

	highlightItem(0);
//	m_ptrMenu->popup(QCursor::pos());
	QAction *ret;
	ret = m_ptrMenu->exec(QCursor::pos());
	// Catch the selected action, 0 if no action was selected.
	// so we only call the cleanup if no menu item was picked.
	if (!ret) menuAboutToHide();
But that crashes as well, both when an action is selected or when one is not, so clearly this won't work either because running it synchronously is not doing something that is needed for the remainder of the code to work right.

Code: Select all

Process:         scantailor [41143]
Path:            /usr/local/src/scantailor/scantailor-9224b0d/./scantailor
Identifier:      scantailor
Version:         ??? (???)
Code Type:       X86 (Native)
Parent Process:  bash [1309]

Date/Time:       2010-10-28 12:15:18.585 -0500
OS Version:      Mac OS X 10.6.5 (10H563)
Report Version:  6

Interval Since Last Report:          82129 sec
Crashes Since Last Report:           23
Per-App Crashes Since Last Report:   20
Anonymous UUID:                      40BECA1D-6F3A-449D-840F-C981A03160F3

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread:  0

Thread 0 Crashed:
0   scantailor                    	0x00154edf InteractionHandler::makePeerPreceeder(InteractionHandler&) + 47
1   scantailor                    	0x0014e56e ZoneContextMenuInteraction::menuItemTriggered(InteractionState&, boost::function<InteractionHandler* ()(InteractionState&)> const&) + 94
2   scantailor                    	0x00150151 boost::detail::function::void_function_obj_invoker0<boost::_bi::bind_t<void, boost::_mfi::mf2<void, ZoneContextMenuInteraction, InteractionState&, boost::function<InteractionHandler* ()(InteractionState&)> const&>, boost::_bi::list3<boost::_bi::value<ZoneContextMenuInteraction*>, boost::reference_wrapper<InteractionState>, boost::_bi::value<boost::function<InteractionHandler* ()(InteractionState&)> > > >, void>::invoke(boost::detail::function::function_buffer&) + 65
3   scantailor                    	0x001915ed QtSignalForwarder::handleSignal() + 45
4   scantailor                    	0x00191b7b QtSignalForwarder::qt_metacall(QMetaObject::Call, int, void**) + 91
5   QtCore_debug                  	0x016f8799 QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) + 167
6   QtCore_debug                  	0x016fc607 QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 867
7   QtGui_debug                   	0x003af13f QAction::triggered(bool) + 75
8   QtGui_debug                   	0x003afcb5 QAction::activate(QAction::ActionEvent) + 287
9   QtGui_debug                   	0x008e3c1b QMenuPrivate::activateCausedStack(QList<QPointer<QWidget> > const&, QAction*, QAction::ActionEvent, bool) + 99
10  QtGui_debug                   	0x008eb04b QMenuPrivate::activateAction(QAction*, QAction::ActionEvent, bool) + 615
11  QtGui_debug                   	0x008ede88 QMenu::mouseReleaseEvent(QMouseEvent*) + 252
12  QtGui_debug                   	0x0042eda4 QWidget::event(QEvent*) + 1122
13  QtGui_debug                   	0x008ea765 QMenu::event(QEvent*) + 105
14  QtGui_debug                   	0x003baac8 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 364
15  QtGui_debug                   	0x003c38be QApplication::notify(QObject*, QEvent*) + 5344
16  QtCore_debug                  	0x016f45fe QCoreApplication::notifyInternal(QObject*, QEvent*) + 158
17  QtGui_debug                   	0x0033255f QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) + 75
18  QtGui_debug                   	0x00330c65 QApplicationPrivate::globalEventProcessor(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) + 12969
19  com.apple.HIToolbox           	0x90d32eef DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1567
20  com.apple.HIToolbox           	0x90d321b6 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 411
21  com.apple.HIToolbox           	0x90d5497b SendEventToEventTarget + 52
22  com.apple.HIToolbox           	0x90d66497 ToolboxEventDispatcherHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) + 1257
23  com.apple.HIToolbox           	0x90d33340 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 2672
24  com.apple.HIToolbox           	0x90d321b6 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 411
25  com.apple.HIToolbox           	0x90d5497b SendEventToEventTarget + 52
26  QtGui_debug                   	0x0034ad49 qt_mac_send_event(QFlags<QEventLoop::ProcessEventsFlag>, OpaqueEventRef*, OpaqueWindowPtr*) + 101
27  QtGui_debug                   	0x0034ccd0 QEventDispatcherMac::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 488
28  QtCore_debug                  	0x017f5a6e QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 170
29  QtCore_debug                  	0x017f5cf8 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 312
30  QtGui_debug                   	0x008e775b QMenu::exec(QPoint const&, QAction*) + 143
31  scantailor                    	0x0014f2d2 ZoneContextMenuInteraction::ZoneContextMenuInteraction(ZoneInteractionContext&, InteractionState&, boost::function<std::vector<ZoneContextMenuItem, std::allocator<ZoneContextMenuItem> > ()(EditableZoneSet::Zone const&, ZoneContextMenuInteraction::StandardMenuItems const&)> const&, std::vector<ZoneContextMenuInteraction::Zone, std::allocator<ZoneContextMenuInteraction::Zone> >&) + 3122
32  scantailor                    	0x0014fc86 ZoneContextMenuInteraction::create(ZoneInteractionContext&, InteractionState&, boost::function<std::vector<ZoneContextMenuItem, std::allocator<ZoneContextMenuItem> > ()(EditableZoneSet::Zone const&, ZoneContextMenuInteraction::StandardMenuItems const&)> const&) + 86
33  scantailor                    	0x00137144 output::FillZoneEditor::createContextMenuInteraction(InteractionState&) + 100
34  scantailor                    	0x00144224 ZoneInteractionContext::createContextMenuInteraction(InteractionState&) + 52
35  scantailor                    	0x001446b6 ZoneDefaultInteraction::onContextMenuEvent(QContextMenuEvent*, InteractionState&) + 38
36  scantailor                    	0x00156122 InteractionHandler::contextMenuEvent(QContextMenuEvent*, InteractionState&) + 242
37  scantailor                    	0x00156172 InteractionHandler::contextMenuEvent(QContextMenuEvent*, InteractionState&) + 322
38  scantailor                    	0x00156172 InteractionHandler::contextMenuEvent(QContextMenuEvent*, InteractionState&) + 322
39  scantailor                    	0x0002dc7f ImageViewBase::contextMenuEvent(QContextMenuEvent*) + 47
40  QtGui_debug                   	0x0042f6c1 QWidget::event(QEvent*) + 3455
41  QtGui_debug                   	0x00891102 QFrame::event(QEvent*) + 64
42  QtGui_debug                   	0x009440d3 QAbstractScrollArea::viewportEvent(QEvent*) + 73
43  QtGui_debug                   	0x00946e2e QAbstractScrollAreaPrivate::viewportEvent(QEvent*) + 40
44  QtGui_debug                   	0x00946f1c QAbstractScrollAreaFilter::eventFilter(QObject*, QEvent*) + 44
45  QtCore_debug                  	0x017f7635 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 221
46  QtGui_debug                   	0x003baaa2 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 326
47  QtGui_debug                   	0x003c4115 QApplication::notify(QObject*, QEvent*) + 7479
48  QtCore_debug                  	0x016f45fe QCoreApplication::notifyInternal(QObject*, QEvent*) + 158
49  QtGui_debug                   	0x00b4a88b QCoreApplication::sendEvent(QObject*, QEvent*) + 75
50  QtGui_debug                   	0x0032e0f4 QApplicationPrivate::globalEventProcessor(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) + 1848
51  com.apple.HIToolbox           	0x90d32eef DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1567
52  com.apple.HIToolbox           	0x90d321b6 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 411
53  com.apple.HIToolbox           	0x90d32015 SendEventToEventTargetWithOptions + 58
54  com.apple.HIToolbox           	0x90d66b6c ToolboxEventDispatcherHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) + 3006
55  com.apple.HIToolbox           	0x90d33340 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 2672
56  com.apple.HIToolbox           	0x90d321b6 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 411
57  com.apple.HIToolbox           	0x90d5497b SendEventToEventTarget + 52
58  QtGui_debug                   	0x0034ad49 qt_mac_send_event(QFlags<QEventLoop::ProcessEventsFlag>, OpaqueEventRef*, OpaqueWindowPtr*) + 101
59  QtGui_debug                   	0x0034ccd0 QEventDispatcherMac::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 488
60  QtCore_debug                  	0x017f5a6e QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 170
61  QtCore_debug                  	0x017f5cf8 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 312
62  QtCore_debug                  	0x017f9193 QCoreApplication::exec() + 297
63  QtGui_debug                   	0x003b781a QApplication::exec() + 24
64  scantailor                    	0x000053ed main + 1165
65  scantailor                    	0x00004d26 _start + 216
66  scantailor                    	0x00004c4d start + 41

Thread 1:
0   libSystem.B_debug.dylib       	0x01c44cca kevent + 10
1   libSystem.B_debug.dylib       	0x01c45972 _dispatch_mgr_invoke + 1108
2   libSystem.B_debug.dylib       	0x01c44644 _dispatch_queue_invoke + 112
3   libSystem.B_debug.dylib       	0x01dc8755 _dispatch_continuation_pop + 33
4   libSystem.B_debug.dylib       	0x01c443fb _dispatch_worker_thread2 + 135
5   libSystem.B_debug.dylib       	0x01c43fb9 _pthread_wqthread + 557
6   libSystem.B_debug.dylib       	0x01c43d36 start_wqthread + 30

Thread 2:
0   libSystem.B_debug.dylib       	0x01c5d396 select$DARWIN_EXTSN$NOCANCEL + 10
1   libSystem.B_debug.dylib       	0x01d15c91 select + 111
2   QtCore_debug                  	0x01823af0 qt_safe_select(int, fd_set*, fd_set*, fd_set*, timeval const*) + 52
3   QtCore_debug                  	0x01826ec9 QEventDispatcherUNIX::select(int, fd_set*, fd_set*, fd_set*, timeval*) + 45
4   QtCore_debug                  	0x018288ea QEventDispatcherUNIXPrivate::doSelect(QFlags<QEventLoop::ProcessEventsFlag>, timeval*) + 650
5   QtCore_debug                  	0x018295d4 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 398
6   QtCore_debug                  	0x017f5a6e QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 170
7   QtCore_debug                  	0x017f5cf8 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 312
8   QtCore_debug                  	0x0172115a QThread::exec() + 144
9   scantailor                    	0x00069542 WorkerThread::Impl::run() + 34
10  QtCore_debug                  	0x0172346d QThreadPrivate::start(void*) + 279
11  libSystem.B_debug.dylib       	0x01c4d29b _pthread_start + 503
12  libSystem.B_debug.dylib       	0x01c4d072 thread_start + 34

Thread 3:
0   libSystem.B_debug.dylib       	0x01c5d396 select$DARWIN_EXTSN$NOCANCEL + 10
1   libSystem.B_debug.dylib       	0x01d15c91 select + 111
2   QtCore_debug                  	0x01823af0 qt_safe_select(int, fd_set*, fd_set*, fd_set*, timeval const*) + 52
3   QtCore_debug                  	0x01826ec9 QEventDispatcherUNIX::select(int, fd_set*, fd_set*, fd_set*, timeval*) + 45
4   QtCore_debug                  	0x018288ea QEventDispatcherUNIXPrivate::doSelect(QFlags<QEventLoop::ProcessEventsFlag>, timeval*) + 650
5   QtCore_debug                  	0x018295d4 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 398
6   QtCore_debug                  	0x017f5a6e QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 170
7   QtCore_debug                  	0x017f5cf8 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 312
8   QtCore_debug                  	0x0172115a QThread::exec() + 144
9   QtCore_debug                  	0x0172346d QThreadPrivate::start(void*) + 279
10  libSystem.B_debug.dylib       	0x01c4d29b _pthread_start + 503
11  libSystem.B_debug.dylib       	0x01c4d072 thread_start + 34

Thread 4:
0   libSystem.B_debug.dylib       	0x01c5d396 select$DARWIN_EXTSN$NOCANCEL + 10
1   libSystem.B_debug.dylib       	0x01d15c91 select + 111
2   QtCore_debug                  	0x01823af0 qt_safe_select(int, fd_set*, fd_set*, fd_set*, timeval const*) + 52
3   QtCore_debug                  	0x01826ec9 QEventDispatcherUNIX::select(int, fd_set*, fd_set*, fd_set*, timeval*) + 45
4   QtCore_debug                  	0x018288ea QEventDispatcherUNIXPrivate::doSelect(QFlags<QEventLoop::ProcessEventsFlag>, timeval*) + 650
5   QtCore_debug                  	0x018295d4 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 398
6   QtCore_debug                  	0x017f5a6e QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 170
7   QtCore_debug                  	0x017f5cf8 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 312
8   QtCore_debug                  	0x0172115a QThread::exec() + 144
9   QtCore_debug                  	0x0172346d QThreadPrivate::start(void*) + 279
10  libSystem.B_debug.dylib       	0x01c4d29b _pthread_start + 503
11  libSystem.B_debug.dylib       	0x01c4d072 thread_start + 34

Thread 0 crashed with X86 Thread State (32-bit):
  eax: 0x01f8ebcc  ebx: 0x0014e51e  ecx: 0x02baaa84  edx: 0x00000000
  edi: 0x01f86410  esi: 0x02baaa80  ebp: 0xbfffc3d8  esp: 0xbfffc3d4
   ss: 0x0000001f  efl: 0x00010206  eip: 0x00154edf   cs: 0x00000017
   ds: 0x0000001f   es: 0x0000001f   fs: 0x00000000   gs: 0x00000037
  cr2: 0x00000000

Tulon
Posts: 687
Joined: 03 Oct 2009, 06:13
Number of books owned: 0
Location: London, UK
Contact:

Re: Mac problem - contextual menus cause crash

Post by Tulon » 29 Oct 2010, 06:17

n9yty wrote:Before I tried that, though, I thought, well, why not do it synchronously...
That's not so good. Asynchronous mode is necessary to resolve ambiguities when you have overlapping zones and you right click in the overlapped area.

We have here a design issue with the QMenu class. What I need is a signal / event like "dismissed without activating any items". Not only they don't provide such an event, but they also don't have a "finalizer"-type of event, where I would be able check if any items were activated. The aboutToHide() signal is totally useless for this purpose, as item activation may or may not happen some time after it.

There is yet another workaround we could try, not as clean as I before though:
We could delay the menuAboutToHide() slot more than once. We already delay it by putting it on a QueuedConnection, so let's delay it once or twice more.
Just have a counter inside the object, and at the beginning of menuAboutToHide() do the following:

Code: Select all

if (m_extraDelaysDone < 1) {
  ++m_extraDelaysDone;
  QTimer::singleShot(0, this, SLOT(menuAboutToHide());
  return;
}
Scan Tailor experimental doesn't output 96 DPI images. It's just what your software shows when DPI information is missing. Usually what you get is input DPI times the resolution enhancement factor.

User avatar
n9yty
Posts: 72
Joined: 25 Jul 2010, 22:13

Re: Mac problem - contextual menus cause crash

Post by n9yty » 29 Oct 2010, 11:06

Tulon wrote:We have here a design issue with the QMenu class. What I need is a signal / event like "dismissed without activating any items". Not only they don't provide such an event, but they also don't have a "finalizer"-type of event, where I would be able check if any items were activated. The aboutToHide() signal is totally useless for this purpose, as item activation may or may not happen some time after it.
I am back to working to achieve this through the subclassing of QMenu. Trying your other suggestion of delaying yet-again the handling of the signal failed, because even with the QTimer re-sending it the signal was arriving before the triggered() signal did. If I changed the QTimer to fire a second or so later then it would work, but of course if you dismissed a menu it would not be available again until the timer had expired. And I wonder how reliable a fixed delay like that is when you start running it on various computers of different processing speeds or processor loads at a given time. There is no way to know how long it would take for the triggered() signal to fire and be processed.

I have made progress on capturing the kind of signal needed in the QMenu subclass, it is working but I can, through some creative clicking and mouse maneuvering, trigger a Qt crash. So I am working to avoid that now and will send you a patch to examine soon.

Tulon
Posts: 687
Joined: 03 Oct 2009, 06:13
Number of books owned: 0
Location: London, UK
Contact:

Re: Mac problem - contextual menus cause crash

Post by Tulon » 29 Oct 2010, 11:17

n9yty wrote:I have made progress on capturing the kind of signal needed in the QMenu subclass, it is working but I can, through some creative clicking and mouse maneuvering, trigger a Qt crash.
Keep in mind that when you override event handlers, you generally have to call their base versions, like this:

Code: Select all

void
MyMenu::hideEvent(QHideEvent* event)
{
    QMenu::hideEvent(event);
    // Do more stuff.
}
Scan Tailor experimental doesn't output 96 DPI images. It's just what your software shows when DPI information is missing. Usually what you get is input DPI times the resolution enhancement factor.

User avatar
n9yty
Posts: 72
Joined: 25 Jul 2010, 22:13

Re: Mac problem - contextual menus cause crash

Post by n9yty » 29 Oct 2010, 13:19

Tulon wrote:Keep in mind that when you override event handlers, you generally have to call their base versions
Right, I have that, there is special care needed to handle knowing when to send the "didHide" kind of signal with respect to mouse events/etc... But I have it working now, sending you the patch info shortly. You will surely want to clean things up, I have not done any C++ before, so it will need TLC, but hopefully less work than starting from zero.

-Steve

User avatar
n9yty
Posts: 72
Joined: 25 Jul 2010, 22:13

Re: Mac problem - contextual menus cause crash

Post by n9yty » 01 Nov 2010, 11:31

If anyone on the Mac would like to try this and verify that it fixes the problem for them, here is the location of a 0.9.9.2 build with the mac fixes... updated with keystroke fix.

http://www.4shared.com/file/-BwOoBST/Sc ... acfix.html

MD5 (ScanTailor-0.9.9.2-macfix.dmg) = 2f716aa649a3f8507b93a722d9278ddf
Last edited by n9yty on 01 Nov 2010, 15:56, edited 1 time in total.

Post Reply