diff options
author | Hans Goudey <h.goudey@me.com> | 2022-08-31 16:07:51 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-08-31 16:15:09 +0300 |
commit | 3ecb21346248014aff621ec3b97ccbc1e7774653 (patch) | |
tree | b571a51b93d61efc01bf8a75a74ecade8e463d16 /intern/ghost/intern/GHOST_DropTargetWin32.cpp | |
parent | b5af7f967e6d5d2e7432d6efa2f47050a5bfc576 (diff) | |
parent | 773241add9d876aa0b4ba011745208f61b53a4e2 (diff) |
Merge branch 'master' into refactor-mesh-material-index-genericrefactor-mesh-material-index-generic
Diffstat (limited to 'intern/ghost/intern/GHOST_DropTargetWin32.cpp')
-rw-r--r-- | intern/ghost/intern/GHOST_DropTargetWin32.cpp | 62 |
1 files changed, 26 insertions, 36 deletions
diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cpp b/intern/ghost/intern/GHOST_DropTargetWin32.cpp index 2283cff3827..03d55c848e3 100644 --- a/intern/ghost/intern/GHOST_DropTargetWin32.cpp +++ b/intern/ghost/intern/GHOST_DropTargetWin32.cpp @@ -219,35 +219,30 @@ void *GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject *pDataObject) hdrop = (HDROP)::GlobalLock(stgmed.hGlobal); totfiles = ::DragQueryFileW(hdrop, -1, NULL, 0); - if (!totfiles) { - ::GlobalUnlock(stgmed.hGlobal); - return NULL; - } - - strArray = (GHOST_TStringArray *)::malloc(sizeof(GHOST_TStringArray)); - strArray->count = 0; - strArray->strings = (uint8_t **)::malloc(totfiles * sizeof(uint8_t *)); - - for (UINT nfile = 0; nfile < totfiles; nfile++) { - if (::DragQueryFileW(hdrop, nfile, fpath, MAX_PATH) > 0) { - if (!(temp_path = alloc_utf_8_from_16(fpath, 0))) { - continue; + if (totfiles) { + strArray = (GHOST_TStringArray *)::malloc(sizeof(GHOST_TStringArray)); + strArray->count = 0; + strArray->strings = (uint8_t **)::malloc(totfiles * sizeof(uint8_t *)); + + for (UINT nfile = 0; nfile < totfiles; nfile++) { + if (::DragQueryFileW(hdrop, nfile, fpath, MAX_PATH) > 0) { + if (!(temp_path = alloc_utf_8_from_16(fpath, 0))) { + continue; + } + /* Just ignore paths that could not be converted verbatim. */ + + strArray->strings[nvalid] = (uint8_t *)temp_path; + strArray->count = nvalid + 1; + nvalid++; } - /* Just ignore paths that could not be converted verbatim. */ - - strArray->strings[nvalid] = (uint8_t *)temp_path; - strArray->count = nvalid + 1; - nvalid++; } } /* Free up memory. */ ::GlobalUnlock(stgmed.hGlobal); ::ReleaseStgMedium(&stgmed); - - return strArray; } } - return NULL; + return strArray; } void *GHOST_DropTargetWin32::getDropDataAsString(IDataObject *pDataObject) @@ -261,16 +256,18 @@ void *GHOST_DropTargetWin32::getDropDataAsString(IDataObject *pDataObject) if (pDataObject->QueryGetData(&fmtetc) == S_OK) { if (pDataObject->GetData(&fmtetc, &stgmed) == S_OK) { LPCWSTR wstr = (LPCWSTR)::GlobalLock(stgmed.hGlobal); - if (!(tmp_string = alloc_utf_8_from_16((wchar_t *)wstr, 0))) { - ::GlobalUnlock(stgmed.hGlobal); - return NULL; - } + + tmp_string = alloc_utf_8_from_16((wchar_t *)wstr, 0); + /* Free memory. */ ::GlobalUnlock(stgmed.hGlobal); ::ReleaseStgMedium(&stgmed); + #ifdef WITH_GHOST_DEBUG - ::printf("\n<converted droped unicode string>\n%s\n</droped converted unicode string>\n", - tmp_string); + if (tmp_string) { + ::printf("\n<converted droped unicode string>\n%s\n</droped converted unicode string>\n", + tmp_string); + } #endif /* WITH_GHOST_DEBUG */ return tmp_string; } @@ -283,15 +280,8 @@ void *GHOST_DropTargetWin32::getDropDataAsString(IDataObject *pDataObject) char *str = (char *)::GlobalLock(stgmed.hGlobal); tmp_string = (char *)::malloc(::strlen(str) + 1); - if (!tmp_string) { - ::GlobalUnlock(stgmed.hGlobal); - return NULL; - } - - if (!::strcpy(tmp_string, str)) { - ::free(tmp_string); - ::GlobalUnlock(stgmed.hGlobal); - return NULL; + if (tmp_string) { + ::strcpy(tmp_string, str); } /* Free memory. */ ::GlobalUnlock(stgmed.hGlobal); |