added null point handling for get dragging file directory.

This commit is contained in:
jerry 2013-09-26 11:34:21 +00:00
parent 952be51c8c
commit 10b9b2e406
3 changed files with 42 additions and 32 deletions

View File

@ -363,7 +363,6 @@ CMSWindowsScreen::leave()
if (getDraggingStarted()) {
CString& draggingDir = getDraggingFileDir();
LOG((CLOG_DEBUG "get dragging file dir: %s", draggingDir.c_str()));
size_t size = draggingDir.size();
if (!m_isPrimary) {
@ -373,6 +372,7 @@ CMSWindowsScreen::leave()
fakeMouseButton(kButtonLeft, false);
if (draggingDir.empty() == false) {
CClientApp& app = CClientApp::instance();
CClient* client = app.getClientPtr();
UInt32 fileCount = 1;
@ -381,6 +381,7 @@ CMSWindowsScreen::leave()
LOG((CLOG_DEBUG "send dragging file to server"));
client->sendFileToServer(draggingDir.c_str());
}
}
m_draggingStarted = false;
}

View File

@ -900,11 +900,7 @@ COSXScreen::leave()
hideCursor();
if (getDraggingStarted()) {
CFStringRef dragInfo = getDraggedFileURL();
char* dragInfoCStr = CFStringRefToUTF8String(dragInfo);
LOG((CLOG_DEBUG "drag info: %s", dragInfoCStr));
CFRelease(dragInfo);
CString fileList(dragInfoCStr);
CString& fileList = getDraggingFileDir();
size_t size = fileList.size();
if (!m_isPrimary) {
@ -916,12 +912,15 @@ COSXScreen::leave()
// fake ctrl key up
fakeKeyUp(29);
if (fileList.empty() == false) {
CClientApp& app = CClientApp::instance();
CClient* client = app.getClientPtr();
UInt32 fileCount = 1;
client->draggingInfoSending(fileCount, fileList, size);
LOG((CLOG_DEBUG "send dragging file to server"));
client->sendFileToServer(dragInfoCStr);
client->sendFileToServer(fileList.c_str());
}
}
m_draggingStarted = false;
}
@ -2100,11 +2099,17 @@ COSXScreen::getDraggingFileDir()
{
if (m_draggingStarted) {
CFStringRef dragInfo = getDraggedFileURL();
char* info = CFStringRefToUTF8String(dragInfo);
char* info = NULL;
info = CFStringRefToUTF8String(dragInfo);
if (info == NULL) {
m_draggingFileDir.clear();
}
else {
LOG((CLOG_DEBUG "drag info: %s", info));
CFRelease(dragInfo);
CString fileList(info);
m_draggingFileDir = fileList;
}
}
return m_draggingFileDir;
}

View File

@ -1750,10 +1750,13 @@ CServer::onMouseMovePrimary(SInt32 x, SInt32 y)
if (m_screen->getDraggingStarted() && m_active != newScreen) {
CString& dragFileList = m_screen->getDraggingFileDir();
size_t size = dragFileList.size() + 1;
char* fileList = new char[size];
char* fileList = NULL;
UInt32 fileCount = 1;
if (dragFileList.empty() == false) {
fileList = new char[size];
memcpy(fileList, dragFileList.c_str(), size);
fileList[size - 1] = '\0';
UInt32 fileCount = 1;
}
// fake a escape key down and up then left mouse button up
m_screen->keyDown(kKeyEscape, 8192, 1);
@ -1769,11 +1772,12 @@ CServer::onMouseMovePrimary(SInt32 x, SInt32 y)
m_ignoreFileTransfer = true;
#endif
if (dragFileList.empty() == false) {
LOG((CLOG_DEBUG2 "sending drag information to client"));
LOG((CLOG_DEBUG3 "dragging file list: %s", fileList));
LOG((CLOG_DEBUG3 "dragging file list string size: %i", size));
newScreen->draggingInfoSending(fileCount, fileList, size);
//m_screen->setDraggingStarted(false);
}
}
// switch screen