← Back to team overview

kicad-developers team mailing list archive

Strange wxWidgets version checks

 

Hi all,

I've been going through the code removing redundant conditionally compiled
blocks for versions of wxWidgets before 3.0 as per the 'Conversion to
wxWidgets 3.0' section of the roadmap [1]. For the most part this is
straightforward as the wxCHECK_VERSION macro is used which makes the intent
clear. However I have run into a couple of cases using the major and minor
constants in a strange way which I want to run past the list first in case
my assumptions are wrong.

First, on common/draw_panel.cpp line 933 [2]:

  #if wxMAJOR_VERSION >= 2 && wxMINOR_VERSION >= 9
      int axis = event.GetWheelAxis();
  #else
      const int axis = 0;
  #endif

As it stands, this will be true for wxWidgets 2.9, 3.9, 3.10, 4.9 etc. I'm
pretty sure this is supposed to be checking for wxWidgets >= 2.9 since, as
far as I can tell, that was when GetWheelAxis() was added.

The second one is on line 32 of include/dialog_shim.h [3]:

  #if wxMINOR_VERSION == 8 && defined(__WXGTK__)
   #define DLGSHIM_USE_SETFOCUS 1
  #else
   #define DLGSHIM_USE_SETFOCUS 0
  #endif

I'm less sure about what this one is checking for. I suspect the #else case
can always be used (my guess is its meant to be either checking for version
== 2.8 or version < 3) as when it is set to 1 it overrides a wx function,
and presumably is doing so for backwards compatibility. Can somebody
confirm that for me?

If somebody can confirm or correct my assumptions about these two, then
I'll be able to finish testing the changes and submit a patch.

Thanks,
Blair


[1]
http://ci.kicad-pcb.org/job/kicad-doxygen/ws/Documentation/doxygen/html/md_Documentation_development_road-map.html#wxwidgets3
[2]
http://bazaar.launchpad.net/~kicad-product-committers/kicad/product/view/head:/common/draw_panel.cpp#L933
[3]
http://bazaar.launchpad.net/~kicad-product-committers/kicad/product/view/head:/include/dialog_shim.h#L32

Follow ups