News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

wx2.9 compatibility

Started by Loaden, December 10, 2010, 05:03:23 AM

Previous topic - Next topic

Loaden

Unnecessary:
#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:

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


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

Only:
switch ((wxChar)str[pos])
Or:
switch ((wxChar)str.GetChar(pos))

Unnecessary:
#if wxCHECK_VERSION(2, 9, 0)
str.Append(m_Buffer[startIndex], writeLen);
#else
str.Append(&m_Buffer[startIndex], writeLen);
#endif

Only:
str.Append((const wxChar*)m_Buffer + startIndex, writeLen);



Unnecessary:
#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:

txtParent->SetLabel(wxString::Format(_T("%s (%d)"), (const wxChar*)_("<Global namespace>"), m_Token->m_ParentIndex));


...

Any comments?

killerbot

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 ...

Biplab

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.

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.

stahta01

#3
Quote from: 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.

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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Biplab

Quote from: stahta01 on December 10, 2010, 10:33:26 PM
Quote from: 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.

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.

oBFusCATed

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!]

Biplab

Quote from: oBFusCATed on December 11, 2010, 10:48:30 AM
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.

xunxun

Quote from: Biplab on December 11, 2010, 01:25:31 PM
Quote from: oBFusCATed on December 11, 2010, 10:48:30 AM
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

oBFusCATed

(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!]

Biplab

Quote from: xunxun1982 on December 11, 2010, 04:06:48 PM
Quote from: Biplab on December 11, 2010, 01:25:31 PM
Quote from: oBFusCATed on December 11, 2010, 10:48:30 AM
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

Quote from: oBFusCATed on December 11, 2010, 04:22:44 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?

oBFusCATed

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!]

Loaden

Quote from: oBFusCATed on December 11, 2010, 10:25:31 PM
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.
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))
     {

oBFusCATed

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

#14
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.next.codeblocks.org/index.php/topic,13777.0.html