#18623: ../src/gtk/colour.cpp(218): assert ""IsOk()"" failed in Alpha(): invalid colour

39 views
Skip to first unread message

wxTrac

unread,
Dec 11, 2019, 5:54:37 AM12/11/19
to wx-...@googlegroups.com
#18623: ../src/gtk/colour.cpp(218): assert ""IsOk()"" failed in Alpha(): invalid
colour
-------------------------+-------------------------
Reporter: ettl.martin | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxGTK | Version: dev-latest
Keywords: assert | Blocked By:
Blocking: | Patch: 0
-------------------------+-------------------------
I am not sure if this is a bug or desired behavior. Calling
{{{wxColour::GetAsString()}}} from an {{{wxColour}}} object that is
initialized with {{{wxNullColour}}} behaves not consistent on Windows and
GTK.

{{{
#!c
wxColour c = wxNullColour;
wxString str = c.GetAsString();
// - The content of str on Windows is "rgba(0, 0, 0, 0.000)"
// and NO assert message is thrown
// - On wxGTK an assert message is thrown
/*../src/gtk/colour.cpp(218): assert ""IsOk()"" failed in Alpha():
invalid colour
../src/gtk/colour.cpp(185): assert ""IsOk()"" failed in Red():
invalid colour
../src/gtk/colour.cpp(196): assert ""IsOk()"" failed in Green():
invalid colour
../src/gtk/colour.cpp(207): assert ""IsOk()"" failed in Blue():
invalid colour*/
}}}

You can give it a try using the attached patch (minimal.patch)

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18623>

wxTrac

unread,
Dec 11, 2019, 5:55:20 AM12/11/19
to wx-...@googlegroups.com
#18623: ../src/gtk/colour.cpp(218): assert ""IsOk()"" failed in Alpha(): invalid
colour
--------------------------+------------------------
Reporter: ettl.martin | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxGTK | Version: dev-latest
Resolution: | Keywords: assert
Blocked By: | Blocking:
Patch: 0 |
--------------------------+------------------------
Changes (by ettl.martin):

* Attachment "minimal.patch" added.

modified minimal sample to demonstrate the issue

wxTrac

unread,
Dec 11, 2019, 7:05:44 AM12/11/19
to wx-...@googlegroups.com
#18623: ../src/gtk/colour.cpp(218): assert ""IsOk()"" failed in Alpha(): invalid
colour
--------------------------+-------------------------------------------
Reporter: ettl.martin | Owner:
Type: defect | Status: confirmed
Priority: normal | Milestone: 3.1.4
Component: wxGTK | Version: dev-latest
Resolution: | Keywords: assert wxColour inconsistency
Blocked By: | Blocking:
Patch: 0 |
--------------------------+-------------------------------------------
Changes (by vadz):

* status: new => confirmed
* keywords: assert => assert wxColour inconsistency
* milestone: => 3.1.4


Comment:

This is annoying because MSW behaviour doesn't really make sense, invalid
colour is not the same as fully transparent black, but we don't want to
break existing MSW code by starting to assert in this case.

I think it makes sense to just return an empty string from `GetAsString()`
if the colour is invalid, just as `wxToString(wxColour)` already does.
This would be a silent change under MSW, but changing the other ports to
return "(0, 0, 0, 0)" looks too unpalatable.

What do the others think?

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18623#comment:1>

wxTrac

unread,
Jul 11, 2020, 8:34:30 AM7/11/20
to wx-...@googlegroups.com
#18623: ../src/gtk/colour.cpp(218): assert ""IsOk()"" failed in Alpha(): invalid
colour
--------------------------+-------------------------------------------
Reporter: ettl.martin | Owner:
Type: defect | Status: confirmed
Priority: normal | Milestone: 3.1.4
Component: wxGTK | Version: dev-latest
Resolution: | Keywords: assert wxColour inconsistency
Blocked By: | Blocking:
Patch: 1 |
--------------------------+-------------------------------------------
Changes (by vadz):

* patch: 0 => 1


Comment:

As nobody objected, I've finally done this in
[https://github.com/wxWidgets/wxWidgets/pull/1947 this PR].

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18623#comment:2>

wxTrac

unread,
Jul 12, 2020, 4:37:22 PM7/12/20
to wx-...@googlegroups.com
#18623: ../src/gtk/colour.cpp(218): assert ""IsOk()"" failed in Alpha(): invalid
colour
--------------------------+-------------------------------------------
Reporter: ettl.martin | Owner: Vadim Zeitlin <vadim@…>
Type: defect | Status: closed
Priority: normal | Milestone: 3.1.4
Component: wxGTK | Version: dev-latest
Resolution: fixed | Keywords: assert wxColour inconsistency
Blocked By: | Blocking:
Patch: 1 |
--------------------------+-------------------------------------------
Changes (by Vadim Zeitlin <vadim@…>):

* owner: => Vadim Zeitlin <vadim@…>
* status: confirmed => closed
* resolution: => fixed


Comment:

In [changeset:"9890cf6bac143b07a15d5e1009e3a0c51ab1eee9/git-wxWidgets"
9890cf6b/git-wxWidgets]:
{{{
#!CommitTicketReference repository="git-wxWidgets"
revision="9890cf6bac143b07a15d5e1009e3a0c51ab1eee9"
Return empty string from wxColour::GetAsString() if it's invalid

This is consistent with wxToString(wxColour) and seems more useful than
either returning black string representation (as wxMSW used to do) or
asserting (as wxGTK did).

Document this behaviour and add a test checking for it.

Closes #18623.
}}}

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18623#comment:3>
Reply all
Reply to author
Forward
0 new messages