-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dragging item from archiver onto pcmanfm's side pane freezes the archiver #45
Comments
A patch which seems most unintrusive to me: diff -ur libfm-1.3.2/src/gtk/fm-dnd-dest.c libfm-1.3.2/src/gtk/fm-dnd-dest.c
--- libfm-1.3.2/src/gtk/fm-dnd-dest.c 2022-10-31 01:05:49.931057670 +0800
+++ libfm-1.3.2/src/gtk/fm-dnd-dest.c 2022-10-31 01:07:27.667579011 +0800
@@ -979,7 +979,7 @@
if (dd->context != drag_context)
clear_src_cache(dd);
action = 0;
- if(!dd->waiting_data) /* we're still waiting for "drag-data-received" signal */
+ if(dest_path && !dd->waiting_data) /* we're still waiting for "drag-data-received" signal */
{
/* retrieve the source files */
gtk_drag_get_data(dd->widget, drag_context, target, time(NULL)); |
Sorry, incomplete check... diff -ur libfm-1.3.2/src/gtk/fm-dnd-dest.c libfm-1.3.2/src/gtk/fm-dnd-dest.c
--- libfm-1.3.2/src/gtk/fm-dnd-dest.c 2022-10-31 01:05:49.931057670 +0800
+++ libfm-1.3.2/src/gtk/fm-dnd-dest.c 2022-10-31 01:07:27.667579011 +0800
@@ -979,7 +979,7 @@
if (dd->context != drag_context)
clear_src_cache(dd);
action = 0;
- if(!dd->waiting_data) /* we're still waiting for "drag-data-received" signal */
+ if(dest && dest_path && !dd->waiting_data) /* we're still waiting for "drag-data-received" signal */
{
/* retrieve the source files */
gtk_drag_get_data(dd->widget, drag_context, target, time(NULL)); |
Did you build and test this? It doesn't seem to have a PR yet. |
@CasperVector it probably will work, but doesn't that just effectively revert 1d7738c? I'm not sure the reason behind that commit, and it's from 2012, but it sill might be interesting to see why that was done like so. |
@CasperVector, I just tried your patch, but unfortunately it didn't fix the issue for me. Once I drag a file from a extractor application like engrampa over pcmanfm panel, it shows this error just like it happens without your patch: I also tried to combine with this other patch mentioned here but it didn't change anything :( |
Sorry, I did not research (and now probably cannot afford to; I have been extremely busy with my day job for nearly an entire year) the commit you mentioned. But I can confirm my patch works on Devuan Chimaera and Devuan Daedalus (and probably the corresponding Debian releases), both against libfm 1.3.2. |
I think the error popup is expected when you (drag and) drop an entry in a compressed file onto the pcmanfm's side pane; what my patch does is to prevent the desktop freeze when the entry is dragged across the pane. I do not know which you mean, but as is said in the previous message, the patch is confirmed to work in the environments I use. |
That's what I thought. |
Now I see!
Sure, but it happens just by hovering (no drop) over the panel, which clearly is not the expected behavior. |
That is exactly what my patch attempts to prevent. So both my patch and the other patch you mentioned probably need some refinement, preferably by someone capable (and having the time) of debugging your case (either locally or remotely). |
This is intriguing. Are you building against GTK2 or GTK3? |
I think it should be GTK3; my Devuan Chimaera (previous) and Devuan Daedalus (current) enviroments do not use GTK2. |
@CasperVector, I think I found the cause of the issue. Try this patch -- don't need to use your patch nor this one.
Explanation: engrampa window (and potentially other extractors) has After applying my patch, I tested drag and dropping from engrampa to the file section of pcmanfm and it's still extracting, so no regression. Also, when drag and dropping a folder from pcmanfm to the side panel, it's still creating a bookmark, so again no regression here. Let me know if you find any issues. Thanks! |
I can confirm your latest patch also prevents the freeze, and (just like in your test) does not suffer from the two regressions. Even better, it also eliminates the error popup in your screenshot, and corresponds to a clear explanation of the root cause. Many thanks! |
Cool! |
In the library source file gtkdragdest.c, What happens if the patch is made like this: gboolean ret = FALSE;
GdkDragAction action = 0;
+ GtkWidget* source_widget = gtk_drag_get_source_widget (drag_context);
+ if (source_widget == NULL) {
+ return FALSE;
+ }
+
target = gtk_drag_dest_find_target(dest_widget, drag_context, NULL);
if(target == GDK_NONE)
return FALSE;
One possibility is that the GTK call hangs because that's where it hangs in the bug. Otherwise it's a few lines shorter (and could be 1 line shorter by collapsing the declaration: |
@dirkf, even better! I confirm it works! |
I can confirm the same. Thanks! |
So this is a solution that works for PCManFM without affecting other packages: time for a PR? The originally suggested patch seems to be good practice too, even if it doesn't solve the issue, so maybe include both commits? |
Well, it might affect packages that depend on libfm, although very unlikely to cause any issue due to the nature of the changes we made.
I don't see any need for this other patch made by zhuyaliang. I wouldn't include it. But yes, I'm happy to suggest your code in a PR. Maybe just removing the curly brackets to keep consistency across the code. :) |
That was just the Gnome style that I pulled in. Some style guides mandate I also don't much like Unfortunately we still haven't discovered the dangerous bug, whereby GTK could hang the UI when this patch is absent. Probably we won't, now, but, if calling
Since GTK must be many times more exercised than PCManFM, I wonder if the latter might be incorrectly setting some data (the possible targets in the Places widget, say) so as to pass to or cause a circular list in GTK. Some years ago the Windows user APIs were overhauled to check user-supplied data more strictly; I think I would want my library code to validate a user-supplied linked list before processing it or handing it out to other API users. |
In principle, there is no freeze. 😉 If you drag very carefully on an entry in the side pane, you can see that dropping is actually possible there. The patch suggested by @dirkf simply disables any drop on the side pane from other applications, which isn't what we want. The freeze happens during a drop attempt between entries, because libfm needs a call to fm_dnd_dest_get_default_action() for its own drops (from folder view to side pane), where it calls gtk_drag_get_data() due to 1d7738c - a call that goes to the archiver, although it is not intended for it. So for XDirectSave, we just need to make sure that the GdkDragAction is determined without getting lost in libfm's drop code:
Indirectly, @CasperVector's patch already did this (because Please test and report back. |
From https://old.reddit.com/r/gnome/comments/1c8vy11/any_drag_and_drop_archive_managers/l0ju1tm/
Anyhow, is it possible that this fix also enables folder (name) drag-drop from PCManFM to XFCE Terminal, as with Thunar? |
What do you mean? Is there a bug report for this? |
Thanks for your interest. I'm not aware of one (I did look here and in the PCManFM SF tracker), but making LibFM XDirectSave-aware seemed like it might be a solution, since you can drag a file on to the XFCE terminal window from Thunar, which in turn doesn't have this drag-drop bug. Apasrt from the original author, no-one could know whether this functionality in PCManFM is broken or was never intended to exist. |
Works for me with both Thunar and PCManFM. |
OK, thx, it does now with 1.3.2-1 versions of PCManFM/LibFM (seems like what I had before) and the supporting libs now in a fully updated MX-Linux 23; it surely used not to work. With the above configuration, while it is true that dragging an archive entry to the Places pane may work if drag is made directly to a writable Place, the UI can nonetheless be locked. Personally I wouldn't mind not being able to drag-drop to a Place, but it would be a pity to have disabled drag-drop to an item in the Directory Tree pane. The current failing behaviour is similar to my earlier description, but I now see these characteristics (maybe overlooked when preparing that description):
The error dialog is similar to what appears when dropping the entry on If as you say |
Please give me an example. If it's an unwritable location, it's up to the archiver to detect it and report the error.
If you test my patch, you will notice that none of this happens anymore (at least not with Xarchiver). The target is responsible for indicating whether a drop is possible at all, and the source is responsible for indicating whether the drop was successful or not.
I've already fixed this as well. Besides the above patch, I currently have four others in my local repository to make drag and drop look more like it should.
This is due to a drag-finish during a drag-received during a drag-motion, i.e. the drag is finished without a drop action that the archiver is still waiting for, roughly speaking.
Not unless someone reports a bug caused by an internal drag and drop. |
That was exactly the original report:
That is, the problem that your patch will correct. I observed the deadlock in these cases:
Dragging to these Places without infringing on the above doesn't cause a deadlock, nor dragging to any part (that I tried) of the Directory Tree Pane.
This seems like a critical error that a GUI framework ought to be detecting and preventing or mitigating, but obviously is out of scope here. Many thanks for your work, which should also fix these long-standing PCManFM issues: |
if(!dd->waiting_data) { ... }
branch when eitherdest
ordest_path
is zero prevents the symptom from occuring. However, I am totally unfamiliar with the drag-and-drop protocols, and therefore unsure whether this fixes the root cause of this issue and does not cause undesirable side effects.The text was updated successfully, but these errors were encountered: