matlo / GIMX

The GIMX software.
GNU General Public License v3.0
590 stars 105 forks source link

gui: Update deprecated calls to wxFont #677

Closed brianredbeard closed 3 years ago

brianredbeard commented 3 years ago

In 2014, a deprecation was announced changing how wxFont is called to ensure stronger typing (http://trac.wxwidgets.org/ticket/15814). This change was introduced in version 2.9.5 of wxWidgets.

Compiling with a recent version of GCC (10.2.1) surfaces these warnings as errors due to the flag ``.

The error presented is:

‘wxFont::wxFont(int, int, int, int, bool, const wxString&, wxFontEncoding)’ is deprecated: use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants

Additionally, the documentation now suggests the use of a helper class (wxFontInfo) instead of directly calling the wxFont constructor.

https://docs.wxwidgets.org/3.1/classwx_font_info.html

brianredbeard commented 3 years ago

FYI, it doesn't seem to be related but I'm running into other errors wxWidgets when running gimx-config:

../src/common/sizer.cpp(1487): assert "!(flags & (wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL)) || !(flags & (wxALIGN_RIGHT | wxALIGN_CENTRE_HORIZONTAL))" failed in DoInsert(): wxEXPAND flag will be overridden by alignment flags
brianredbeard commented 3 years ago

Digging further, it seems to be specifically: https://github.com/matlo/GIMX/blob/65252d2b6248953048be9952744339f78470157c/config/gimx-config.cpp#L717

This is the full stack trace:

Breakpoint 3 at 0x449f10: file gimx-config.cpp, line 717.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /usr/bin/gimx-config 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffe6f21640 (LWP 7780)]
[New Thread 0x7fffe6720640 (LWP 7781)]
[New Thread 0x7fffe5ef5640 (LWP 7782)]
[New Thread 0x7fffe56f0640 (LWP 7783)]
[Detaching after vfork from child process 7784]
[Detaching after vfork from child process 7786]
[Detaching after vfork from child process 7788]
[Detaching after vfork from child process 7790]

Thread 1 "gimx-config" hit Breakpoint 3, configFrame::configFrame (this=this@entry=0x7cac00, file=..., parent=parent@entry=0x0, id=id@entry=-1)
    at gimx-config.cpp:717
717    FlexGridSizer17->Add(StaticBoxSizer9, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
(gdb) s
wxSizer::Add (this=0x5511b0, sizer=0x5f2290, flag=10736, userData=0x0, border=5, proportion=1) at /usr/include/wx-3.1/wx/sizer.h:1181
1181       return Add( new wxSizerItem( sizer, proportion, flag, border, userData ) );
(gdb) s
operator new (sz=sz@entry=96) at ../../../../libstdc++-v3/libsupc++/new_op.cc:43
43  {
(gdb) 
47   if (__builtin_expect (sz == 0, false))
(gdb) 
[Thread 0x7fffe6720640 (LWP 7781) exited]
50   while ((p = malloc (sz)) == 0)
(gdb) 
wxSizerItem::wxSizerItem (this=<optimized out>, sizer=<optimized out>, proportion=<optimized out>, flag=<optimized out>, border=<optimized out>, 
    userData=<optimized out>, this=<optimized out>, sizer=<optimized out>, proportion=<optimized out>, flag=<optimized out>, 
    border=<optimized out>, userData=<optimized out>) at ../include/wx/object.h:354
354    wxObject() { m_refData = NULL; }
(gdb) s
239             m_userData(userData)
(gdb) 
0x00007ffff7ab31f7 in wxObject::wxObject (this=<optimized out>, this=<optimized out>) at ../include/wx/object.h:354
354    wxObject() { m_refData = NULL; }
(gdb) 
280    wxSize() : x(0), y(0) { }
(gdb) 
239             m_userData(userData)
(gdb) 
0x00007ffff7ab321a in wxPoint::wxPoint (this=<optimized out>) at ../include/wx/gdicmn.h:568
568    wxPoint() : x(0), y(0) { }
(gdb) 
722    wxRect()
(gdb) 
239             m_userData(userData)
(gdb) 
0x00007ffff7ab3235 in wxRect::wxRect (this=<optimized out>) at ../include/wx/gdicmn.h:723
723        : x(0), y(0), width(0), height(0)
(gdb) 
241    ASSERT_VALID_SIZER_FLAGS( m_flag );
(gdb) 
243    DoSetSizer(sizer);
(gdb) 
wxSizerItem::DoSetSizer (this=this@entry=0x806160, sizer=sizer@entry=0x5f2290) at ../src/common/sizer.cpp:223
223    m_kind = Item_Sizer;
(gdb) 
224    m_sizer = sizer;
(gdb) 
wxSizer::Add (this=0x5511b0, sizer=0x5f2290, flag=10736, userData=0x0, border=5, proportion=1) at /usr/include/wx-3.1/wx/sizer.h:1181
1181       return Add( new wxSizerItem( sizer, proportion, flag, border, userData ) );
(gdb) 
wxSizer::Add (item=0x806160, this=0x5511b0) at /usr/include/wx-3.1/wx/sizer.h:1169
1169       return Insert( m_children.GetCount(), item );
(gdb) 
0x000000000041fec1 in wxListBase::GetCount (this=<optimized out>) at /usr/include/wx-3.1/wx/list.h:455
455    size_t GetCount() const { return m_count; }
(gdb) 
wxListBase::GetCount (this=<optimized out>) at /usr/include/wx-3.1/wx/list.h:455
455    size_t GetCount() const { return m_count; }
(gdb) 
1181       return Add( new wxSizerItem( sizer, proportion, flag, border, userData ) );
(gdb) 
0x000000000041fef4 in wxSizer::Add (item=0x806160, this=0x5511b0) at /usr/include/wx-3.1/wx/sizer.h:1169
1169       return Insert( m_children.GetCount(), item );
(gdb) 
1181       return Add( new wxSizerItem( sizer, proportion, flag, border, userData ) );
(gdb) 
0x000000000041ff01 in wxSizer::Add (item=0x806160, this=0x5511b0) at /usr/include/wx-3.1/wx/sizer.h:1169
1169       return Insert( m_children.GetCount(), item );
(gdb) 
wxSizer::Insert (this=0x5511b0, index=0, item=0x806160) at ../include/wx/sizer.h:1162
1162       return DoInsert(index, item);
(gdb) 
wxGridSizer::DoInsert (this=0x5511b0, index=0, item=0x806160) at ../src/common/sizer.cpp:1454
1454    {
(gdb) 
1459       if ( m_cols && m_rows )
(gdb) 
1462           if ( nitems == m_cols*m_rows )
(gdb) 
1483       const int flags = item->GetFlag();
(gdb) 
wxSizerItem::GetFlag (this=0x806160) at ../include/wx/sizer.h:376
376        { return m_flag; }
(gdb) 
wxGridSizer::DoInsert (this=0x5511b0, index=0, item=0x806160) at ../src/common/sizer.cpp:1484
1484       if ( flags & wxEXPAND )
(gdb) 
1487           wxASSERT_MSG
(gdb) 
wxOnAssert (file=0x7ffff7c21274 "../src/common/sizer.cpp", line=1487, func=0x7ffff7c1d0ce "DoInsert", 
    cond=0x7ffff7c22e40 "!(flags & (wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL)) || !(flags & (wxALIGN_RIGHT | wxALIGN_CENTRE_HORIZONTAL))", 
    msg=0x7ffff7c22788 L"wxEXPAND flag will be overridden by alignment flags") at ../src/common/appbase.cpp:1260

I'd say I'm pretty confident that this is related to wxWidgets 3.1.x in general and not these specific changes, but (to be fair) I've never even looked into the API before trying to get GIMX working.

matlo commented 3 years ago

This code section is generated by codeblocks+wxsmith. I generated the code again using the latest codeblocks+wxsmith versions available on my distro (Linux Mint 20), and observed changes on these lines. I pushed the changes in the refresh-gui-code branch. Please check if these changes fix your compilation issue.

brianredbeard commented 3 years ago

Confirmed. Compilation issues resolved. Thanks!

matlo commented 3 years ago

I pushed the changes to the master branch and deleted the refresh-gui-files one. Thanks!