Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: Loaden on December 10, 2010, 05:03:23 am

Title: wx2.9 compatibility
Post by: Loaden 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?
Title: Re: wx2.9 compatibility
Post by: killerbot 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 ...
Title: Re: wx2.9 compatibility
Post by: Biplab 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.
Title: Re: wx2.9 compatibility
Post by: stahta01 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.
Title: Re: wx2.9 compatibility
Post by: Biplab 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.
Title: Re: wx2.9 compatibility
Post by: oBFusCATed on December 11, 2010, 10:48:30 am
BTW: Is C::B usable with wx2.9.1?
Title: Re: wx2.9 compatibility
Post by: Biplab 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.
Title: Re: wx2.9 compatibility
Post by: xunxun 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....
Title: Re: wx2.9 compatibility
Post by: oBFusCATed on December 11, 2010, 04:22:44 pm
CC crashes even with wx2.8
Title: Re: wx2.9 compatibility
Post by: Biplab 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.
Title: Re: wx2.9 compatibility
Post by: daniloz 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?
Title: Re: wx2.9 compatibility
Post by: oBFusCATed on December 11, 2010, 10:25:31 pm
Means that the problem is in CC not in the wx version:)
Title: Re: wx2.9 compatibility
Post by: Loaden 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))
     {
Title: Re: wx2.9 compatibility
Post by: oBFusCATed 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 :)
Title: Re: wx2.9 compatibility
Post by: daniloz 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
Title: Re: wx2.9 compatibility
Post by: xunxun on December 13, 2010, 12:52:52 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

Year, when I use 2.8.10, C::B sometimes crashes, but I use 2.8.11 now, and C::B crashes very little...
I don't know why.