Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#14052 closed defect (fixed)

wxTopLevelWindowGTK::IsMaximized causes segfault when m_widget is NULL (wxMessageDialog, for example)

Reported by: jonmarbach Owned by:
Priority: normal Milestone: 2.9.4
Component: wxGTK Version: 2.9.3
Keywords: CenterOnParent wxMessageDialog IsMaximized Cc:
Blocked By: Blocking:
Patch: no

Description

Briefest summary possible, the following code crashes on wxGTK:

wxMessageDialog warningPrompt( someWindow, someMessage );
warningPrompt.CenterOnParent(wxBOTH);

This is because, as of changeset 63171, CenterOnParent, which calls wxTopLevelWindowBase::DoCentre, calls IsMaximized().

In this case, but maybe others as well, wxTopLevelWindowGTK::m_widget is NULL, so when wxTopLevelWindowGTK::IsMaximized calls gtk_widget_get_window(m_widget), we get a segfault.

I don't know what the best solution would be, so I don't have a patch to submit. Maybe IsMaximized should return false if m_widget is NULL. Maybe wxMessageDialog should return true from IsAlwaysMaximized to shortcut ever calling IsMaximized.

Note: You can view some discussion about this problem here:
http://forums.wxwidgets.org/viewtopic.php?f=23&t=34024
But don't be fooled by the title of the post - the problem exists even if the dialog has a parent.

Thanks very much - and go easy on me - this is my first bug report!

Change History (2)

comment:1 Changed 9 years ago by PC

  • Resolution set to fixed
  • Status changed from new to closed

(In [70733]) avoid crash if IsMaximized() is called before native widget is created, fixes #14052

comment:2 Changed 9 years ago by PC

(In [70734]) Remove code to query GDK window origin from DoGetPosition(), it should not be necessary, and was probably wrong anyway.
This allows removing unnecessary assertions on m_widget (see #14052).
Also, avoid setting initial position to (-1,-1)

Note: See TracTickets for help on using tickets.