Project

General

Profile

Actions

Bug #14925

open
MS

WMenuItem: segfault later if set both checkable and icon

Bug #14925: WMenuItem: segfault later if set both checkable and icon

Added by Michael Seibt 11 days ago. Updated 10 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
Start date:
10/28/2026
Due date:
% Done:

0%

Estimated time:

Description

Affected WMenuItem of Wt 4.14.4 (and former versions)

segfault in WMenuItem::isChecked because the dev did not care about pointers!
At least, it could have been a clear exception easily by using reference cast dynamic_cast<WCheckBox &> in

    WCheckBox *cb = dynamic_cast<WCheckBox *>(anchor()->widget(0));
    return cb->isChecked();

STR:
run attached main.cpp
it contains:

setCheckable(true);
setIcon("some.ico");
log("trace") << "checkable " << isCheckable();
log("trace") << "checked   " << isChecked();

There is an indirect hint in the docs that checkable and icon were mutually exclusive (at setCheckable only):
"When an item is checkable, a checkbox is displayed to the left of the item text (instead of an icon)."
This is not necessary because it works well with the following workaround:

const bool checkable{isCheckable()};
setCheckable(false);
setIcon("some.ico");
setCheckable(checkable);

Files

main.cpp (2.2 KB) main.cpp Michael Seibt, 10/28/2026 09:30 AM

RM Updated by Romain Mardulyn 10 days ago Actions #1

  • Target version set to 4.16.0
Actions

Also available in: PDF Atom