Debug alert in Release? Why? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 2922
Joined: Sun Jan 03, 2010 5:45 pm

Re: Debug alert in Release? Why?

Post by PB » Thu Mar 01, 2012 3:43 pm

So extreme001, what was the reason for debug alerts to pop up in the release builds? According to my experience and the official documentation, those should not normally appear.

extreme001
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Fri Dec 22, 2006 9:17 am
Location: Germany
Contact:

Re: Debug alert in Release? Why?

Post by extreme001 » Thu Mar 01, 2012 4:11 pm

Edited the setup.h, cleaned all projects including the wxWidgets-build and rebuilded all. I set wxDebugLevel=0 for production builds.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2922
Joined: Sun Jan 03, 2010 5:45 pm

Re: Debug alert in Release? Why?

Post by PB » Thu Mar 01, 2012 4:18 pm

Aha, so you haven't figured why the debug alerts happened when they should not. OK, I was just curious.

User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Debug alert in Release? Why?

Post by eranon » Sat Mar 30, 2013 12:11 am

Hello,

I dig out this thread since I'm facing a similar issue and could maybe add some useful words.

Well, under Windows (7 x64), I've compiled wxWidgets 2.9.4 to produce RELEASE libs with wxDEBUG_LEVEL 0 (as doublemax, I'm used to handle the errors by myself and provide a user friendly message to final user when possible ; users are very quick to think a piece of software is buggy if they see too of technical - and weird for them - detail). Also, my own project using these libs is compiled with NDEBUG.

Nevertheless, and in spite of these precautions, sometimes, when a Windows native function fails, I see an error message on screen, and this is not what I want. What I want is to discover this error during the development or from my testers, then manage a way to workaround the issue or provide a smart message for final release (for non-technical final users).

For example, in this (simplified) code below, if the target file already exists and the file copy fails, I get my own message ( a smart one, with global error and an advice), plus the one coming from wxWidgets itself (something which says "Failed to copy the file x to the file y. Error 80"). This second message is undesirable in my case.

Code: Select all

if (!wxCopyFile(strSource, strTarget, false /* do not overwrite */)){
   wxMessageBox("The copy is currently not possible, but nothing is lost.\nYou should renew from a fresh workspace.");}
So, I've digged and seen the responsible is the wxWidgets's logging mechanism which seems to be (not sure, so I use the word "seems" with its full sense) independent of wxDEBUG_LEVEL.

For example, about the wxCopyFile used above, the wxWidgets code is :

Code: Select all

if ( !::CopyFile(file1.t_str(), file2.t_str(), !overwrite) )
{
    wxLogSysError(_("Failed to copy the file '%s' to '%s'"), file1.c_str(), file2.c_str());
    return false;
}
At this stage of my understanding of the beast, I'm here. Tomorrow or monday, I'll read this page : http://docs.wxwidgets.org/trunk/overview_log.html which, certainly, contains the solution (I assume disable logging or redirect it toward a log file, for example).

Good night (1:27 AM here) :)
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]

User avatar
doublemax
Moderator
Moderator
Posts: 15828
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Debug alert in Release? Why?

Post by doublemax » Sat Mar 30, 2013 1:35 am

There are some functions that create this system error messages even in release mode, mostly file operations and e.g. accessing the registry under Windows.

You can temporarily suppress these messages by creating an instance of wxLogNull:
http://docs.wxwidgets.org/stable/wx_wxlognull.html

Globally setting wxLog::SetLogLevel(0) in release mode should work, too.
http://docs.wxwidgets.org/stable/wx_wxl ... etloglevel
(I never tested that though)
Use the source, Luke!

User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Debug alert in Release? Why?

Post by eranon » Sun Mar 31, 2013 4:38 am

Thanks doublemax. I'm currently not in front of my dev-station, but will decide with your advice/guidance in mind...

--
EDIT 2013/03/31 : it works perfectly with wxLog::SetLogLevel(0) : not any log message anymore. So, I'll can add this in final release (and let these log messages for debug and alpha/beta releases only).
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]

Post Reply