I am redesigning so that all of the windows are now based on their own
Toplevel, which of course are all off of the one, single MainWindow.
When a window is needed, I will simply use the "Popup" command. Otherwise
the withdraw command will keep it hidden. A small proof of concept
program I have showed it to work.

There will be about 18 windows (some are pretty complicated) that will
be staying in existence througout the life of the program. Most of
the other windows (trivial popups) will use your suggested Dialog.
A lot of extra memory may be taken up by the program, but it should
work. Thanks for the tip.

I am now a little scared to implement the redesign in the real program
at work. It is a pretty big program. I would hate to spend the
couple of weeks needed just to find out it won't work. My fear is
that third party modules that I use, such as Tk::FileSelect, will lead
me to the "Segmentation Fault" because it obviously pops up a
mini-browser, and when done, destroys it.

I notice in the module Fileselect the author uses this call:

Tk::DialogWrapper('fileselect',$cmd, %args);<br>

I could not find any documentation for Tk::DialogWrapper but in
file Tk.pm, sub DialogWrapper has the line

my $w = delete $args{'-parent'};<br>

Further in sub DialogWrapper, this line appears

$w->destroy if $created;<br>

Ouch!

The var $created becomes 1 (and we created a new MainWindow) if $w is
undefined after the afforementioned line. This is important because
it would seem to ruin my chances of success here.

Equally bad, the parameters passed in to DialogWrapper are

my ($method,$kind,%args) = @_;<br>

and I do not know what the parameters are really for, or how to use
them. Nor do I have a clue as to why deleting '-parent' from the
%args hash should cause a new MainWindow to be created.

Is there some documentation that can explain this? I have, and read
most of, Mastering Perl/Tk, but it does not touch upon it. Is there
another book I can purchase that can explain it. Neither google,
dogpile or search.cpan.org seemed to help.

I wonder, could it be possible to wrap all third-party modules that
pop up something, cpan or otherwise, in a so-called DialogWrapper?

All this could be avoided if there were just some way to tell if
the $mw->destroy command was really behind-the-scenes finished, so
that when a new MainWindow was needed, my program could be free to
just go ahead and create one. I tried Exists($mw), but Exists passes
sometimes even when the previous $mw->destroy seems done.

Thanks


In reply to Re: "Segmentation fault after destroying window" by mnooning
in thread "Segmentation fault after destroying window" by mnooning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.