gtk scroll assertion dialog box on app open

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
rayarachelian
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Oct 07, 2015 7:57 pm

gtk scroll assertion dialog box on app open

Post by rayarachelian »

Hi, I've recently ported my project (lisaem) to the Raspbery Pi on Raspbian.

I've built both an old copy of 2.9.5 (I know, not stable), and also the latest stable 3.0.3 and both generate this error:

"../src/gtk/scrolwin.cpp(205): assert "scrolled" failed in DoShowScrollbars(): window must be created"

I'm guessing it means that a scroll widget might be instantiated before a window has been created?


Has anyone dealt with this before? Anything in particular I should change in my code to to prevent this from coming up?

Thanks.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: gtk scroll assertion dialog box on app open

Post by doublemax »

I've recently ported my project (lisaem) to the Raspbery Pi on Raspbian.
So are you saying that the same code worked fine on another platform?
"../src/gtk/scrolwin.cpp(205): assert "scrolled" failed in DoShowScrollbars(): window must be created"
I'm guessing it means that a scroll widget might be instantiated before a window has been created?
It means that somewhere, someone is trying to set the scrollbars before the window is fully created. But without seeing code it's hard to say more. Is there anything special regarding the particular window that causes this assert?
Use the source, Luke!
rayarachelian
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Oct 07, 2015 7:57 pm

Re: gtk scroll assertion dialog box on app open

Post by rayarachelian »

Yes, exactly, the same code works on OS X and Windows without that message.

Code is here: https://github.com/rayarachelian/lisaem ... aem_wx.cpp
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: gtk scroll assertion dialog box on app open

Post by doublemax »

That's a little too much code to look through. I did a text search for scroll related things, but nothing caught my eye. So we'll need at least a backtrace to see which call in your code triggers the assert.
Use the source, Luke!
rayarachelian
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Oct 07, 2015 7:57 pm

Re: gtk scroll assertion dialog box on app open

Post by rayarachelian »

This is the backtrace from Linux with wx3.0.2:

ASSERT INFO:
../src/gtk/scrolwin.cpp(205): assert "scrolled" failed in DoShowScrollbars(): window must be created

BACKTRACE:
[1] wxScrollHelper::DoShowScrollbars(wxScrollbarVisibility, wxScrollbarVisibility) /home/ray/wxWidgets-3.0.2/build-gtk/../src/gtk/scrolwin.cpp:205
[2] wxScrolled<wxPanel>::Create(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&) /usr/local/wx3.0.2-gtk/include/wx-3.0/wx/scrolwin.h:427
[3] LisaEmFrame::LisaEmFrame(wxString const&) /home/ray/lisaem-1.2.6.2/wxui/lisaem_wx.cpp:5138
[4] LisaEmApp::OnInit() /home/ray/lisaem-1.2.6.2/wxui/lisaem_wx.cpp:1774
[5] wxEntry(int&, wchar_t**) /home/ray/wxWidgets-3.0.2/build-gtk/../src/common/init.cpp:479
[6] wxEntry(int&, char**) /home/ray/wxWidgets-3.0.2/build-gtk/../src/common/init.cpp:508
[7] main /home/ray/lisaem-1.2.6.2/wxui/lisaem_wx.cpp:1725
[8] __libc_start_main
[9] _start


5138 if (!my_lisawin) my_lisawin = new LisaWin(this);

and the LisaWin class extends wxScrolledWindow:

271 class LisaWin : public wxScrolledWindow
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: gtk scroll assertion dialog box on app open

Post by doublemax »

Sorry, i have no explanation for this.

Things you can try now:

- check if any of the wxWidgets samples shows the same problem
- if not, try to create a minimal compilable sample that creates the assert

- single-step through the LisaWin ctor and check what's going wrong
Use the source, Luke!
rayarachelian
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Oct 07, 2015 7:57 pm

Re: gtk scroll assertion dialog box on app open

Post by rayarachelian »

Will do.

I did find this, which might be related: https://lists.launchpad.net/kicad-devel ... 17114.html

But, D'oh! :lol: I found the problem, I had been compiling wxWidgets with debug enabled from when I was trying to capture all the errors and warnings in my own code to get hints as to what code to fix.

Disabling it in the configure step gets rid of the message and all is good.

There's still a question as to why gtk complains about scrollable windows, but that's less important.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: gtk scroll assertion dialog box on app open

Post by doublemax »

I did find this, which might be related: https://lists.launchpad.net/kicad-devel ... 17114.html
Yes, that sounds like the same problem. The solution seems to be to not set the wxALWAYS_SHOW_SB flag.
Disabling it in the configure step gets rid of the message and all is good.
Not really, you just silenced the assert. The problem is still there.
Use the source, Luke!
rayarachelian
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Oct 07, 2015 7:57 pm

Re: gtk scroll assertion dialog box on app open

Post by rayarachelian »

Well yes, but now I can work on turning this into a .deb package.
Tony0945
Earned some good credits
Earned some good credits
Posts: 105
Joined: Wed Oct 21, 2009 4:02 pm

Re: gtk scroll assertion dialog box on app open

Post by Tony0945 »

This is the code that triggers the ASSERT:

Code: Select all

void wxScrollHelper::DoShowScrollbars(wxScrollbarVisibility horz,
                                      wxScrollbarVisibility vert)
{
    GtkScrolledWindow * const scrolled = GTK_SCROLLED_WINDOW(m_win->m_widget);
    wxCHECK_RET( scrolled, "window must be created" );

    gtk_scrolled_window_set_policy(scrolled,
                                   GtkPolicyFromWX(horz),
                                   GtkPolicyFromWX(vert));
}

Apparently, the macro is returning a null pointer. The message is very unclear because this code is called from somewhere in the window creation code, so the "window must be created" message isn't helpful. If anything, I would patch the code to return rather than ignore the null pointer.

Gdb tells me that this is called from somewhere in a chain from generic/grid.cpp:

Code: Select all

bool wxGrid::Create(wxWindow *parent, wxWindowID id,
                          const wxPoint& pos, const wxSize& size,
                          long style, const wxString& name)
{
    if (!wxScrolledWindow::Create(parent, id, pos, size,
                                  style | wxWANTS_CHARS, name))
        return false;

    m_colMinWidths = wxLongToLongHashMap(GRID_HASH_SIZE);
    m_rowMinHeights = wxLongToLongHashMap(GRID_HASH_SIZE);

    Create();
    SetInitialSize(size);
    CalcDimensions();

    return true;
}
I don't understand the second Create(); is that wxGrid:Create() or wxScrolledWindow::Create()? In either case I don't see any documentation of Create() with no parameters.

The problem seems to be with wxALWAYS_SHOW_SB. It appears this is not allowed in wxGTK, but the documentation doesn't say this, so it is at least a documentation bug.

I'm annoyed too. With the help of doublemax, I have my application running great on Windows and, like you, it appears to work on Linux except to the annoying ASSET message. I'd hate to have to run it under WINE instead of natively.
Tony0945
Earned some good credits
Earned some good credits
Posts: 105
Joined: Wed Oct 21, 2009 4:02 pm

Re: gtk scroll assertion dialog box on app open

Post by Tony0945 »

wxCHECK_RET is defined here: http://docs.wxwidgets.org/trunk/group__ ... 6b434fd0bd
It says that the check is made and returns if the condition is false, so rather than just comment it out, you should replace it with something like:

Code: Select all

if (!scrolled) return;
Tony0945
Earned some good credits
Earned some good credits
Posts: 105
Joined: Wed Oct 21, 2009 4:02 pm

Re: gtk scroll assertion dialog box on app open

Post by Tony0945 »

FOUND THE BUG!

In /include/wx/scrollwin.h near line 425, the present code is:

Code: Select all

#ifdef __WXOSX__
        bool retval = T::Create(parent, winid, pos, size, style, name);
        if ( retval && (style & wxALWAYS_SHOW_SB) )
            ShowScrollbars(wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS);
        return retval;
#else
        if ( style & wxALWAYS_SHOW_SB )
            ShowScrollbars(wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS);

        return T::Create(parent, winid, pos, size, style, name);
#endif
This should be changed to:

Code: Select all

#ifndef __WXMSW__
        bool retval = T::Create(parent, winid, pos, size, style, name);
        if ( retval && (style & wxALWAYS_SHOW_SB) )
            ShowScrollbars(wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS);
        return retval;
#else
        if ( style & wxALWAYS_SHOW_SB )
            ShowScrollbars(wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS);

        return T::Create(parent, winid, pos, size, style, name);
#endif
because this code works on Windows but not Linux or OSX.

At the least it should be:

Code: Select all

#if defined(__WXOSX__) || defined(__WXGTK__)
        bool retval = T::Create(parent, winid, pos, size, style, name);
        if ( retval && (style & wxALWAYS_SHOW_SB) )
            ShowScrollbars(wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS);
        return retval;
#else
        if ( style & wxALWAYS_SHOW_SB )
            ShowScrollbars(wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS);

        return T::Create(parent, winid, pos, size, style, name);
#endif
I have no idea where to submit this bug report.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: gtk scroll assertion dialog box on app open

Post by doublemax »

I have no idea where to submit this bug report.
http://trac.wxwidgets.org/
Use the source, Luke!
Post Reply