Re: TN5250 Crash After Paste (Vista)

"Ken Koehler" <[email protected]>
Newsgroups gmane.comp.emulators.tn5250,gmane.spam.detected
Message-ID <[email protected]>
   Ok, the attachments didn't go.

   Here is the unified diff of changes against tn5250-0.17.4.

   --- winterm.c 2008-11-21 03:12:22.000000000 -0500
   +++ winterm2.c 2009-05-09 21:58:06.000000000 -0400
   @@ -20,6 +20,19 @@
     *
     */

   +/* Fixes:
   + *  Selecting text backwards (e.g. line 11 back to 10) would abort.
   + *  Select & copy outside screen buffer would abort. Few ways.
   + *  Placing cursor outside screen buffer would abort.
   + *  WinXP screen lock would abort TN5250 (BitBlt).
   + */
   +
   +/* KJK Defined for consistancy, to fix bugs */
   +#define RowsFor80Col 24
   +#define RowsFor132Col 27
   +#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
   +#define MAX(a, b)  (((a) > (b)) ? (a) : (b))
   +
    #define _TN5250_TERMINAL_PRIVATE_DEFINED
    #include "tn5250-private.h"
    #include "resource.h"
   @@ -832,7 +845,7 @@
           This->data->font_80_w = default_w;
       }

   -   win32_terminal_font(This, This->data->font_80, 80, 25,
   This->data->font_80_w, This->data->font_80_h);
   +   win32_terminal_font(This, This->data->font_80, 80, RowsFor80Col+1,
   This->data->font_80_w, This->data->font_80_h);

       if (myfont132 != NULL) {
           size = strlen(myfont132) + 1;
   @@ -1254,7 +1267,7 @@
       int y, x;
       int mx, my;
       unsigned char attr, c;
   -   unsigned char text[132*27];
   +   unsigned char text[132*RowsFor132Col];
       HBRUSH oldbrush;
       HPEN oldpen;
       int len;
   @@ -1861,6 +1874,7 @@
         static int handledkey=0;
         HMENU hMenu;
         int redraw;
   +     int lReturn = 0; /* KJK - WinXP Screen Lock Fix */

         switch (msg) {
            case WM_CREATE:
   @@ -2144,25 +2158,27 @@
               SelectObject(bmphdc, screenbuf);
               if (BitBlt(hdc, x, y, w, h, bmphdc, x, y, SRCCOPY)==0) {
                    TN5250_LOG(("WIN32: BitBlt failed: %d\n",
   GetLastError()));
   -                TN5250_ASSERT(0);
   +                lReturn = 1; /* KJK - WinXP Screen Lock Fix */
               }
   -           if (globTerm->data->caret_style != CARETSTYLE_NOBLINK) {
   -               if (hwnd == GetFocus())
   -                   win32_move_caret(hdc, globTerm);
   -           }
   -           if (globTerm->data->selected) {
   -                SetROP2(hdc, R2_NOT);
   -                if (globTerm->data->selecting)
   -                     SelectObject(hdc, GetStockObject(NULL_BRUSH) );
   -                else
   -                     SelectObject(hdc, GetStockObject(WHITE_BRUSH) );
   -                Rectangle(hdc, globTerm->data->selstr.x,
   -                               globTerm->data->selstr.y,
   -                               globTerm->data->selend.x,
   -                               globTerm->data->selend.y);
   +           if (lReturn==0) { /* KJK - WinXP Screen Lock Fix */
   +               if (globTerm->data->caret_style != CARETSTYLE_NOBLINK) {
   +                   if (hwnd == GetFocus())
   +                       win32_move_caret(hdc, globTerm);
   +               }
   +               if (globTerm->data->selected) {
   +                    SetROP2(hdc, R2_NOT);
   +                    if (globTerm->data->selecting)
   +                         SelectObject(hdc, GetStockObject(NULL_BRUSH) );
   +                    else
   +                         SelectObject(hdc, GetStockObject(WHITE_BRUSH) );
   +                    Rectangle(hdc, globTerm->data->selstr.x,
   +                                   globTerm->data->selstr.y,
   +                                   globTerm->data->selend.x,
   +                                   globTerm->data->selend.y);
   +               }
               }
               EndPaint (hwnd, &ps);
   -           return 0;
   +           return lReturn; /* KJK - WinXP Screen Lock Fix */
               break;

            case WM_RBUTTONDOWN:
   @@ -2484,11 +2500,24 @@
          sy = This->data->selstr.y / This->data->font_height;
          ey = This->data->selend.y / This->data->font_height;

   -      while (ey>tn5250_display_height(display)) ey--;
   -
   +      /* Limit to actual screen size, not calculated. 0-80 is 81
   characters, oops. */
   +      TN5250_LOG(("WIN32-win32_copy_text_selection: Width=%d\n",
   tn5250_display_width (globDisplay)));
   +      if (tn5250_display_width (globDisplay)<100) {
   +         ex = MIN(ex, (80-1));
   +         ey = MIN(ey, (RowsFor80Col-1));  /* -1 for zero-based */
   +      } else {
   +         ex = MIN(ex, (132-1));
   +         ey = MIN(ey, (RowsFor132Col-1)); /* -1 for zero-based */
   +      }
          TN5250_LOG (("Copy to clipboard sx=%d,sy=%d,ex=%d,ey=%d\n",
                       sx,sy,ex,ey));

   +      /* If the selection is fouled up then we have to get out of here.
   */
   +      if ((sx > ex) || (sy > ey))
   +         return; /* <----- EARLY RETURN */
   +
   +      while (ey>tn5250_display_height(display)) ey--;
   +
          bufsize = ((ex-sx)+3) * ((ey-sy)+1) - 1;
          hBuf = GlobalAlloc(GHND|GMEM_SHARE, bufsize);
          TN5250_ASSERT(hBuf!=NULL);
   @@ -2968,8 +2997,9 @@

       /* Set new caret position */

   -   cx = x / This->data->font_width;
   -   cy = y / This->data->font_height;
   +   /* KJK - Don't go outside screen buffer */
   +   cx = MIN(x / This->data->font_width, ((tn5250_display_width
   (globDisplay)<100) ? (80-1) : (132-1)));
   +   cy = MIN(y / This->data->font_height, ((tn5250_display_width
   (globDisplay)<100) ? (RowsFor80Col-1) : (RowsFor132Col-1)));
       tn5250_display_set_cursor(disp, cy, cx);

       This->data->caretx = cx * This->data->font_width;

   ------ Original Message ------
   Received: 01:40 PM EDT, 05/11/2009
   From: "Ken Koehler" <[email protected]>
   To: Linux 5250 Development Project <linux5250-Zwy7GipZuJhWk0Htik3J/[email protected]>, Scott Klement
   <[email protected]>
   Subject: Re: [LINUX5250] TN5250 Crash After Paste (Vista)

     Attached is .C and unified diff of fixes I list below. It compiled fine.

     These don't address Brians Paste issue.

     ------ Original Message ------
     Received: 10:23 PM EDT, 05/09/2009
     From: "Ken Koehler" <[email protected]>
     To: Linux 5250 Development Project <linux5250-Zwy7GipZuJhWk0Htik3J/[email protected]>, Scott
     Klement <[email protected]>
     Subject: Re: [LINUX5250] TN5250 Crash After Paste (Vista)

       I have a version that I combed out all the bug fixes and re-applied
       them to the original source.
       Monday I will see about recompiling and submitting the Unified Diff
       format of the changes.

       /* Fixes:
        *  Selecting text backwards (e.g. line 11 back to 10) would abort.
        *  Select & copy outside screen buffer would abort. Few ways.
        *  Placing cursor outside screen buffer would abort.
        *  WinXP screen lock would abort TN5250 (BitBlt).
        */

       Hey wait, your issue is with PASTE not COPY. That's news to me and I
       would like to address it.
       Can you tell me more about how you are doing it? A screen picture
       would probably help so I can see the nature of the paste, like field
       size(s), single or multi-line paste, etc.

       ------ Original Message ------
       Received: 07:23 PM EDT, 05/08/2009
       From: "Ken Koehler" <[email protected]>
       To: Linux 5250 Development Project <linux5250-Zwy7GipZuJhWk0Htik3J/[email protected]>, Scott
       Klement <[email protected]>
       Subject: Re: [LINUX5250] TN5250 Crash After Paste (Vista)

         I have made many Windows platform fixes, including this one. The
         tough part is that they are becoming intertwined.

         The problem is when the user selects outside the 80x24 or 132x27
         range. Another bug was like starting with line 0 versus line 1 of
         the screen buffer.

         I'm super busy at work, converting from rs/6000 unix based ERP to
         iSeries solution. I'll see when I can extract the fixes. Do you
         Brian have the ability to recompile if I give you source or
         differences? You want my EXE to get you by for the short term at
         least?

         I've added other config file options like title bar value, can
         restrict users from exiting TN5250 if not at login screen. I fixed
         screen resizing between 80 and 132 column, but my fix is the
         opposite of how unix version works. I keep window the same size and
         resize the fonts to fit.
         I fixed WinXP problem where program hoses up when screen is locked
         and user has to enter password.

         ------ Original Message ------
         Received: 03:54 PM EDT, 05/08/2009
         From: Scott Klement <[email protected]>
         To: Linux 5250 Development Project <linux5250-Zwy7GipZuJhWk0Htik3J/[email protected]>
         Subject: Re: [LINUX5250] TN5250 Crash After Paste (Vista)

           By all means, try that... enable the trace function and see if you
           can
           replicate it. It *might* help, though I don't know that there's
           sufficient info in the trace file to help me debug a problem like
           this.

           However, I don't have access to a Vista machine. So even if I
           think I
           find the solution, I'm not sure how I could tell that my solution
           worked.

           Brian wrote:
           > Hey Scott. I am still having this issue in Vista. Is there
           anything I
           > can do to provide more info? I did see a logging option. Once I
           copy
           > something 'bad', I can replicate the issue over and over. So,
           maybe
           > once it happens again I could activate logging and capture some
           info?
           >
           > Thanks much.
           >
           > Scott Klement wrote:
           >> Hi Brian,
           >>
           >> Are you using the current version of TN5250? (The one we
           released a
           >> month or so ago?)
           >>
           >> I know I fixed some similar issues in that release.
           >>
           >> I know of an outstanding bug in the copy to clipboard (if you
           select
           >> text outside the normal 80x24 or 132x27 screen, it'll try to
           copy the
           >> text, and crash) but I don't know of any outstanding issues
           with paste...
           >>
           >> I'm running XP, and don't currently have access to a Vista box.
           If
           >> updating to the current version doesn't help, can you tell me
           how to
           >> reproduce the problem on XP? (Or something I can try to
           reproduce the
           >> problem?) Without being able to reproduce it, I don't even know
           how to
           >> begin to debug it...
           >>
           >>
           >> Brian wrote:
           >>> Hello all.
           >>>
           >>> I seem to be experiencing some odd issue in TN5250 that
           happens when I
           >>> paste data (normal text data) from another windows application
           (like
           >>> Outlook) in to a 5250 session. The session ends up crashing
           and I need
           >>> to restart it. I can reproduce the scenario over and over when
           >>> copy/pasting the same data. However, when I type that same
           text in to
           >>> the 5250 session, all is well, and if I type it in to the 5250
           window
           >>> and then copy paste it from there, it is OK as well.
           >>>
           >>> My OS is Vista business. I just switched from XP and I do not
           recall
           >>> having this issue in XP at all, or if I did, it was not
           reproducible on
           >>> demand like this one is in Vista.
           >>>
           >>> My guess is that something is coming along in the buffer in
           Vista as I
           >>> am copy/pasting that TN5250 does not like.
           >>>
           >>> Is this a known issue or is there some workaround perhaps?
           >>>
           >>> Thanks much.
           >

           --
           This is the Linux 5250 Development Project (LINUX5250) mailing
           list
           To post a message email: LINUX5250-Zwy7GipZuJhWk0Htik3J/[email protected]
           To subscribe, unsubscribe, or change list options,
           visit: http://lists.midrange.com/mailman/listinfo/linux5250
           or email: LINUX5250-request-Zwy7GipZuJhWk0Htik3J/[email protected]
           Before posting, please take a moment to review the archives
           at http://archive.midrange.com/linux5250.

     > ---------------------------------------------
     > Attachment: winterm.c
     > MIME Type: text/plain
     > ---------------------------------------------
     > ---------------------------------------------
     > Attachment: winterm-select.UnifiedDiff
     > MIME Type: text/plain
     > ---------------------------------------------
-- 
This is the Linux 5250 Development Project (LINUX5250) mailing list
To post a message email: LINUX5250-Zwy7GipZuJhWk0Htik3J/[email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/linux5250
or email: LINUX5250-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/linux5250.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.