X-Git-Url: http://git.phpeclipse.com 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..337a556 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; @@ -34,21 +45,27 @@ public class PHPDBGPacket { int i; PHPDBGFrame frame; +// System.out.println ("PHPDBGPacket: sendPacket"); + 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) { + } } }