about ap_UnixApp.cpp

Ming-I Hsieh (mihs@wm28.csie.ncu.edu.tw)
Fri, 25 Jun 1999 07:22:28 +0800


<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
  else
  {
   char message[2048];
   g_snprintf(message, 2048,
        "Cannot open file %s.", m_pArgs->m_argv[optind]);
   messageBoxOK(message);

   // remove the stale frame

   // NOTE : Must have app forget frame manually.  Is this a bad
   // NOTE : design decision on the part of the frame?  The
   // NOTE : frame is reponsible for making the app remember it
   // NOTE : in its constructor, shouldn't it have the app
   // NOTE : forget it in its destructor?

   forgetFrame(pFirstUnixFrame);

   pFirstUnixFrame->close();
   DELETEP(pFirstUnixFrame);

   // decrement the number of windows opened
   kWindowsOpened--;
 
  }
  optind++;
 }

If you want remove it everytime, you should call ``pFirstFrame = NULL''.
Otherwise, you will access a non-allocation segment! Like,

AbiWord exist1.abw noexist2.abw exist3.abw

Then you will open exist1.abw, the allocate a new frame.
Beause you can open noexist2.abw, so you free the frame, but you don't
let pFirstUnixFrame to NULL. Then you want to open exist3.abw, but
the pFirstUnixFrame is pointing to a non-allocation memory segment.
So you shouldn't forget to make pFirstFrame to NULL if you want call
``pFirstUnix->close();'' and ``forgetFrame(pFirstUnixFrame);'' everytime.
I had been trying to move forgetFrame() & close() to its destructor. It seem
make another bug! And you don't need remove it every time. You only
remove the at last: Like following:

 if (kWindowsOpened == 0)
 {
  // no documents specified or were able to be opened,
  // open an untitled one
  pFirstUnixFrame->loadDocument(NULL, IEFT_Unknown);
 }
 else
 {
  // if there are some opened documents and one null
  // frame, delete it. It will don't crash! :)
  forgetFrame(pFirstUnixFrame);
  pFirstUnixFrame->close();
  delete pFirstUnixFrame;
 }
 



This archive was generated by hypermail 1.03b2.