From fe4773b50e6f715760269693af36993866a0faff Mon Sep 17 00:00:00 2001 From: robekras Date: Tue, 8 Nov 2005 19:10:49 +0000 Subject: [PATCH] 1) Added a 'try catch block' to sendPacket to avoid exceptions when PHP script is finished. --- .../phpdt/internal/debug/core/PHPDBGPacket.java | 33 ++++++++++++++----- 1 files changed, 24 insertions(+), 9 deletions(-) diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGPacket.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGPacket.java index cbbcdbe..313f57d 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGPacket.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGPacket.java @@ -13,6 +13,17 @@ package net.sourceforge.phpdt.internal.debug.core; import java.io.IOException; import java.io.OutputStream; import java.util.Vector; + +/** + * + * TODO: Added a try catch block in sendPacket to avoid an execption in case the PHP script + * has finished and DBG isn't ready for receiving any new frame. + * (This happens when mouse is hovering over variable or user switches to watch expression) + * It is not clear why DBG isn't sending any SCRIPT_END event (or something similar), + * or whether there is another way to check whether DBG is listening or not. + * For the moment this is only a workaround. + * + */ public class PHPDBGPacket { private static final int PACKET_HEADER_SIZE = 16; @@ -36,19 +47,23 @@ public class PHPDBGPacket { PHPDBGBase.copyCharsTo (packetHeader, PHPDBGBase.IntToChar4 (packetSize), 4, 12); - out.write (PHPDBGBase.CharArrayToByteArray (packetHeader)); // Send packet header - out.flush (); // - - for (i = 0; i < frames.size (); i++) { // Send Frames - frame = (PHPDBGFrame) frames.get (i); // Header of frame + try { + out.write (PHPDBGBase.CharArrayToByteArray (packetHeader)); // Send packet header + out.flush (); // - out.write (PHPDBGBase.CharArrayToByteArray (frame.getHeader ())); // Convert the char buffer to a byte buffer and send - out.flush (); + for (i = 0; i < frames.size (); i++) { // Send Frames + frame = (PHPDBGFrame) frames.get (i); // Header of frame - if (frame.getSizeOfData () > 0) { // If there is a data frame - out.write (PHPDBGBase.CharArrayToByteArray (frame.getFrameData ()));// Convert the data char buffer to a byte buffer and send + out.write (PHPDBGBase.CharArrayToByteArray (frame.getHeader ())); // Convert the char buffer to a byte buffer and send out.flush (); + + if (frame.getSizeOfData () > 0) { // If there is a data frame + out.write (PHPDBGBase.CharArrayToByteArray (frame.getFrameData ()));// Convert the data char buffer to a byte buffer and send + out.flush (); + } } } + catch (Exception e) { + } } } -- 1.7.1