Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: wizzard on March 31, 2007, 07:25:21 pm

Title: 2.8 Compilation Error: CentreOnWindow
Post by: wizzard on March 31, 2007, 07:25:21 pm
When compiling on Arch Linux (wxGTK 2.8) I got the following compilation error:

g++ -DHAVE_CONFIG_H -I. -I../../src/include -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -I../../src/include -I../../src/include/wxscintilla/include -I../../src/include/tinyxml -I../../src/include/scripting/include -I../../src/include/scripting/sqplus -I../../src/include/wxFlatNotebook/include -I../../src/include/propgrid/include -Ulinux -Uunix -O2 -ffast-math -g -O2 -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexceptions -MT globals.lo -MD -MP -MF .deps/globals.Tpo -c globals.cpp  -fPIC -DPIC -o .libs/globals.o
globals.cpp: In function 'void PlaceWindow(wxWindow*, cbPlaceDialogMode, bool)':
globals.cpp:875: error: 'class wxWindow' has no member named 'CentreOnScreen'
make[3]: *** [globals.lo] Error 1


commenting out the line allows me to compile & run. I have no idea why it gives that error, I looked up CentreOnScreen in the wxWidgets manual and yes it is a member function...
Title: Re: 2.8 Compilation Error: CentreOnWindow
Post by: Biplab on March 31, 2007, 07:39:20 pm
AFAIK, this function has been deprecated in wx 2.8.

Just replace CentreOnScreen() to
Code
Centre(wxCENTRE_ON_SCREEN)

Couple of wx2.8 related patches have been reverted recently which is causing this compilation error. :)
Title: Re: 2.8 Compilation Error: CentreOnWindow
Post by: stahta01 on April 01, 2007, 12:50:26 am
My patch for this was [ Patch #1762 ] CentreOnScreen patch for wxWidgets 2.8

http://developer.berlios.de/patch/?func=detailpatch&patch_id=1762&group_id=5358

What version number of wxWidgets 2.8 has this problem?

Change it to
Code
Centre(wxBOTH | wxCENTRE_ON_SCREEN)

Tim S
Title: Re: 2.8 Compilation Error: CentreOnWindow
Post by: killerbot on April 01, 2007, 09:47:54 am
Thomas has reverted some of those patches. From the explanation he gave me, I think he is correct. A few places didn't need the patch. And for the other places of reversal to work he adjusted globals.cpp

Code
void PlaceWindow(wxToplevelWindow *w, cbPlaceDialogMode mode, bool enforce)

PlaceWindows now takes a wxToplevelWindow pointer instead of a wxWindow pointer.

BUT, afb has reverted later on this back to wxWindow*. The commit comments were :
Quote
- didn't compile, wxToplevelWindow -> wxWindow

@Afb : what exactly didn't compile ??

At the others, try to build with the PlaceWindow taking the wxToplevelWindow*, and see what happens and report back here if you can.
Title: Re: 2.8 Compilation Error: CentreOnWindow
Post by: afb on April 01, 2007, 09:49:55 am
Sorry, the compilation problems seem to have been all mine. But it was changed in once place (the source) and not in th other (the header) - as long as it is changed in both it works just fine.

as in: go right ahead and change wxWindow to wxToplevelWindow
Title: Re: 2.8 Compilation Error: CentreOnWindow
Post by: killerbot on April 01, 2007, 09:52:36 am
ok, I will do that, build on windows and commit. Will check later on in linux.
Title: Re: 2.8 Compilation Error: CentreOnWindow
Post by: afb on April 01, 2007, 09:57:01 am
It built OK for wxMac 2.8 in my sandbox, but that also had all the patches/changes.
Title: Re: 2.8 Compilation Error: CentreOnWindow
Post by: killerbot on April 01, 2007, 10:33:54 am
committed, BUT doesn't build on linux --> working on it

undefined references to PlaceWindow --> hmm strange, and make clean was of no help

FIXED :I hate ifdefs
Title: Re: 2.8 Compilation Error: CentreOnWindow
Post by: thomas on April 02, 2007, 10:25:12 am
committed, BUT doesn't build on linux --> working on it

undefined references to PlaceWindow --> hmm strange, and make clean was of no help

FIXED :I hate ifdefs
Hahaha... that was why I reverted Patch #1762. :)

You are really unable to tell what's going on with all those #ifdefs. Save the whales, kill #ifdefs instead :)

@Tim:
Although your patch did work just fine (thanks for spotting the issue, above all), I did not like it, sorry :P
For PlaceWindow, it really only makes sense to work on wxToplevelWindow*, if one thinks about it. I originally implemented it to take a wxWindow* because that was the class which contained all the CentreXXX functions (and still does in 2.8, according to the documentation!). The documentation would say "no effect on non-toplevel windows" and I said "yeah, fine with me, makes sense".
It would of course have been no mistake (and maybe more logical) to use wxToplevelWindow* in the first place, since you really only want to position dialogs and frames.

Now, they secretly moved those functions into wxTopLevelWindow (without updating the documentation, and without a fallback), so it would suddenly no longer compile.
Changing the function signature works fine for all versions, and takes no #ifdefs, which is more readable.

As to the other two locations in the reverted patch, cbSplashScreen is a wxFrame (thus it is a wxTopLevelWindow), so it is not necessary to patch anything here.
The call to PlaceWindow inside the config panel dialog is wrong alltogether. It is a relict from the times before all config panels were placed inside a list view (where it of course no longer makes sense to center anything on screen). It used to work without problems in 2.6, so nobody ever noticed. But, the correct solution here is to just delete the offending code alltogether.
Title: Re: 2.8 Compilation Error: CentreOnWindow
Post by: stahta01 on April 02, 2007, 10:44:36 am
@Tim:
Although your patch did work just fine (thanks for spotting the issue, above all), I did not like it, sorry :P
For PlaceWindow, it really only makes sense to work on wxToplevelWindow*, if one thinks about it. I originally implemented it to take a wxWindow* because that was the class which contained all the CentreXXX functions (and still does in 2.8, according to the documentation!). The documentation would say "no effect on non-toplevel windows" and I said "yeah, fine with me, makes sense".
It would of course have been no mistake (and maybe more logical) to use wxToplevelWindow* in the first place, since you really only want to position dialogs and frames.

Yeah, you solution is much better than mine was, but I did NOT know enough to do your's at the time.
Do NOT think that I would have seen it even if I fixed it now.

Tim S
Title: Re: 2.8 Compilation Error: CentreOnWindow
Post by: killerbot on April 02, 2007, 11:00:49 am
the good thing is, all together we fixed it and ended up with a good solution.
Community team work rules ;-)