Fix dropping files onto the window under Wayland in some cases
Dropping files from gnome-web onto Blender failed because the URL data didn't end with a newline.
This commit is contained in:
parent
eb856f6fbb
commit
0f3b691c22
|
@ -2432,16 +2432,22 @@ static void data_device_handle_drop(void *data, wl_data_device * /*wl_data_devic
|
|||
std::vector<std::string> uris;
|
||||
|
||||
size_t pos = 0;
|
||||
while (true) {
|
||||
while (pos != std::string::npos) {
|
||||
pos = data.find(file_proto, pos);
|
||||
const size_t start = pos + sizeof(file_proto) - 1;
|
||||
pos = data.find(lf, pos);
|
||||
|
||||
if (pos == std::string::npos) {
|
||||
break;
|
||||
}
|
||||
/* Account for 'CRLF' case. */
|
||||
const size_t start = pos + sizeof(file_proto) - 1;
|
||||
pos = data.find(lf, pos);
|
||||
|
||||
size_t end = pos;
|
||||
if (UNLIKELY(end == std::string::npos)) {
|
||||
/* Note that most well behaved file managers will add a trailing newline,
|
||||
* Gnome's web browser (44.3) doesn't, so support reading up until the last byte. */
|
||||
/* Account for 'CRLF' case. */
|
||||
end = data.size();
|
||||
}
|
||||
/* Account for 'CRLF' case. */
|
||||
if (data[end - 1] == '\r') {
|
||||
end -= 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue