Author Topic: Workarounds to "Encountered an improper argument" error dialogue.  (Read 22767 times)

Offline riecks

  • Beta Testers
  • Newcomer
  • *
  • Posts: 29
    • View Profile
I saw a mention of this from 2012 http://forums.camerabits.com/index.php?topic=8023.msg38411#msg38411 , but no solution mentioned.  This has been happening to me sporadically over the past couple of months. It began at first with TIFF or PSD files, but happened tonight with standard RAW+JPEG captures.

For those wanting the executive summary, I think I've found a workaround to the issue, but would love to have a solution for longer term. Jump to the bold text at the end for the answer.

I'm running PM 5.0 build 13915 (a16ea99) under 64 bit Win7 Pro. when checked, PM says it's current.

Again, this issue appeared to be sporadic. When it would manifest, I would get the "Encountered an improper argument" dialog whenever I had the "Info Tooltips" option turned on (View >> Show Info Tooltips).  This generally happens immediately after I'd just applied the IPTC Stationary pad (Cntrl + I), and then hover over the image (to check that I've entered both caption and keywords).

I've learned that if I make sure that the mouse is not over the image I can press the ESC (escape) key, and then continue my work. Or if the dialogue isn't over the thumbnail that is causing the problem, I can press the "OK" button in the dialogue.  However, whenever my mouse strays over that image, the Error dialogue "Encountered an improper argument" will appear again.

I can turn off the option to show the tooltips, but then I have to stop and open each image to verify that I've added metadata. As I generally leave the "Show Tooltips" option on, this is not a satisfactory workaround.

As the other post asked, what was being used in my "Show Tooltips"  (using Edit >> Settings >> Show Info Text). Here is that set of values.

Caption: {caption}
Date: {date}, Time: {time}
Model: {modl}, Serial #: {snum}
Firmware: {firm}, Frame #: {fnum}
Actuations: {actuations}
Latitude: {glat}
Longitude: {glon}
Altitude: {galt}
Lens (mm): {lens}
ISO: {iso}
Aperture: {f}
Shutter: {shut}
Program: {prgm}
White Bal.: {baln}
ICC Profile: {icc}
{height} x {width} pixels
Keywords: {Keywords}

I've tried refreshing the set (View >> Refresh), and even turning off Photo Mechanic and restarting, and the dialogue will still appear over these specific images.

From some trial and error, I thought that the problem seemed to be some interaction between something I wrote in the caption, and the "Into Tooltip" mouse over.

I thought -- since I'd composed the caption in another application (notepad) -- that I might have brought in something in with my "paste" operation that was in a character set (unicode?) that PM couldn't handle.  So I first I opened the IPTC window, and "cut" the caption from the image and then clicked the "OK" button. When I hovered the mouse over the image, everything worked, and I did not see the dreaded "Encountered an improper argument" error dialogue!

So, success, but only if I don't want captions on my images.   :-\

So, operating under the assumption that there was something in the text that I wasn't seeing, I tried pasting the caption into other applications that I thought would "strip out" the offending stuff. I tried pasting into a search window in my Firefox browser, and then into Notetab ++ (which generally strips everything), but no luck. Whenever I pasted the full caption back into my image's IPTC, I got the error dialogue!!! argh.

So, next I tried by typing a short caption into the image.  That worked fine.  Then I tried copying and pasting in a short bit of the caption, instead of the full one.  That worked too!  Since it seemed that the issue might be with the length of the caption, the question was how much. After some additional trial and error, the magic number for me is 466 characters.   If I have a caption that is 467 characters or more, the error dialogue pops up.

Weird, but true.  See the attached images for what happens when I shorten the caption.

So, now that I've discovered the issue, can anything be done about this? (short of me shortening all of my captions).  Is it indeed just the caption, or could it be that it's the total size of the Info Tool tips (only able to show so many lines, or so many characters in total?)?

I've included two screen shots as illustrations.

Hope this helps some others. It's been bugging me for months!

David

[attachment deleted by admin]

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Re: Workarounds to "Encountered an improper argument" error dialogue.
« Reply #1 on: May 18, 2013, 10:43:40 PM »
David,

Thank you for the additional information.  I just made a huge caption and was able to instantly reproduce the problem.  It turns out that the Microsoft MFC library class that handles tool tips (CToolTipCtrl) has an internal limitation of 1024 characters for a tool tip's text.

I'll put in some code to remove the "middle" text if it is longer than 1000 (just to be safe) characters but in the meantime, you could try this workaround:

Change your use of the {caption} variable to:

{caption:0,400}

This should eliminate the problem for now.  Captions that have more than 400 characters will print only the first 400 characters.  Captions that have fewer than 400 characters will print the entire amount.

HTH,

-Kirk

Offline riecks

  • Beta Testers
  • Newcomer
  • *
  • Posts: 29
    • View Profile
Re: Workarounds to "Encountered an improper argument" error dialogue.
« Reply #2 on: May 19, 2013, 05:10:42 PM »
Kirk:

So this is a "Windows" only issue, correct?

BTW, would this have also happened in the older Photo Mechanic 4.5+ versions?  I don't recall seeing it then, but may have blotted that out of my memory.

Another option would be to limit the other fields that I'm printing.. to reduce the number of other characters being displayed in the tooltip on "mouse over"?

David

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Re: Workarounds to "Encountered an improper argument" error dialogue.
« Reply #3 on: May 19, 2013, 05:43:53 PM »
David,

So this is a "Windows" only issue, correct?

Yes, Windows only.

BTW, would this have also happened in the older Photo Mechanic 4.5+ versions?  I don't recall seeing it then, but may have blotted that out of my memory.

Yes, it should happen in all versions.

Another option would be to limit the other fields that I'm printing.. to reduce the number of other characters being displayed in the tooltip on "mouse over"?

Yes, you could do that, but if the sum of the lengths of the fields exceeds 1024 then it will get that error.  I will modify the code to make the string fit the requirements.

-Kirk