Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
fa7d8967
Commit
fa7d8967
authored
Sep 03, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't show message boxes for assertion failures, since this can lead to crashes when in OnPaint
parent
729d30ec
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
7 deletions
+64
-7
src/gui/control/card_viewer.cpp
src/gui/control/card_viewer.cpp
+6
-2
src/main.cpp
src/main.cpp
+19
-0
src/util/error.cpp
src/util/error.cpp
+19
-0
src/util/prec.hpp
src/util/prec.hpp
+14
-5
src/util/regex.hpp
src/util/regex.hpp
+6
-0
No files found.
src/gui/control/card_viewer.cpp
View file @
fa7d8967
...
...
@@ -72,7 +72,9 @@ void CardViewer::onChangeSize() {
void
CardViewer
::
onPaint
(
wxPaintEvent
&
)
{
#ifdef _DEBUG
// we don't want recursion
assert
(
!
inOnPaint
());
if
(
inOnPaint
())
{
wxTrap
();
}
WITH_DYNAMIC_ARG
(
inOnPaint
,
true
);
#endif
wxSize
cs
=
GetClientSize
();
...
...
@@ -129,7 +131,9 @@ class CardViewer::OverdrawDC : private OverdrawDC_aux, public RotatedDC {
shared_ptr
<
RotatedDC
>
CardViewer
::
overdrawDC
()
{
#ifdef _DEBUG
// don't call from onPaint
assert
(
!
inOnPaint
());
if
(
inOnPaint
())
{
wxTrap
();
}
#endif
return
shared_ptr
<
RotatedDC
>
(
new
OverdrawDC
(
this
));
}
...
...
src/main.cpp
View file @
fa7d8967
...
...
@@ -46,6 +46,10 @@ class MSE : public wxApp {
int
OnExit
();
/// On exception: display error message
bool
OnExceptionInMainLoop
();
/// Fancier assert
#if defined(_MSC_VER) && defined(_DEBUG)
void
OnAssert
(
const
wxChar
*
file
,
int
line
,
const
wxChar
*
cond
,
const
wxChar
*
msg
);
#endif
};
IMPLEMENT_APP
(
MSE
)
...
...
@@ -265,3 +269,18 @@ bool MSE::OnExceptionInMainLoop() {
}
CATCH_ALL_ERRORS
(
true
);
return
true
;
}
#if defined(_MSC_VER) && defined(_DEBUG)
// Print assert failures to debug output
void
msvc_assert
(
const
char
*
,
const
char
*
,
const
char
*
,
unsigned
);
void
MSE
::
OnAssert
(
const
wxChar
*
file
,
int
line
,
const
wxChar
*
cond
,
const
wxChar
*
msg
)
{
#ifdef UNICODE
char
file_
[
1024
];
wcstombs
(
file_
,
file
,
1023
);
char
cond_
[
1024
];
wcstombs
(
cond_
,
cond
,
1023
);
char
msg_
[
1024
];
wcstombs
(
msg_
,
msg
,
1023
);
msvc_assert
(
msg_
,
cond_
,
file_
,
line
);
#else
msvc_assert
(
msg
,
cond
,
file
,
line
);
#endif
}
#endif
src/util/error.cpp
View file @
fa7d8967
...
...
@@ -12,6 +12,25 @@
DECLARE_TYPEOF_COLLECTION
(
ScriptParseError
);
// ----------------------------------------------------------------------------- : Debug utilities
#if defined(_MSC_VER) && defined(_DEBUG)
void
msvc_assert
(
const
char
*
msg
,
const
char
*
expr
,
const
char
*
file
,
unsigned
line
)
{
if
(
IsDebuggerPresent
())
{
char
buffer
[
1024
];
if
(
msg
)
{
sprintf
(
buffer
,
"Assertion failed: %s: %s, file %s, line %d
\n
"
,
msg
,
expr
,
file
,
line
);
}
else
{
sprintf
(
buffer
,
"Assertion failed: %s, file %s, line %d
\n
"
,
expr
,
file
,
line
);
}
OutputDebugStringA
(
buffer
);
DebugBreak
();
}
else
{
_assert
(
expr
,
file
,
line
);
}
}
#endif
// ----------------------------------------------------------------------------- : Error types
Error
::
Error
(
const
String
&
message
)
...
...
src/util/prec.hpp
View file @
fa7d8967
...
...
@@ -80,12 +80,21 @@ class FileName : public wxString {
#include "reflect.hpp"
#include "regex.hpp"
// ----------------------------------------------------------------------------- : Debugging fixes
#ifdef _MSC_VER
//# pragma conform(forScope,on) // in "for(int x=..);" x goes out of scope after the for
// somehow forScope pragma doesn't work in precompiled headers, use this hack instead:
#ifdef _DEBUG
#define for if(false);else for
#endif
//# pragma conform(forScope,on) // in "for(int x=..);" x goes out of scope after the for
// somehow forScope pragma doesn't work in precompiled headers, use this hack instead:
#ifdef _DEBUG
#define for if(false);else for
#endif
#ifdef _DEBUG
// Use OutputDebugString/DebugBreak for assertions if in debug mode
void
msvc_assert
(
const
char
*
,
const
char
*
,
const
char
*
,
unsigned
);
#undef assert
#define assert(exp) (void)( (exp) || (msvc_assert(nullptr, #exp, __FILE__, __LINE__), 0) )
#endif
#endif
// ----------------------------------------------------------------------------- : EOF
...
...
src/util/regex.hpp
View file @
fa7d8967
...
...
@@ -54,6 +54,9 @@
}
};
inline
Regex
()
{}
inline
Regex
(
const
String
&
code
)
{
assign
(
code
);
}
void
assign
(
const
String
&
code
);
inline
bool
matches
(
const
String
&
str
)
const
{
return
regex_search
(
str
.
begin
(),
str
.
end
(),
regex
);
...
...
@@ -126,6 +129,9 @@
friend
class
ScriptRegex
;
};
inline
Regex
()
{}
inline
Regex
(
const
String
&
code
)
{
assign
(
code
);
}
void
assign
(
const
String
&
code
);
inline
bool
matches
(
const
String
&
str
)
const
{
return
regex
.
Matches
(
str
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment