~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

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