Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Need help to remove AutoLoader in Tx::Text::SuperText

by capfan (Sexton)
on Feb 05, 2016 at 18:06 UTC ( [id://1154498]=perlquestion: print w/replies, xml ) Need Help??

capfan has asked for the wisdom of the Perl Monks concerning the following question:

Hi all!

I just got co-maint on Tk::Text::SuperText. I wanted to make it look better, like having a lib folder and tests.

There is also some issues in this module and I would like to investigate. However, the module does use AutoLoader, which makes it harder for me to understand the module.

So I tried to remove AutoLoader. Simply remove the use AutoLoader statement, remove the __END__ block and move all method inside the module.

But then it happens: suddently, stuff that worked before does not work anymore. To be precise: With the current state of the module (v0.9.5), typing a < works fine. With the new state, with the adjustments as described above, it crashes immediately.

How can this be? Any ideas welcome.

Replies are listed 'Best First'.
Re: Need help to remove AutoLoader in Tx::Text::SuperText
by ww (Archbishop) on Feb 05, 2016 at 20:48 UTC

    A quick check of Tk::Text::SuperText tells us that the module uses the NON-default form of AUTOLOADER. Here's a snippet from the CPAN synopsis of AutoLoader:

    package Tk::Text::SuperText; use AutoLoader;

    Invoking AutoLoader that way requires that T::Tk::SuperText supply a to replace what you've removed...(or, perhaps, to remove something you didn't delete?), according to the AutoLoader doc:

    package Foo; use AutoLoader 'AUTOLOAD'; # import the default AUTOLOAD subrout +ine package Bar; use AutoLoader; # don't import AUTOLOAD, define our o +wn sub AUTOLOAD { ... $AutoLoader::AUTOLOAD = "..."; goto &AutoLoader::AUTOLOAD; } ....

    Hence, I suspect your problem lies in your "Simply remove the use AutoLoader statement, remove the __END__ block and move all method inside the module." I'm willing to guess that you already knew that, but can't help suspecting some small (or large) mistake in doing so. Unfortunately, you haven't given us much to go on, in that regard.

    ++$anecdote ne $data

      Unfortunately, you haven't given us much to go on, in that regard.

      True. What do you need to know?

      I really only removed line 76 (use AutoLoader;) and removed lines 650 (1;) and (#__END__).

      My example code looks as follows:

      #!perl use strict; use warnings; use utf8; use 5.020; use FindBin qw/$Bin/; use lib $Bin . '/Tk-Text-SuperText-0.9.5'; use Tk; use Tk::Text::SuperText; say $Tk::Text::SuperText::VERSION; my $mw = tkinit(); my $st = $mw->SuperText->pack(-fill => 'both', -expand => 1); $mw->MainLoop; exit(0);

      Maybe the module was broken from the beginning and the errors show regardless of the changes I did. But that's just a suspicion.

        IMO, your first question is one you must answer for yourself in your search for a solution. I've neither time nor inclination to go hareing back thru the module trying to see what might be involved in "I really only removed line 76 (use AutoLoader;) and removed lines 650 (1;) and (#__END__)."

        As to your "suspicion," it may be well-founded. Consider Corion's reply which looks to be well-worth your attention and followup.


        Spirit of the Monastery

        check Ln42! (or maybe Ln420?)

Re: Need help to remove AutoLoader in Tx::Text::SuperText
by Anonymous Monk on Feb 06, 2016 at 00:07 UTC

    But then it happens: suddently, stuff that worked before does not work anymore. To be precise: With the current state of the module (v0.9.5), typing a < works fine. With the new state, with the adjustments as described above, it crashes immediately.

    What is the error message?

    It "works" for me on win32, with or without use autoloader/__END__, typing < or >, no crash

      Ah, it seems that the issue when typing a bracket is related to the debugger. I'm working with Komodo IDE.

      I do not get a Perl error message, it just crashes and then shows a generic Windows error notification (Perl Command Line Interpreter stopped working).

      Without the debugger, I do get the same result when pressing tab and then shift + tab.

      I can't reproduce it at the moment, but I once also saw a debugger warning about deep recursion for focusPrev.
      The method looks as follows:

      sub focusPrev { my $w = shift; $w->focusPrev; }

        I would suspect that something is different in the way the parameters get passed to focusPrev between the "with AutoLoader" and the "no AutoLoader" version. If $w contains $self (as would be customary), then $self->focusPrev will call itself forever (or until the memory is exhausted).

        Maybe output a dump of @_ on each call to focusPrev to see the difference between the AutoLoader version and the other one.

        Of course, this assumes that the widget isn't broken and the problem does not happen with the unmodified widget either :).

        Update: Thinking more about it, I wonder how this could work with the AutoLoader version at all. Removing the two subroutines should still keep focus switching working in both versions of the module.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1154498]
Approved by Laurent_R
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-19 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found