Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit 04ecec8

Browse files
authored
Merge pull request #8943 from mono/master-vscfixParenting
Fixes VSTS Bug 1002571: Regression: VSC checkout message dialogs shown below progress dialog window.
2 parents d256c38 + 66a4fd6 commit 04ecec8

File tree

5 files changed

+64
-26
lines changed

5 files changed

+64
-26
lines changed

main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,17 @@ public bool Run (AlertDialogData data)
240240
NSApplication.SharedApplication.StopModal ();
241241
});
242242

243-
// pass parent and not alert so that the Runloop will change
244-
// and processing will stop until the sheet is closed.
245-
// If we pass alert, then it will run until a second alert is created
246-
// which will be shown as a dialog and then the runloop changes and
247-
// processing stops
248-
NSApplication.SharedApplication.RunModalForWindow (parent);
243+
if (IdeApp.Workbench.RootWindow?.Visible == true) {
244+
// pass parent and not alert so that the Runloop will change
245+
// and processing will stop until the sheet is closed.
246+
// If we pass alert, then it will run until a second alert is created
247+
// which will be shown as a dialog and then the runloop changes and
248+
// processing stops
249+
NSApplication.SharedApplication.RunModalForWindow (parent);
250+
} else {
251+
// fixes message dialog below other dialogs issue when no main window is present (at start)
252+
NSApplication.SharedApplication.RunModalForWindow (alert.Window);
253+
}
249254
}
250255
}
251256

main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/CheckoutCommand.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.Threading.Tasks;
77
using System.Threading;
8+
using System;
89

910
namespace MonoDevelop.VersionControl
1011
{
@@ -47,17 +48,25 @@ protected override string GetDescription ()
4748
return GettextCatalog.GetString ("Checking out {0}...", path);
4849
}
4950

51+
Ide.ProgressMonitoring.MessageDialogProgressMonitor messageDialogProgressMonitor;
52+
5053
protected override ProgressMonitor CreateProgressMonitor ()
5154
{
5255
return new MonoDevelop.Core.ProgressMonitoring.AggregatedProgressMonitor (
5356
base.CreateProgressMonitor (),
54-
new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor (true, true, true, true)
57+
messageDialogProgressMonitor = new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor (true, true, true, true)
5558
);
5659
}
5760

61+
protected override void ReportError (string primaryText, string message, Exception exception)
62+
{
63+
MessageService.ShowError (messageDialogProgressMonitor.ProgressDialog, primaryText, message, exception);
64+
}
65+
5866
AlertButton AskForCheckoutPath ()
5967
{
6068
return MessageService.AskQuestion (
69+
messageDialogProgressMonitor.ProgressDialog,
6170
GettextCatalog.GetString ("Checkout path is not empty. Do you want to delete its contents?"),
6271
path,
6372
AlertButton.Cancel,

main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlTask.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ public Task StartAsync ()
5757
var msg = GettextCatalog.GetString ("The operation could not be completed because a shared library is missing: ");
5858
tracker.ReportError (msg + exception.Message, null);
5959
LoggingService.LogError ("Version Control command failed: ", exception);
60-
} else if (exception is VersionControlException) {
61-
ReportError (exception.Message, exception);
6260
} else {
63-
ReportError (exception.Message, exception);
61+
string msg = GettextCatalog.GetString ("Version control operation failed");
62+
tracker.ReportError ($"{msg}: {exception.Message}", exception);
63+
if (IdeApp.Workbench.RootWindow?.Visible == false)
64+
ReportError (msg, exception.Message, exception);
6465
}
6566
}
6667
Wakeup ();
@@ -84,12 +85,9 @@ protected void Warn(string logtext) {
8485
tracker.ReportWarning(logtext);
8586
}
8687

87-
void ReportError (string message, Exception exception)
88+
protected virtual void ReportError (string primaryText, string message, Exception exception)
8889
{
89-
string msg = GettextCatalog.GetString ("Version control operation failed");
90-
tracker.ReportError ($"{msg}: {message}", exception);
91-
if (IdeApp.Workbench.RootWindow?.Visible == false)
92-
MessageService.ShowError (msg, message, exception);
90+
MessageService.ShowError (primaryText, message, exception);
9391
}
9492
}
9593
}

main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.ProgressMonitoring/MessageDialogProgressMonitor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public class MessageDialogProgressMonitor: ProgressMonitor
3939
ProgressDialog dialog;
4040
bool hideWhenDone;
4141
bool showDetails;
42-
42+
43+
public ProgressDialog ProgressDialog => dialog;
44+
4345
public MessageDialogProgressMonitor (): this (false)
4446
{
4547
}

main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/MessageService.cs

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,34 +263,58 @@ public static bool Confirm (ConfirmationMessage message)
263263
return messageService.GenericAlert (null, message) == message.ConfirmButton;
264264
}
265265
#endregion
266-
266+
267267
#region AskQuestion
268-
public static AlertButton AskQuestion (string primaryText, params AlertButton[] buttons)
268+
public static AlertButton AskQuestion (string primaryText, params AlertButton [] buttons)
269269
{
270270
return AskQuestion (primaryText, null, buttons);
271271
}
272-
273-
public static AlertButton AskQuestion (string primaryText, string secondaryText, params AlertButton[] buttons)
272+
273+
public static AlertButton AskQuestion (string primaryText, string secondaryText, params AlertButton [] buttons)
274274
{
275275
return GenericAlert (MonoDevelop.Ide.Gui.Stock.Question, primaryText, secondaryText, buttons);
276276
}
277-
public static AlertButton AskQuestion (string primaryText, int defaultButton, params AlertButton[] buttons)
277+
public static AlertButton AskQuestion (string primaryText, int defaultButton, params AlertButton [] buttons)
278278
{
279279
return AskQuestion (primaryText, null, defaultButton, buttons);
280280
}
281-
282-
public static AlertButton AskQuestion (string primaryText, string secondaryText, int defaultButton, params AlertButton[] buttons)
281+
282+
public static AlertButton AskQuestion (string primaryText, string secondaryText, int defaultButton, params AlertButton [] buttons)
283283
{
284284
return GenericAlert (MonoDevelop.Ide.Gui.Stock.Question, primaryText, secondaryText, defaultButton, buttons);
285285
}
286-
286+
287287
public static AlertButton AskQuestion (QuestionMessage message)
288288
{
289289
return messageService.GenericAlert (null, message);
290290
}
291-
291+
292+
public static AlertButton AskQuestion (Window parent, string primaryText, params AlertButton [] buttons)
293+
{
294+
return AskQuestion (parent, primaryText, null, buttons);
295+
}
296+
297+
public static AlertButton AskQuestion (Window parent, string primaryText, string secondaryText, params AlertButton [] buttons)
298+
{
299+
return GenericAlert (parent, MonoDevelop.Ide.Gui.Stock.Question, primaryText, secondaryText, buttons);
300+
}
301+
public static AlertButton AskQuestion (Window parent, string primaryText, int defaultButton, params AlertButton [] buttons)
302+
{
303+
return AskQuestion (parent, primaryText, null, defaultButton, buttons);
304+
}
305+
306+
public static AlertButton AskQuestion (Window parent, string primaryText, string secondaryText, int defaultButton, params AlertButton [] buttons)
307+
{
308+
return GenericAlert (parent, MonoDevelop.Ide.Gui.Stock.Question, primaryText, secondaryText, defaultButton, buttons);
309+
}
310+
311+
public static AlertButton AskQuestion (Window parent, QuestionMessage message)
312+
{
313+
return messageService.GenericAlert (parent, message);
314+
}
315+
292316
#endregion
293-
317+
294318
/// <summary>
295319
/// Places, runs and destroys a transient dialog.
296320
/// </summary>

0 commit comments

Comments
 (0)