Bug 38073 - Failure when dragging file from Project A to Project B then back to Project A
Summary: Failure when dragging file from Project A to Project B then back to Project A
Status: VERIFIED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General (show other bugs)
Version: 5.10 (C6SR3)
Hardware: PC Mac OS
: Normal normal
Target Milestone: (C8)
Assignee: Matt Ward
URL:
Depends on:
Blocks:
 
Reported: 2016-01-26 21:19 UTC by Brad Umbaugh
Modified: 2016-07-13 09:16 UTC (History)
5 users (show)

See Also:
Tags: papercut,NotRegression
Is this bug a regression?: ---
Last known good build:


Attachments

Description Brad Umbaugh 2016-01-26 21:19:16 UTC
- Create a solution, add an iOS app and an iOS library project that the app references
- Add a class in the library project
- Drag the class from the library project to the app project
- Now drag the same file from the app project to the library project

This second file move -- back into the original project -- doesn't work; the file never moves. Restarting Xamarin Studio will allow you to complete the operation. This can be frustrating when second-guessing architectural decisions.
Comment 1 Matt Ward 2016-02-03 10:03:25 UTC
Unable to reproduce this with Xamarin Studio 5.10.2.

Is this still happening? Is there anything in the IDE log (Help - Open Log directory)?
Comment 2 Brad Umbaugh 2016-02-05 04:36:28 UTC
Thanks for checking it out, Matt.

Here's a screencast:
http://screencast.com/t/TxuOLozLn
Comment 6 Matt Ward 2016-02-05 09:37:37 UTC
I am still unable to reproduce it following the same steps. One difference is that I am on Yosemite whilst you are on El Capitan.

The only thing I can see in the IDE log is a Git error but the callstack for that does not seem to be involved with any drag operation.

 Version control status query failed
LibGit2Sharp.AmbiguousSpecificationException: More than one file matches the pathspec 'DragTestLibrary'. You can either force a literal path evaluation (GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH), or use git_status_foreach().
  at LibGit2Sharp.Core.Proxy.git_status_file (LibGit2Sharp.Core.Handles.RepositorySafeHandle repo, LibGit2Sharp.Core.FilePath path) [0x0003f] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/external/libgit2sharp/LibGit2Sharp/Core/Proxy.cs:2778 
  at LibGit2Sharp.Repository.RetrieveStatus (System.String filePath) [0x00020] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/external/libgit2sharp/LibGit2Sharp/Repository.cs:1989 
  at MonoDevelop.VersionControl.Git.GitRepository.GetFilesVersionInfoCore (LibGit2Sharp.Repository repo, MonoDevelop.VersionControl.Git.GitRevision rev, System.Collections.Generic.List`1 localPaths, System.Collections.Generic.List`1 versions) [0x0001e] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs:459 
  at MonoDevelop.VersionControl.Git.GitRepository.GetDirectoryVersionInfo (FilePath localDirectory, IEnumerable`1 localFileNames, Boolean getRemoteStatus, Boolean recursive) [0x001cd] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs:420 
  at MonoDevelop.VersionControl.Git.GitRepository.OnGetVersionInfo (IEnumerable`1 paths, Boolean getRemoteStatus) [0x0000a] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs:369 
  at MonoDevelop.VersionControl.Repository.RunQueries (System.Object ob) [0x0013c] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs:417 


After that there is a GTK# error which is from a drag operation - OnDragBegin but I am not sure if that is just GTK logging a problem or failing the drag.

Gtk-Critical: void gtk_drag_set_icon_pixbuf(GdkDragContext *, GdkPixbuf *, gint, gint): assertion `GDK_IS_PIXBUF (pixbuf)' failed
Stack trace: 
  at Gtk.Drag.gtk_drag_set_icon_pixbuf (IntPtr , IntPtr , Int32 , Int32 ) [0x00000] in <filename unknown>:0 
  at Gtk.Drag.SetIconPixbuf (Gdk.DragContext context, Gdk.Pixbuf pixbuf, Int32 hot_x, Int32 hot_y) [0x0002f] in /private/tmp/source-mono-mac-4.2.0-branch-c6sr1/bockbuild-mono-4.2.0-branch/profiles/mono-mac-xamarin/build-root/gtk-sharp-2.12.21/gtk/generated/Drag.cs:199 
  at MonoDevelop.Ide.Gui.Components.ExtensibleTreeView+ExtensibleTreeViewTree.OnDragBegin (Gdk.DragContext context) [0x0002c] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs:2170 
  at Gtk.Widget.dragbegin_cb (IntPtr widget, IntPtr context) [0x0001b] in /private/tmp/source-mono-mac-4.2.0-branch-c6sr1/bockbuild-mono-4.2.0-branch/profiles/mono-mac-xamarin/build-root/gtk-sharp-2.12.21/gtk/generated/Widget.cs:1887 
  at Gtk.Application.gtk_main () [0x00000] in <filename unknown>:0 
  at Gtk.Application.Run () [0x00001] in /private/tmp/source-mono-mac-4.2.0-branch-c6sr1/bockbuild-mono-4.2.0-branch/profiles/mono-mac-xamarin/build-root/gtk-sharp-2.12.21/gtk/Application.cs:135 
  at MonoDevelop.Ide.IdeApp.Run () [0x00000] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs:376 
  at MonoDevelop.Ide.IdeStartup.Run (MonoDevelop.Ide.MonoDevelopOptions options) [0x00833] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:291 
  at MonoDevelop.Ide.IdeStartup.Main (System.String[] args, MonoDevelop.Ide.Extensions.IdeCustomizer customizer) [0x00093] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:652 
  at Xamarin.Startup.MainClass.Main (System.String[] args) [0x00003] in /Users/builder/data/lanes/2693/bb74ff46/source/md-addins/Xamarin.Startup/Main.cs:11
Comment 7 Brad Umbaugh 2016-02-05 20:26:28 UTC
I tried to reproduce this in Xamarin Studio by making a new iOS app, this time without enabling git integration in the new project wizard. 

I was still able to produce the problem; this error appeared in the Xamarin Studio log immediately after the drag failed:

ERROR [2016-02-05 10:34:33Z]: Gtk-Critical: void gtk_drag_set_icon_pixbuf(GdkDragContext *, GdkPixbuf *, gint, gint): assertion `GDK_IS_PIXBUF (pixbuf)' failed
Stack trace:
  at Gtk.Drag.gtk_drag_set_icon_pixbuf (IntPtr , IntPtr , Int32 , Int32 ) [0x00000] in <filename unknown>:0
  at Gtk.Drag.SetIconPixbuf (Gdk.DragContext context, Gdk.Pixbuf pixbuf, Int32 hot_x, Int32 hot_y) [0x0002f] in /private/tmp/source-mono-mac-4.2.0-branch-c6sr1/bockbuild-mono-4.2.0-branch/profiles/mono-mac-xamarin/build-root/gtk-sharp-2.12.21/gtk/generated/Drag.cs:199
  at MonoDevelop.Ide.Gui.Components.ExtensibleTreeView+ExtensibleTreeViewTree.OnDragBegin (Gdk.DragContext context) [0x0002c] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs:2170
  at Gtk.Widget.dragbegin_cb (IntPtr widget, IntPtr context) [0x0001b] in /private/tmp/source-mono-mac-4.2.0-branch-c6sr1/bockbuild-mono-4.2.0-branch/profiles/mono-mac-xamarin/build-root/gtk-sharp-2.12.21/gtk/generated/Widget.cs:1887
  at Gtk.Application.gtk_main () [0x00000] in <filename unknown>:0
  at Gtk.Application.Run () [0x00001] in /private/tmp/source-mono-mac-4.2.0-branch-c6sr1/bockbuild-mono-4.2.0-branch/profiles/mono-mac-xamarin/build-root/gtk-sharp-2.12.21/gtk/Application.cs:135
  at MonoDevelop.Ide.IdeApp.Run () [0x00000] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs:376
  at MonoDevelop.Ide.IdeStartup.Run (MonoDevelop.Ide.MonoDevelopOptions options) [0x00833] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:291
  at MonoDevelop.Ide.IdeStartup.Main (System.String[] args, MonoDevelop.Ide.Extensions.IdeCustomizer customizer) [0x00093] in /Users/builder/data/lanes/2693/bb74ff46/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:652
  at Xamarin.Startup.MainClass.Main (System.String[] args) [0x00003] in /Users/builder/data/lanes/2693/bb74ff46/source/md-addins/Xamarin.Startup/Main.cs:11
2016-02-05 10:34:33.912 XamarinStudio[6580:1355643] _DPSDiscardEvents: FlushEventsMatchingListFromQueue returned error (-50)
text/uri-list:
Comment 9 Matt Ward 2016-03-22 12:07:23 UTC
OK I may have reproduced this with Xamarin Studio 5.10.2, 5.10.3 (build 26) and 6.0 (build 4801) in a slightly different way. The drag was not between two projects but between two folders in the same project but the symptoms seem to be the same.

My repro steps were:

1) Create a new Xamarin.Forms project - with PCL project.
2) I created a folder called abc.
3) Right click the abc folder and select Add - New File and create a new Forms Content Page Xaml. After this is complete you should see nothing is selected in the Solution window. Note that if the new .cs file is highlighted/selected in the Solution window then the error does not occur.
4) If you now try to drag that file to the Properties folder the drag does not seem to work and you see the Gtk-Critical: void gtk_drag_set_icon_pixbuf error. Note that if you click the file first without dragging and then drag it then it works.

Screencast: http://www.screencast.com/t/7ariqTvojTo

Looking at the screencast in #c2 the drag problem seems to be the same. In #c2 the file is not initially selected and the drag will then fail.
Comment 10 Matt Ward 2016-03-22 16:46:19 UTC
The gtk-critical error is just a symptom. If the dragIcon is null then calling Drag.SetIconPixbuf will report the gtk-critical error. If Drag.SetIconPixbuf is not called when the dragIcon is null then the problem still occurs.

The main problem is that when nothing is selected in the tree view then nothing is being dragged so even though it looks like the file is being dragged, nothing really is, so nothing happens.

The bug seems to be due to the custom SelectFunction added in the ContextMenuTreeView's OnButtonPressEvent method which overrides the default selection of the tree view and prevents the file being selected when you drag it when nothing is selected in the tree view.

https://github.com/mono/monodevelop/blob/45821f1f0a392937dd454dfeef6085c9a9ee539d/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuTreeView.cs#L74-L79

Sometimes when you ctrl+click to bring up the Add File dialog you sometimes manage to call into ContextMenuTreeView's OnButtonPressEvent method twice. The first time shows the popup and then the second call modifies the Selection.SelectFunction so it returns false and disables the selection. Now when the new file dialog creates the files the selection is not updated since SelectFunction now returns false. This method is still called when the drag operation starts if you click but do not release the button.

With some logging added to the ContextMenuTreeView:

INFO [2016-03-22 16:26:02Z]: OnButtonPressEvent - start
INFO [2016-03-22 16:26:02Z]: OnButtonPressEvent - Check IsClickedNodeSelected
INFO [2016-03-22 16:26:02Z]: OnButtonPressEvent - DoPopup
INFO [2016-03-22 16:26:02Z]: OnButtonPressEvent - end
INFO [2016-03-22 16:26:02Z]: OnButtonPressEvent start
INFO [2016-03-22 16:26:02Z]: OnButtonPressEvent - hookup custom SelectFunction
INFO [2016-03-22 16:26:02Z]: OnButtonPressEvent - end - call base.OnButtonPressEvent

New files created:

INFO [2016-03-22 16:26:11Z]: OnButtonPressEvent - custom SelectFunction called
INFO [2016-03-22 16:26:11Z]: OnButtonPressEvent - custom SelectFunction called

Now try to drag:

INFO [2016-03-22 16:28:03Z]: OnButtonPressEvent start
INFO [2016-03-22 16:28:03Z]: OnButtonPressEvent end - call base.OnButtonPressEvent
INFO [2016-03-22 16:28:03Z]: OnButtonPressEvent - custom SelectFunction called
INFO [2016-03-22 16:28:04Z]: GetDragObjects - No selected nodes.

A possible workaround would be to make sure the SelectFunction is reset in ContextMenuTreeView.OnButtonPressEvent. With the SelectFunction reset when you drag the file would be selected before the drag so the drag would work. Note that when OnButtonReleaseEvent is called the SelectFunction is reset but the OnButtonReleaseEvent is not called when the bug happens. However the underlying problem seems to be the OnButtonPressEvent method being triggered twice for some reason. This also has the side effect of not selecting the just created file in the solution window when normally it would be selected.
Comment 12 Matt Ward 2016-07-04 14:39:26 UTC
Opened a pull request with a fix:

https://github.com/mono/monodevelop/pull/1536
Comment 13 xamarin-release-manager 2016-07-11 10:55:07 UTC
Fixed in version 6.2.0.26 (master)

Author: Matt Ward
Commit: 581cd1693af8c0e5981eab0b414579ab1e90668b (mono/monodevelop)
Comment 14 xamarin-release-manager 2016-07-11 12:48:40 UTC
Fixed in version 6.1.0.5123 (cycle8)

Author: Matt Ward
Commit: 42ad5f62b8d2ad1bb14023636b3bf0cdffc9a69a (mono/monodevelop)

Note You need to log in before you can comment on or make changes to this bug.