[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-Modules] Navigation bugs



I believe there to be an error in Navigation::new() in the line:

    $handle = new Handle($_[0].pack("xxs", scalar(@{$_[1]}))."@{$_[1]}");

whereby white space is inserted between the items in the 'types' list. The
upshot is that the handle is mal-formed and only the first item in the list
is subsequently recognisable.

Re-writing the line as follows resolves the problem:

    $handle = new Handle(
        $_[0].pack("xxs", scalar(@{$_[1]})).join('', @{$_[1]})
    );

Another difficulty with Navigation.pm is that free memory seems to leak
away continuously at the rate of about 240K per minute while the window is
up and quiescent. The loss is not reclaimed until MacPerl is relaunched.

This memory leak is definitely asssociated with the 'events' procedure. The
script in which it was noticed is attached below for anyone who would like
to repeat the experiment.

Would it be possible for the 'typemap' for Navigation.xs to be published?

Alan Fry

==========

#!perl

use Mac::Navigation;
use Mac::Files;

$dir = FindFolder(kOnSystemDisk, kDesktopFolderType);
$options = NavGetDefaultDialogOptions();
$options->message("Try shift click or \360_AÉ");
$options->windowTitle("WH3R3 R 7H3 F1L3Z???");

$options->dialogOptionFlags(
      kNavAllFilesInPopup      # ==  16
    + kNavAllowPreviews        # ==  64
    + kNavAllowMultipleFiles   # == 128
#   + kNavNoTypePopup          # ==   1; same as NavChooseFile()
);

# dialogOptionFlags == 208; default is 228 -- presumably also
# including kNavCtlGetFirstControlID (== 20) whatever that isÉ

$creator = "MPS ";
$types   = ["APPL", "OBJ ", "TEXT"];
$list_h  = NavTypeListHandle->new($creator, $types);

$reply   = NavGetFile(
    $dir, $options, $list_h, sub{1}, sub{0}, \&noFolders
) or die $^E;

for (1..$reply->count) { print $reply->file($_), "\n" }

sub noFolders { $_[1]->isFolder ? 0 : 1 }

END { NavDisposeReply $reply if defined $reply}

==========



==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-modules-request@macperl.org