~diresu/blender/blender-command-port

« back to all changes in this revision

Viewing changes to intern/moto/intern/MT_Assert.cpp

  • Committer: theeth
  • Date: 2008-10-14 16:52:04 UTC
  • Revision ID: vcs-imports@canonical.com-20081014165204-r32w2gm6s0osvdhn
copy back trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * $Id: MT_Assert.cpp 14444 2008-04-16 22:40:48Z hos $
 
3
 * ***** BEGIN GPL LICENSE BLOCK *****
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software Foundation,
 
17
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
18
 *
 
19
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 
20
 * All rights reserved.
 
21
 *
 
22
 * The Original Code is: all of this file.
 
23
 *
 
24
 * Contributor(s): none yet.
 
25
 *
 
26
 * ***** END GPL LICENSE BLOCK *****
 
27
 */
 
28
 
 
29
#include <stdio.h>
 
30
 
 
31
#ifdef _WIN32
 
32
#include <windows.h>
 
33
#endif
 
34
 
 
35
#include "MT_assert.h"
 
36
 
 
37
#ifdef _MSC_VER
 
38
#ifndef snprintf
 
39
  #define snprintf _snprintf
 
40
#endif
 
41
#endif
 
42
 
 
43
// Query the user if they want to break/abort the program, ignore the assert, or ignore all future
 
44
// occurance of the assert.
 
45
int MT_QueryAssert(const char *file, int line, const char *predicate, int *do_assert)
 
46
{
 
47
#ifdef _WIN32
 
48
        if (*do_assert)
 
49
        {
 
50
                char buffer[1024];
 
51
                snprintf(buffer, 1024, "ASSERT %s:%d: %s failed.\nWould you like to debug? (Cancel = ignore)", file, line, predicate);
 
52
                int result = MessageBox(NULL, buffer, "ASSERT failed.", MB_YESNOCANCEL|MB_ICONERROR);
 
53
                if (result == IDCANCEL)
 
54
                {
 
55
                        *do_assert = 0;
 
56
                        return 0;
 
57
                }
 
58
                
 
59
                return result == IDYES;
 
60
        }
 
61
#endif
 
62
        printf("ASSERT %s:%d: %s failed.\n", file, line, predicate);
 
63
        return *do_assert;
 
64
}