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

View File

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

View File

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