wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
6.2k stars 1.78k forks source link

wxDataView counterintuitive error message #19294

Closed wxtrac closed 3 years ago

wxtrac commented 3 years ago

Issue migrated from trac ticket # 19294

component: GUI-all | priority: low | resolution: fixed

2021-10-18 03:52:08: lhardt (lhardt) created the issue


(My version: wx3.0 - latest debian version)

I just passed through the painful experience of trying to resolve a bug in my code.

I have a wxDataviewColumn which is just a button. It was quite simple to make and did not produce errors of any kind in another computer of mine. I also had code in my ViewModel which looked like this:

        switch(col){
            case COL_ID: {
                variant = ...;
                break;
            }
            case COL_NAME: {
                variant = ...;
                break;
            }
                        ...
                        default: {
                // variant = wxT("XX");
                break;
            }

WxWidgets creates a log popup when a type mismatch occurs between the given value and the value defined in the wxDataviewCtrl definition.

The problem i see is: 1) The message given is "Wrong type, required: xxx but yyy". This message is both direct and misleading. From common sense, you would feel that 'xxx' is the type defined in ViewCtrl.AppendColumn, because it is requiring data from a certain type, in contrast to the "variant = ..." code, which gives a value that must comply with that type.

It was under that presumption that I spent quite some time debugging the wrong code. "required" here is a misnomer, and "but" does not give any information.

2) This is presented in a warning popup, and you can see "details" -- just a log giving 10x the same error. There is no "ignore this next time" checkbox like in assertion errors.

3) As the GetValueByRow function is called more or less a billion times a second, there is absolutely no way to close the window on time -- it will create another popup before you try. The next best option is killing the process.

wxtrac commented 3 years ago

2021-10-18 11:04:49: @vadz changed status from new to closed

2021-10-18 11:04:49: @vadz set resolution to fixed

2021-10-18 11:04:49: @vadz commented

The message has been improved and turned into a wxLogDebug() in 3.1, see a49567109a (Consistently check for type mismatch in all ports in wxDataViewCtrl., 2015-08-28) and now looks like the following

#!cpp
            // If you're seeing this message, this indicates that either your
            // renderer is using the wrong type, or your model returns values
            // of the wrong type.
            wxLogDebug("Wrong type returned from the model for column %u: "
                       "%s required but actual type is %s",
                       column,
                       GetVariantType(),
                       value.GetType());

which should hopefully be clear enough.