Author Topic: wx2.9 compatibility  (Read 14149 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
wx2.9 compatibility
« on: December 10, 2010, 05:03:23 am »
Unnecessary:
Code
#if wxCHECK_VERSION(2, 9, 0)
Manager::Get()->GetLogManager()->DebugLog(F(_T("workspace config: '%s'"), s.wx_str()));
#else
Manager::Get()->GetLogManager()->DebugLog(F(_T("workspace config: '%s'"), s.c_str()));
#endif
Only:
Code
Manager::Get()->GetLogManager()->DebugLog(F(_T("workspace config: '%s'"), s.wx_str()));

Unnecessary:
Code
#if wxCHECK_VERSION(2, 9, 0)
switch (str[pos].GetValue())
#else
switch (str[pos])
#endif
Only:
Code
switch ((wxChar)str[pos])
Or:
Code
switch ((wxChar)str.GetChar(pos))

Unnecessary:
Code
#if wxCHECK_VERSION(2, 9, 0)
str.Append(m_Buffer[startIndex], writeLen);
#else
str.Append(&m_Buffer[startIndex], writeLen);
#endif
Only:
Code
str.Append((const wxChar*)m_Buffer + startIndex, writeLen);



Unnecessary:
Code
#if wxCHECK_VERSION(2, 9, 0)
txtParent->SetLabel(wxString::Format(_T("%s (%d)"), _("<Global namespace>").wx_str(), m_Token->m_ParentIndex));
#else
txtParent->SetLabel(wxString::Format(_T("%s (%d)"), _("<Global namespace>"), m_Token->m_ParentIndex));
#endif
Only:
Code
txtParent->SetLabel(wxString::Format(_T("%s (%d)"), (const wxChar*)_("<Global namespace>"), m_Token->m_ParentIndex));

...

Any comments?
« Last Edit: December 10, 2010, 05:33:23 am by Loaden »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: wx2.9 compatibility
« Reply #1 on: December 10, 2010, 07:28:47 am »
just a personal taste, I am not so fond of all the casting ( in general).
But ifdefs are also not that nice.

Problem with the casts could be that some developers sees it, thinks it is not necessary and removes them again. And I guess only in 50% they will ne needed : 2.9.0 compared to earlier ...

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: wx2.9 compatibility
« Reply #2 on: December 10, 2010, 08:11:01 am »
It's not a matter of personal choice. Rather it's to provide a guaranteed compatibility upto wx 2.8.0. For example the following code may not work with wx-2.8.0 as wxString::wx_str() function was not available. At least it is missing in doc. IIRC it was added in the midst of wx 2.8 series.

Code
Manager::Get()->GetLogManager()->DebugLog(F(_T("workspace config: '%s'"), s.wx_str()));

As long as the modified code works both with wx-2.8.x and wx-2.9.x I'm ok with such change.
Be a part of the solution, not a part of the problem.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: wx2.9 compatibility
« Reply #3 on: December 10, 2010, 10:33:26 pm »
It's not a matter of personal choice. Rather it's to provide a guaranteed compatibility upto wx 2.8.0. For example the following code may not work with wx-2.8.0 as wxString::wx_str() function was not available. At least it is missing in doc. IIRC it was added in the midst of wx 2.8 series.

Code
Manager::Get()->GetLogManager()->DebugLog(F(_T("workspace config: '%s'"), s.wx_str()));

As long as the modified code works both with wx-2.8.x and wx-2.9.x I'm ok with such change.

It existed in 2.6 and 2.8 wxWidgets and likely 2.0. It was used in the past and was replaced with c_str() at some time. I think it was replaced by c_str() with the start of 2.0 wxWidgets.

Tim S.
« Last Edit: December 10, 2010, 10:39:17 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: wx2.9 compatibility
« Reply #4 on: December 11, 2010, 03:41:52 am »
It's not a matter of personal choice. Rather it's to provide a guaranteed compatibility upto wx 2.8.0. For example the following code may not work with wx-2.8.0 as wxString::wx_str() function was not available. At least it is missing in doc. IIRC it was added in the midst of wx 2.8 series.

Code
Manager::Get()->GetLogManager()->DebugLog(F(_T("workspace config: '%s'"), s.wx_str()));

As long as the modified code works both with wx-2.8.x and wx-2.9.x I'm ok with such change.

It existed in 2.6 and 2.8 wxWidgets and likely 2.0. It was used in the past and was replaced with c_str() at some time. I think it was replaced by c_str() with the start of 2.0 wxWidgets.

Tim S.

It is possible that it may have existed before wx-2.8.0. However in wx-2.8.0 doc it was undocumented. What I did was to ensure that our existing code is unaffected by the changes that I'm making for wx-2.9 migration.

Frankly speaking unless it is absoultely necessary I don't want to use any undocumented functions. Also a few #ifdef statements won't affect the final binary adversely even though it adds few lines to the source file. But it does what it is supposed to do; that is to not to break existing code.
Be a part of the solution, not a part of the problem.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: wx2.9 compatibility
« Reply #5 on: December 11, 2010, 10:48:30 am »
BTW: Is C::B usable with wx2.9.1?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: wx2.9 compatibility
« Reply #6 on: December 11, 2010, 01:25:31 pm »
BTW: Is C::B usable with wx2.9.1?

No, not fully usable. It crashes on exit, at least on 64 bit os.
Be a part of the solution, not a part of the problem.

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: wx2.9 compatibility
« Reply #7 on: December 11, 2010, 04:06:48 pm »
BTW: Is C::B usable with wx2.9.1?

No, not fully usable. It crashes on exit, at least on 64 bit os.

I think you can set "DEBUG_INFO=0 DEBUG_FLAG=0" on wx2.9.2svn compiling, then C::B works well when exit.
But if you use CC plugin, C::B may crash....
Regards,
xunxun

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: wx2.9 compatibility
« Reply #8 on: December 11, 2010, 04:22:44 pm »
CC crashes even with wx2.8
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: wx2.9 compatibility
« Reply #9 on: December 11, 2010, 04:37:23 pm »
BTW: Is C::B usable with wx2.9.1?

No, not fully usable. It crashes on exit, at least on 64 bit os.

I think you can set "DEBUG_INFO=0 DEBUG_FLAG=0" on wx2.9.2svn compiling, then C::B works well when exit.
But if you use CC plugin, C::B may crash....

I haven't tried wx trunk for a while. If it works then it'll be a good news.

The crash-on-exit I'm referring to is not due to CC. It's in C::B core and occurs every time C::B is closed.
Be a part of the solution, not a part of the problem.

daniloz

  • Guest
Re: wx2.9 compatibility
« Reply #10 on: December 11, 2010, 09:09:10 pm »
CC crashes even with wx2.8

What does that mean? If this is a known bug, is there any workaround? Any other wx version that could be used?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: wx2.9 compatibility
« Reply #11 on: December 11, 2010, 10:25:31 pm »
Means that the problem is in CC not in the wx version:)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: wx2.9 compatibility
« Reply #12 on: December 12, 2010, 10:19:59 am »
Means that the problem is in CC not in the wx version:)
No! It's wx problem, not CC.
If you apply this patch, then CC works well in wx-2.9.
Code
Index: src/plugins/codecompletion/nativeparser.cpp
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 6895)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -480,6 +480,7 @@
 
 void NativeParser::CreateClassBrowser()
 {
+    return; // avoid cc crash when use wx-2.9
     ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("code_completion"));
     if (!m_ClassBrowser && cfg->ReadBool(_T("/use_symbols_browser"), true))
     {

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: wx2.9 compatibility
« Reply #13 on: December 12, 2010, 11:24:21 am »
I'm using CC with 2.8 and it crashes sometimes, it is not too annoying, so I've not tried to catch it :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

daniloz

  • Guest
Re: wx2.9 compatibility
« Reply #14 on: December 13, 2010, 12:29:30 pm »
I am also using CC with 2.8.10 and it crashes or freezes from time to time. I have the impression that it is happening more often now... I have catch a few crashes and freezes and posted in this thread: http://forums.codeblocks.org/index.php/topic,13777.0.html
« Last Edit: December 13, 2010, 12:32:19 pm by daniloz »