User forums > General (but related to Code::Blocks)

Alert message box jumps if I open the compiler setting dialog

<< < (3/3)

ollydbg:
I tested the stc sample of the wxWidgets 3.1.3.

I change the line of the 610 of the source file wxWidgets-3.1.3\samples\stc\edit.cpp like below


--- Code: ---    // default fonts for all styles!
    int Nr;
    for (Nr = 0; Nr < wxSTC_STYLE_LASTPREDEFINED; Nr++) {
        //wxFont font(wxFontInfo(10).Family(wxFONTFAMILY_MODERN));
        wxFont font(wxFontInfo(16).FaceName("Terminus"));
        StyleSetFont (Nr, font);
    }

--- End code ---

I see that this Terminus font is shown in the result edit control. So, this means stc sample correctly loads the user defined font.

ollydbg:

--- Code: ---    wxString fontstring = mgr->Read(_T("/font"), wxEmptyString);

    if (!fontstring.IsEmpty())
    {
        wxNativeFontInfo nfi;
        nfi.FromString(fontstring);
        font.SetNativeFontInfo(nfi);
    }

--- End code ---

In this code(in C::B source sdk\cbeditor.cpp), I get the fontstring

--- Code: ---1;13.8;-23;0;0;0;400;0;0;0;0;1;2;1;49;Terminus
--- End code ---
I have also get another string like:

--- Code: ---1;10.2;-17;0;0;0;400;0;0;0;0;3;2;1;49;Courier New
--- End code ---


This get failed in the check: "wxASSERT(numWeight > 0);" in file:


--- Code: ---https://github.com/wxWidgets/wxWidgets/blob/db2e571c1b9ec414ec261b8f3227622989a15937/include/wx/font.h#L277
--- End code ---


--- Code: ---    // Another helper for converting arbitrary numeric weight to the closest
    // value of wxFontWeight enum. It should be avoided in the new code (also
    // note that the function for the conversion in the other direction is
    // trivial and so is not provided, we only have GetNumericWeightOf() which
    // contains backwards compatibility hacks, but we don't need it here).
    static wxFontWeight GetWeightClosestToNumericValue(int numWeight)
    {
        wxASSERT(numWeight > 0);
        wxASSERT(numWeight <= 1000);

        // round to nearest hundredth = wxFONTWEIGHT_ constant
        int weight = ((numWeight + 50) / 100) * 100;

        if (weight < wxFONTWEIGHT_THIN)
            weight = wxFONTWEIGHT_THIN;
        if (weight > wxFONTWEIGHT_MAX)
            weight = wxFONTWEIGHT_MAX;

        return static_cast<wxFontWeight>(weight);
    }

--- End code ---

Those string are some OS dependent string saved by the function: (See document here: https://docs.wxwidgets.org/3.0/classwx_font.html#ac78bab66824b38f42669cfc0b4dc7c9f)


--- Quote ---wxString wxFont::GetNativeFontInfoDesc    (       )    const

Returns the platform-dependent string completely describing this font.

Returned string is always non-empty unless the font is invalid (in which case an assert is triggered).

Note that the returned string is not meant to be shown or edited by the user: a typical use of this function is for serializing in string-form a wxFont object.

See also
    SetNativeFontInfo(), GetNativeFontInfoUserDesc()


--- End quote ---

Is the negative number wrong in the font string?

I see the string is saved in the font setting dialog: in file: src\editorconfigurationdlg.cpp

--- Code: ---void EditorConfigurationDlg::EndModal(int retCode)
{
    if (retCode == wxID_OK)
    {
        ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("editor"));

        cfg->Write(_T("/font"), XRCCTRL(*this, "lblEditorFont", wxStaticText)->GetFont().GetNativeFontInfoDesc());


--- End code ---

ollydbg:
OK, it is a wx bug.

I just reproduce this bug in wx3.1.3's sample font.

First, I can set a font in the setting dialog, and it shows such dialog: See screen shot below.

Second, I use the menu->Font->set native font description, this also pops up the same alert message box as in C::B.

ollydbg:
https://groups.google.com/d/msg/wx-users/DGJvUd-314A/t745N9XvAQAJ
The wx dev thought it is a bug, and they will be fixed soon.

ollydbg:
#18590 (Font description string Get and Set bug in wx3.1.3 on Windows 32bit build) – wxWidgets
This bug is fixed already.

Navigation

[0] Message Index

[*] Previous page

Go to full version