• Index
  •  » Support
  •  » Corrupted list of items when using Import Scanner

#1 2017-08-13 02:13:47

Registered: 2017-05-21
Posts: 13

Corrupted list of items when using Import Scanner

I just spent a little bit of time tracking down erratic results when using a local barcode scanner and when dealing with a large number of items. After about 3 or 4 items I noticed one or more of them would be overwritten with duplicate or corrupted data.

I do have a fix, but I'm not sure if it is the correct thing to do from a memory management perspective or from a gcstar management perspective. The fix is to deep copy each item added in the loop, and then return a list of deep copied items in the return array. Unfortunately this won't free the deep copied items with any regularity, and it requires http://search.cpan.org/~garu/Clone-0.39/Clone.pm to be installed (it wasn't part of my standard install). For the latter, I'm not sure if this is enough of an issue that it needs to be added to the required package list for gcstar or not, or if there is another, more elegant solution.

My hacky fix is rather easy -- using https://gitlab.com/Kerenoc/GCstar/blob/ … Scanner.pm from today (12Aug2017).

1. Install the Clone package with the package/module manager of choice (i.e. CPAN).

2. Around line 287 use the Clone package --
285         my @result;
287         use Clone 'clone';
289         #First we try to get the correct plugin
290         my $plugin = $GCPlugins::pluginsMap{$self->{model}->getName}->{$self->{options}->{plugin}};
291         $plugin->{bigPics} = $self->{options}->{parent}->{options}->bigPics;

3. And around line 379, push a deep copied version of the $info item instead of the local copy --
377             }
378             $previous = $info->{$titleField};
379             push @result, clone($info);
380             $self->{options}->{parent}->restoreCursor;
381         }
382         $socket->close if $socket;
383         return \@result;

If this should be a permanent fix (that is to say the fix is good enough) I can add a pull request for this, but with the requirement for an additional package it was a bit beyond my comfort/experience level.



#2 2017-08-13 07:55:14

Registered: 2016-03-19
Posts: 109

Re: Corrupted list of items when using Import Scanner

Importing using a scanner seems to be quite tricky as 3 asynchronous processes need to work together : the UI, listening to the socket for codes and waiting for the web request to finish. It seems the reason why it's not working on Windows.

In this case, maybe in some configuration, a code can be received although the previous request is finished?

For the kind of modification you propose it would be great to have advise from the author or the contributors that know the inner working of GCstar!


  • Index
  •  » Support
  •  » Corrupted list of items when using Import Scanner

Should you have a problem using GCstar, you can open a bug report or request some support on GCstar forums.