Page MenuHomePhabricator

Workbench crashes when accessing the "Hotkeys"-Preference page for the data manager (only debug)
Closed, ResolvedPublic

Description

To reproduce:

  1. Start MITK in debug-mode
  2. Press Ctrl+P or go to "Window -> Preference" to open the preference menu
  3. click on "DataManager -> Hotkeys"
  4. Experience a workbench crash in mitkBaseApplication. Output is:
259.56 core.mod.apputil.baseApp ERROR: ASSERT: "uint(i) < uint(size())" in file c:\users\qt\work\qt\qtbase\src\corelib\tools\qstring.h, line 1544

Event Timeline

kalali triaged this task as Normal priority.Aug 1 2018, 12:03 PM
kalali created this task.

The error seems to be in the QKeySequence.
Looks like Qt cannot handle the Ctrl+ sequence. Why is this only happening in debug mode?

However, even in release mode the Ctrl+-sequences do not work (e.g. try Ctrl+R for GlobalReinit).

The preference page does not show the Ctrl+-part of the sequence, but starts with a comma (e.g. , R). If the user changes a key sequence to a combination of Ctrl+letter, the sequence is recognized and shown as text in the line edit. If the user clicks on Ok and reopens the preference page, the Ctrl+-part is removed and the sequence starts with a comma again.

Apparently initializing a QKeySequence with QKeySequence(keyEvent->modifiers(), keyEvent->key()) does not work, since both arguments will be taken as individual integers, each representing a key. The first argument however is only a modifier and does not represent a real key - it can only be combined with a key. That's why the result is , Key, where the first key is not recognized.
Using QKeySequence(keyEvent->modifiers() + keyEvent->key()) solved this problem.