Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#11616 closed defect (fixed)

OSX: Unable to use FlexGridSizer::Insert

Reported by: Mdx4 Owned by: csomor
Priority: normal Milestone: 2.9.2
Component: wxOSX-Cocoa Version: stable-latest
Keywords: FlexGridSizer Insert Cc:
Blocked By: Blocking:
Patch: yes

Description

Trying to compile the file layer_widget.cpp I obtain:

kicad-sources/pcbnew/layer_widget.cpp: In member function ‘void LAYER_WIDGET::insertLayerRow(int, const LAYER_SPEC&)’:
kicad-sources/pcbnew/layer_widget.cpp:275: error: no matching function for call to ‘wxFlexGridSizer::Insert(long unsigned int, wxStaticBitmap*&, wxSizerFlags&)’
wxWidgets/include/wx/sizer.h:736: note: candidates are: virtual wxSizerItem* wxGridSizer::Insert(size_t, wxSizerItem*)
kicad-sources/pcbnew/layer_widget.cpp:280: error: no matching function for call to ‘wxFlexGridSizer::Insert(long unsigned int, wxBitmapButton*&, wxSizerFlags&)’
wxWidgets/include/wx/sizer.h:736: note: candidates are: virtual wxSizerItem* wxGridSizer::Insert(size_t, wxSizerItem*)
kicad-sources/pcbnew/layer_widget.cpp:287: error: no matching function for call to ‘wxFlexGridSizer::Insert(long unsigned int, wxStaticText*&, wxSizerFlags&)’
wxWidgets/include/wx/sizer.h:736: note: candidates are: virtual wxSizerItem* wxGridSizer::Insert(size_t, wxSizerItem*)
kicad-sources/pcbnew/layer_widget.cpp:292: error: no matching function for call to ‘wxFlexGridSizer::Insert(long unsigned int, wxCheckBox*&, wxSizerFlags&)’
wxWidgets/include/wx/sizer.h:736: note: candidates are: virtual wxSizerItem* wxGridSizer::Insert(size_t, wxSizerItem*)

This code was reported to work with Linux but fails on OSX

I've resolved the issue changing commenting a virtual definition in wxGridSizer that overloads the one in wxSizer in sizer.h

Index: include/wx/sizer.h
===================================================================
--- include/wx/sizer.h	(revision 63050)
+++ include/wx/sizer.h	(working copy)
@@ -733,7 +733,7 @@
     wxGridSizer( int rows, int cols, int vgap, int hgap );
     wxGridSizer( int rows, int cols, const wxSize& gap );
 
-    virtual wxSizerItem *Insert(size_t index, wxSizerItem *item);
+    //virtual wxSizerItem *Insert(size_t index, wxSizerItem *item);
 
     virtual void RecalcSizes();
     virtual wxSize CalcMin();

I don't know if is a good approach or if i've done something wrong, feedbacks are appreciated.

--

Marco

Attachments (1)

GridSizerUsingInsert.patch download (359 bytes) - added by jatupper 4 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 4 years ago by jatupper

If you just comment out the wxGridSizer::Insert declaration, I'd think wx itself would have trouble building when it comes around to the wxGridSizer::Insert definition.

I'm attaching a patch that unhides the wxSizer::Insert functions.

Changed 4 years ago by jatupper

comment:2 Changed 4 years ago by Mdx4

Works great.

Thank you.

comment:3 Changed 4 years ago by csomor

  • Owner set to csomor
  • Status changed from new to accepted

could someone comment on whether I have to bracket this with something to avoid breaking builds with some older compilers ? I'll apply with a #ifdef WXOSX to be safe

comment:4 Changed 4 years ago by SC

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

(In [63179]) avoiding Insert shadowing superclass methods, closes #11616

comment:5 Changed 4 years ago by VZ

(In [63230]) Add virtual wxSizer::DoInsert() to replace Insert().

This allows to avoid problems with hiding all but the overridden overloads of
Insert() in wxSizer-derived classes, see #11616, without having to explicitly
write any using statements.

Keep Insert(size_t, wxSizerItem) virtual to allow the existing code overriding
it to keep working.

Note: See TracTickets for help on using tickets.