Professional Web Applications Themes

DrawString suddenly started crashing - Mac Programming

My programs have suddenly stopped working. I have determined that the cause is DrawString(Str255&). Does this function no longer work with 10.2 or perhaps with CodeWarrior 8.3? Any help appreciated. I have to figure out what the heck is going on here. Thanks. __________________________________________________ ______________________ Keith Wiley [email]kwileycs.unm.edu[/email] [url]http://www.unm.edu/~keithw[/url] [url]http://www.mp3.com/KeithWiley[/url] "Yet mark his perfect self-contentment, and hence learn his lesson, that to be self-contented is to be vile and ignorant, and that to aspire is better than to be blindly and impotently happy." -- Edwin A. Abbott, Flatland __________________________________________________ ______________________...

  1. #1

    Default DrawString suddenly started crashing

    My programs have suddenly stopped working. I have determined that the
    cause is DrawString(Str255&). Does this function no longer work with 10.2
    or perhaps with CodeWarrior 8.3? Any help appreciated. I have to figure
    out what the heck is going on here.

    Thanks.

    __________________________________________________ ______________________
    Keith Wiley [email]kwileycs.unm.edu[/email]
    [url]http://www.unm.edu/~keithw[/url] [url]http://www.mp3.com/KeithWiley[/url]

    "Yet mark his perfect self-contentment, and hence learn his lesson,
    that to be self-contented is to be vile and ignorant, and that to
    aspire is better than to be blindly and impotently happy."
    -- Edwin A. Abbott, Flatland
    __________________________________________________ ______________________
    Keith Wiley Guest

  2. #2

    Default Re: DrawString suddenly started crashing

    In article <Pine.LNX.4.56.0309022312310.8552santafe.cs.unm.e du>,
    Keith Wiley <kwileycs.unm.edu> wrote:
    > My programs have suddenly stopped working. I have determined that the
    > cause is DrawString(Str255&). Does this function no longer work with 10.2
    > or perhaps with CodeWarrior 8.3? Any help appreciated. I have to figure
    > out what the heck is going on here.
    DrawString is fine in OS X 10.2, CW 8.3. The problem is your program.
    At the point that DrawString crashs, is the heap OK? is the current
    GrafPort OK?
    David Phillip Oster Guest

  3. #3

    Default Re: DrawString suddenly started crashing

    On Wed, 3 Sep 2003, David Phillip Oster wrote:
    > In article <Pine.LNX.4.56.0309022312310.8552santafe.cs.unm.e du>,
    > Keith Wiley <kwileycs.unm.edu> wrote:
    >
    > > My programs have suddenly stopped working. I have determined that the
    > > cause is DrawString(Str255&). Does this function no longer work with 10.2
    > > or perhaps with CodeWarrior 8.3? Any help appreciated. I have to figure
    > > out what the heck is going on here.
    >
    > DrawString is fine in OS X 10.2, CW 8.3. The problem is your program.
    > At the point that DrawString crashs, is the heap OK? is the current
    > GrafPort OK?
    Impossible. I wrote a toy program to test DrawString and it doesn't even
    work. The following "program" crashes at the DrawString line:

    #include <Carbon.h>
    #include <time.h>

    int main()
    {
    WindowPtr w = GetNewCWindow(128, NULL, NULL);

    SetPort((OpaqueGrafPtr*)w);

    MoveTo (10,10);
    DrawString("\pHello");

    long st = TickCount();
    while (TickCount() - st < 60 * 5);

    return 0;
    }

    __________________________________________________ ______________________
    Keith Wiley [email]kwileycs.unm.edu[/email]
    [url]http://www.unm.edu/~keithw[/url] [url]http://www.mp3.com/KeithWiley[/url]

    "Yet mark his perfect self-contentment, and hence learn his lesson,
    that to be self-contented is to be vile and ignorant, and that to
    aspire is better than to be blindly and impotently happy."
    -- Edwin A. Abbott, Flatland
    __________________________________________________ ______________________
    Keith Wiley Guest

  4. #4

    Default Re: DrawString suddenly started crashing

    In article <Pine.LNX.4.56.0309030831340.10701santafe.cs.unm. edu>,
    Keith Wiley <kwileycs.unm.edu> wrote:
    > > DrawString is fine in OS X 10.2, CW 8.3. The problem is your program.
    > > At the point that DrawString crashs, is the heap OK? is the current
    > > GrafPort OK?
    >
    > Impossible. I wrote a toy program to test DrawString and it doesn't even
    > work. The following "program" crashes at the DrawString line:
    >
    > #include <Carbon.h>
    > #include <time.h>
    >
    > int main()
    > {
    > WindowPtr w = GetNewCWindow(128, NULL, NULL);
    >
    > SetPort((OpaqueGrafPtr*)w);
    "Impossible." Perhaps that word doesn't mean what you think it does? :-)

    Casting Windows (and other things) is illegal on OS X and has been since
    day 1. Call the appropriate Get function (ie, GetWindowPort) or the
    appropriate helper function instead (ie, SetPortWindowPort). So:
    SetPortWindowPort(w);
    -OR-
    SetPort(GetWindowPort(w));

    You might want to do wholescale searches in your source code for:
    "GrafPtr)"
    "WindowPtr)"
    "DialogPtr)"
    "GWorldPtr)"
    to avoid similar crashes in the future.
    Tom Dowdy Guest

  5. #5

    Default Re: DrawString suddenly started crashing

    In article <dowdy-9848B2.08303803092003news.apple.com>,
    Tom Dowdy <dowdyapple.com> wrote:
    > In article <Pine.LNX.4.56.0309030831340.10701santafe.cs.unm. edu>,
    > Keith Wiley <kwileycs.unm.edu> wrote:
    >
    > > > DrawString is fine in OS X 10.2, CW 8.3. The problem is your program.
    > > > At the point that DrawString crashs, is the heap OK? is the current
    > > > GrafPort OK?
    > >
    > > Impossible. I wrote a toy program to test DrawString and it doesn't even
    > > work. The following "program" crashes at the DrawString line:
    > >
    > > #include <Carbon.h>
    > > #include <time.h>
    > >
    > > int main()
    > > {
    > > WindowPtr w = GetNewCWindow(128, NULL, NULL);
    > >
    > > SetPort((OpaqueGrafPtr*)w);
    >
    > "Impossible." Perhaps that word doesn't mean what you think it does? :-)
    >
    > Casting Windows (and other things) is illegal on OS X and has been since
    > day 1. Call the appropriate Get function (ie, GetWindowPort) or the
    > appropriate helper function instead (ie, SetPortWindowPort). So:
    > SetPortWindowPort(w);
    > -OR-
    > SetPort(GetWindowPort(w));
    >
    > You might want to do wholescale searches in your source code for:
    > "GrafPtr)"
    > "WindowPtr)"
    > "DialogPtr)"
    > "GWorldPtr)"
    > to avoid similar crashes in the future.
    Keith also forgot to initialize the toolbox by calling InitCursor();
    That omission alone would cause his program to crash.

    TickCount() returns an unsigned long, so while() loop also, won't do
    what he expects if his machine has been on for a few weeks.

    also, If this is C++, C-style casts are deprecated in C++.
    David Phillip Oster Guest

  6. #6

    Default Re: DrawString suddenly started crashing

    On Wed, 3 Sep 2003, John Harrison wrote:
    > I love the attitude.
    >
    > 'I've got a problem, I've no idea what's causing it, I need help, but I know
    > that it CANNOT POSSIBLY be my fault.'.
    Well, aside from you sarcasm, did you bother to notice my five line
    example. Are you suggesting that program is so complicated that I've lost
    a pointer somewhere?

    __________________________________________________ ______________________
    Keith Wiley [email]kwileycs.unm.edu[/email]
    [url]http://www.unm.edu/~keithw[/url] [url]http://www.mp3.com/KeithWiley[/url]

    "Yet mark his perfect self-contentment, and hence learn his lesson,
    that to be self-contented is to be vile and ignorant, and that to
    aspire is better than to be blindly and impotently happy."
    -- Edwin A. Abbott, Flatland
    __________________________________________________ ______________________
    Keith Wiley Guest

  7. #7

    Default Re: DrawString suddenly started crashing

    On Wed, 3 Sep 2003, Tom Dowdy wrote:
    > Casting Windows (and other things) is illegal on OS X and has been since
    > day 1. Call the appropriate Get function (ie, GetWindowPort) or the
    > appropriate helper function instead (ie, SetPortWindowPort). So:
    > SetPortWindowPort(w);
    That did it. Thanks. To the folks who thought it would be more helpful
    to insult me, thanks for nothing. What a wonderful help you were. To
    this guy and the guy who suggested InitCursor, thanks tremendously for the
    help.

    Cheers!

    __________________________________________________ ______________________
    Keith Wiley [email]kwileycs.unm.edu[/email]
    [url]http://www.unm.edu/~keithw[/url] [url]http://www.mp3.com/KeithWiley[/url]

    "Yet mark his perfect self-contentment, and hence learn his lesson,
    that to be self-contented is to be vile and ignorant, and that to
    aspire is better than to be blindly and impotently happy."
    -- Edwin A. Abbott, Flatland
    __________________________________________________ ______________________
    Keith Wiley Guest

  8. #8

    Default Re: DrawString suddenly started crashing


    "Keith Wiley" <kwileycs.unm.edu> wrote in message
    news:Pine.LNX.4.56.0309031139450.11988santafe.cs. unm.edu...
    > On Wed, 3 Sep 2003, John Harrison wrote:
    >
    > > I love the attitude.
    > >
    > > 'I've got a problem, I've no idea what's causing it, I need help, but I
    know
    > > that it CANNOT POSSIBLY be my fault.'.
    >
    > Well, aside from you sarcasm, did you bother to notice my five line
    > example. Are you suggesting that program is so complicated that I've lost
    > a pointer somewhere?
    >
    I know very little about Mac programming and I wouldn't be able to offer
    advice on your code.

    Your second post made me smile, that's all, sorry to offend.

    john


    John Harrison Guest

  9. #9

    Default Re: DrawString suddenly started crashing

    In article <oster-ACFC40.10070103092003news.sf.sbcglobal.net>,
    David Phillip Oster <osterieee.org> wrote:
    > Keith also forgot to initialize the toolbox by calling InitCursor();
    > That omission alone would cause his program to crash.
    On Carbon?

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Jurisic Guest

  10. #10

    Default Re: DrawString suddenly started crashing

    In article <Pine.LNX.4.56.0309031145350.11988santafe.cs.unm. edu>,
    Keith Wiley <kwileycs.unm.edu> wrote:
    > To the folks who thought it would be more helpful
    > to insult me, thanks for nothing.
    You get better help if you lose the whole "it's not my fault, it's
    impossible, it's obviously the OS that has the problem" attitude.
    Michael Ash Guest

  11. #11

    Default Re: DrawString suddenly started crashing

    In article <macdev-293122.19233503092003senator-bedfellow.mit.edu>,
    Miro Jurisic <macdevmeeroh.org> wrote:
    > In article <oster-ACFC40.10070103092003news.sf.sbcglobal.net>,
    > David Phillip Oster <osterieee.org> wrote:
    >
    > > Keith also forgot to initialize the toolbox by calling InitCursor();
    > > That omission alone would cause his program to crash.
    >
    > On Carbon?
    I was probably over-generalizing from technote 2003, which implies that
    it is necessary. <http://developer.apple.com/technotes/tn/pdf/tn2003.pdf>
    and
    <[url]http://developer.apple.com/doentation/Carbon/Reference/Carbon_Spec_Po[/url]
    rting/QuickDraw_Manager.html>

    "When your Carbon application is launched, the system sets the cursor to
    the watch cursor. Your application should call InitCursor at the end of
    its startup initialization process, to reset the cursor. Available in
    CarbonLib 1.0 and later when running Mac OS 8.1 or later. Available in
    Mac OS X 10.0 and later."
    David Phillip Oster Guest

  12. #12

    Default Re: DrawString suddenly started crashing

    In article <oster-DCA70D.22032703092003news.sf.sbcglobal.net>,
    David Phillip Oster <osterieee.org> wrote:
    > In article <macdev-293122.19233503092003senator-bedfellow.mit.edu>,
    > Miro Jurisic <macdevmeeroh.org> wrote:
    >
    > > In article <oster-ACFC40.10070103092003news.sf.sbcglobal.net>,
    > > David Phillip Oster <osterieee.org> wrote:
    > >
    > > > Keith also forgot to initialize the toolbox by calling InitCursor();
    > > > That omission alone would cause his program to crash.
    > >
    > > On Carbon?
    >
    > I was probably over-generalizing from technote 2003, which implies that
    > it is necessary. <http://developer.apple.com/technotes/tn/pdf/tn2003.pdf>
    > and
    > <[url]http://developer.apple.com/doentation/Carbon/Reference/Carbon_Spec_Po[/url]
    > rting/QuickDraw_Manager.html>
    >
    > "When your Carbon application is launched, the system sets the cursor to
    > the watch cursor. Your application should call InitCursor at the end of
    > its startup initialization process, to reset the cursor. Available in
    > CarbonLib 1.0 and later when running Mac OS 8.1 or later. Available in
    > Mac OS X 10.0 and later."
    The implication is wrong. InitCursor() is not necessary in Carbon on
    Mac OS X. Nor, for that matter, will the system set the cursor to the
    watch cursor when a Carbon application is launched on Mac OS X.

    -Eric

    --
    Eric Albert [email]ejalbertstanford.edu[/email]
    [url]http://rescomp.stanford.edu/~ejalbert/[/url]
    Eric Albert Guest

Similar Threads

  1. CFMX7 Started Crashing (Signal 11)
    By mike_lopus in forum Coldfusion Server Administration
    Replies: 1
    Last Post: December 14th, 01:21 PM
  2. CFMX server suddenly started going down
    By alanfox70 in forum Coldfusion Server Administration
    Replies: 14
    Last Post: October 12th, 05:58 AM
  3. Photoshop 7 suddenly keeps crashing on startup
    By M. t. in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 20
    Last Post: July 28th, 05:39 PM
  4. Camino 0.7.0 suddenly crashing on startup
    By Richard Wesley in forum Mac Applications & Software
    Replies: 0
    Last Post: June 25th, 07:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139