Ensure the debugger control buttons are only enabled once initialisation is complete. Fixes #4360

This commit is contained in:
Akshay Joshi 2019-06-18 14:46:28 +01:00 committed by Dave Page
parent 9e65c971a3
commit b36d5d153b
4 changed files with 52 additions and 76 deletions

View File

@ -33,4 +33,5 @@ Bug fixes
| `Bug #4349 <https://redmine.postgresql.org/issues/4349>`_ - Ensure strings are properly encoded in the Query History. | `Bug #4349 <https://redmine.postgresql.org/issues/4349>`_ - Ensure strings are properly encoded in the Query History.
| `Bug #4350 <https://redmine.postgresql.org/issues/4350>`_ - Ensure we include the CSRF token when uploading files. | `Bug #4350 <https://redmine.postgresql.org/issues/4350>`_ - Ensure we include the CSRF token when uploading files.
| `Bug #4357 <https://redmine.postgresql.org/issues/4357>`_ - Fix connection restoration issue when pgAdmin server is restarted and the page is refreshed. | `Bug #4357 <https://redmine.postgresql.org/issues/4357>`_ - Fix connection restoration issue when pgAdmin server is restarted and the page is refreshed.
| `Bug #4365 <https://redmine.postgresql.org/issues/4365>`_ - Fix help links for backup globals and backup server. | `Bug #4360 <https://redmine.postgresql.org/issues/4360>`_ - Ensure the debugger control buttons are only enabled once initialisation is complete.
| `Bug #4365 <https://redmine.postgresql.org/issues/4365>`_ - Fix help links for backup globals and backup server.

View File

@ -839,7 +839,7 @@ def restart_debugging(trans_id):
de_inst.debugger_data['restart_debug'] = 1 de_inst.debugger_data['restart_debug'] = 1
de_inst.update_session() de_inst.update_session()
de_inst.function_data = { de_inst.function_data.update({
'server_id': de_inst.debugger_data['server_id'], 'server_id': de_inst.debugger_data['server_id'],
'database_id': de_inst.debugger_data['database_id'], 'database_id': de_inst.debugger_data['database_id'],
'schema_id': de_inst.debugger_data['schema_id'], 'schema_id': de_inst.debugger_data['schema_id'],
@ -851,7 +851,7 @@ def restart_debugging(trans_id):
'proargdefaults': de_inst.function_data['default_value'], 'proargdefaults': de_inst.function_data['default_value'],
'proargnames': de_inst.function_data['args_name'], 'proargnames': de_inst.function_data['args_name'],
'require_input': de_inst.function_data['require_input'] 'require_input': de_inst.function_data['require_input']
} })
return make_json_response( return make_json_response(
data={ data={

View File

@ -39,6 +39,26 @@ define([
this.trigger('pgDebugger:button:state:' + btn, enable); this.trigger('pgDebugger:button:state:' + btn, enable);
}, },
enable_toolbar_buttons: function() {
var self = this;
self.enable('stop', true);
self.enable('step_over', true);
self.enable('step_into', true);
self.enable('toggle_breakpoint', true);
self.enable('clear_all_breakpoints', true);
self.enable('continue', true);
},
disable_toolbar_buttons: function() {
var self = this;
self.enable('stop', false);
self.enable('step_over', false);
self.enable('step_into', false);
self.enable('toggle_breakpoint', false);
self.enable('clear_all_breakpoints', false);
self.enable('continue', false);
},
/* /*
Function to set the breakpoint and send the line no. which is set to server Function to set the breakpoint and send the line no. which is set to server
trans_id :- Unique Transaction ID, line_no - line no. to set the breakpoint, trans_id :- Unique Transaction ID, line_no - line no. to set the breakpoint,
@ -405,12 +425,7 @@ define([
// Enable all the buttons as we got the results // Enable all the buttons as we got the results
// TODO: Fix this properly so a timeout isn't required. // TODO: Fix this properly so a timeout isn't required.
setTimeout(function() { setTimeout(function() {
self.enable('stop', true); self.enable_toolbar_buttons();
self.enable('step_over', true);
self.enable('step_into', true);
self.enable('continue', true);
self.enable('toggle_breakpoint', true);
self.enable('clear_all_breakpoints', true);
}, 500); }, 500);
} }
} else if (res.data.status === 'Busy') { } else if (res.data.status === 'Busy') {
@ -422,12 +437,7 @@ define([
); );
// As we are waiting for another session to invoke the target,disable all the buttons // As we are waiting for another session to invoke the target,disable all the buttons
self.enable('stop', false); self.disable_toolbar_buttons();
self.enable('step_over', false);
self.enable('step_into', false);
self.enable('continue', false);
self.enable('toggle_breakpoint', false);
self.enable('clear_all_breakpoints', false);
pgTools.DirectDebug.first_time_indirect_debug = false; pgTools.DirectDebug.first_time_indirect_debug = false;
self.poll_result(trans_id); self.poll_result(trans_id);
} else { } else {
@ -648,12 +658,7 @@ define([
var self = this, var self = this,
baseUrl = url_for('debugger.restart', {'trans_id': trans_id}); baseUrl = url_for('debugger.restart', {'trans_id': trans_id});
self.enable('stop', false); self.disable_toolbar_buttons();
self.enable('step_over', false);
self.enable('step_into', false);
self.enable('toggle_breakpoint', false);
self.enable('clear_all_breakpoints', false);
self.enable('continue', false);
// Clear msg tab // Clear msg tab
pgTools.DirectDebug pgTools.DirectDebug
@ -725,12 +730,7 @@ define([
// Continue the execution until the next breakpoint // Continue the execution until the next breakpoint
Continue: function(trans_id) { Continue: function(trans_id) {
var self = this; var self = this;
self.enable('stop', false); self.disable_toolbar_buttons();
self.enable('step_over', false);
self.enable('step_into', false);
self.enable('toggle_breakpoint', false);
self.enable('clear_all_breakpoints', false);
self.enable('continue', false);
//Check first if previous execution was completed or not //Check first if previous execution was completed or not
if (pgTools.DirectDebug.direct_execution_completed && if (pgTools.DirectDebug.direct_execution_completed &&
@ -767,12 +767,7 @@ define([
Step_over: function(trans_id) { Step_over: function(trans_id) {
var self = this; var self = this;
self.enable('stop', false); self.disable_toolbar_buttons();
self.enable('step_over', false);
self.enable('step_into', false);
self.enable('toggle_breakpoint', false);
self.enable('clear_all_breakpoints', false);
self.enable('continue', false);
// Make ajax call to listen the database message // Make ajax call to listen the database message
var baseUrl = url_for('debugger.execute_query', { var baseUrl = url_for('debugger.execute_query', {
@ -803,12 +798,7 @@ define([
Step_into: function(trans_id) { Step_into: function(trans_id) {
var self = this; var self = this;
self.enable('stop', false); self.disable_toolbar_buttons();
self.enable('step_over', false);
self.enable('step_into', false);
self.enable('toggle_breakpoint', false);
self.enable('clear_all_breakpoints', false);
self.enable('continue', false);
// Make ajax call to listen the database message // Make ajax call to listen the database message
var baseUrl = url_for('debugger.execute_query', { var baseUrl = url_for('debugger.execute_query', {
@ -839,12 +829,7 @@ define([
Stop: function(trans_id) { Stop: function(trans_id) {
var self = this; var self = this;
self.enable('stop', false); self.disable_toolbar_buttons();
self.enable('step_over', false);
self.enable('step_into', false);
self.enable('toggle_breakpoint', false);
self.enable('clear_all_breakpoints', false);
self.enable('continue', false);
// Make ajax call to listen the database message // Make ajax call to listen the database message
var baseUrl = url_for( var baseUrl = url_for(
@ -890,12 +875,7 @@ define([
toggle_breakpoint: function(trans_id) { toggle_breakpoint: function(trans_id) {
var self = this; var self = this;
self.enable('stop', false); self.disable_toolbar_buttons();
self.enable('step_over', false);
self.enable('step_into', false);
self.enable('toggle_breakpoint', false);
self.enable('clear_all_breakpoints', false);
self.enable('continue', false);
var info = pgTools.DirectDebug.editor.lineInfo(self.active_line_no); var info = pgTools.DirectDebug.editor.lineInfo(self.active_line_no);
@ -936,12 +916,8 @@ define([
return marker; return marker;
}()); }());
} }
self.enable('stop', true);
self.enable('step_over', true); self.enable_toolbar_buttons();
self.enable('step_into', true);
self.enable('toggle_breakpoint', true);
self.enable('clear_all_breakpoints', true);
self.enable('continue', true);
} else if (res.data.status === 'NotConnected') { } else if (res.data.status === 'NotConnected') {
Alertify.alert( Alertify.alert(
gettext('Debugger Error'), gettext('Debugger Error'),
@ -965,12 +941,7 @@ define([
if ((br_list.length == 1) && (br_list[0].linenumber == -1)) if ((br_list.length == 1) && (br_list[0].linenumber == -1))
return; return;
self.enable('stop', false); self.disable_toolbar_buttons();
self.enable('step_over', false);
self.enable('step_into', false);
self.enable('toggle_breakpoint', false);
self.enable('clear_all_breakpoints', false);
self.enable('continue', false);
var breakpoint_list = new Array(); var breakpoint_list = new Array();
@ -1004,12 +975,7 @@ define([
} }
} }
} }
self.enable('stop', true); self.enable_toolbar_buttons();
self.enable('step_over', true);
self.enable('step_into', true);
self.enable('toggle_breakpoint', true);
self.enable('clear_all_breakpoints', true);
self.enable('continue', true);
}) })
.fail(function() { .fail(function() {
Alertify.alert( Alertify.alert(
@ -1561,7 +1527,7 @@ define([
let browser = window.opener ? let browser = window.opener ?
window.opener.pgAdmin.Browser : window.top.pgAdmin.Browser; window.opener.pgAdmin.Browser : window.top.pgAdmin.Browser;
this.preferences = browser.get_preferences_for_module('sqleditor'); this.preferences = browser.get_preferences_for_module('debugger');
this.docker = new wcDocker( this.docker = new wcDocker(
'#container', { '#container', {
@ -1592,6 +1558,7 @@ define([
.done(function(res) { .done(function(res) {
if (res.data.status) { if (res.data.status) {
self.intializePanels(); self.intializePanels();
controller.enable_toolbar_buttons();
controller.poll_result(trans_id); controller.poll_result(trans_id);
} }
}) })
@ -1656,6 +1623,7 @@ define([
.done(function(res) { .done(function(res) {
if (res.data.status === 'Success') { if (res.data.status === 'Success') {
self.intializePanels(); self.intializePanels();
controller.enable_toolbar_buttons();
// If status is Success then find the port number to attach the executer. // If status is Success then find the port number to attach the executer.
controller.start_execution(trans_id, res.data.result); controller.start_execution(trans_id, res.data.result);
} else if (res.data.status === 'Busy') { } else if (res.data.status === 'Busy') {

View File

@ -54,19 +54,23 @@ try {
<button type="button" class="btn btn-sm btn-secondary btn-step-into" id="btn-step-into" <button type="button" class="btn btn-sm btn-secondary btn-step-into" id="btn-step-into"
title="" title=""
accesskey="" accesskey=""
tabindex="0" autofocus="autofocus"> tabindex="0"
autofocus="autofocus"
disabled>
<i class="fa fa-indent sql-icon-lg"></i> <i class="fa fa-indent sql-icon-lg"></i>
</button> </button>
<button type="button" class="btn btn-sm btn-secondary btn-step-over" id="btn-step-over" <button type="button" class="btn btn-sm btn-secondary btn-step-over" id="btn-step-over"
title="" title=""
accesskey="" accesskey=""
tabindex="0"> tabindex="0"
disabled>
<i class="fa fa-outdent sql-icon-lg"></i> <i class="fa fa-outdent sql-icon-lg"></i>
</button> </button>
<button type="button" class="btn btn-sm btn-secondary btn-continue" id="btn-continue" <button type="button" class="btn btn-sm btn-secondary btn-continue" id="btn-continue"
title="" title=""
accesskey="" accesskey=""
tabindex="0"> tabindex="0"
disabled>
<i class="fa fa-play-circle sql-icon-lg"></i> <i class="fa fa-play-circle sql-icon-lg"></i>
</button> </button>
</div> </div>
@ -74,13 +78,15 @@ try {
<button type="button" class="btn btn-sm btn-secondary btn-toggle-breakpoint" id="btn-toggle-breakpoint" <button type="button" class="btn btn-sm btn-secondary btn-toggle-breakpoint" id="btn-toggle-breakpoint"
title="" title=""
accesskey="" accesskey=""
tabindex="0"> tabindex="0"
disabled>
<i class="fa fa-circle sql-icon-lg"></i> <i class="fa fa-circle sql-icon-lg"></i>
</button> </button>
<button type="button" class="btn btn-sm btn-secondary btn-clear-breakpoint" id="btn-clear-breakpoint" <button type="button" class="btn btn-sm btn-secondary btn-clear-breakpoint" id="btn-clear-breakpoint"
title="" title=""
accesskey="" accesskey=""
tabindex="0"> tabindex="0"
disabled>
<i class="fa fa-ban sql-icon-lg"></i> <i class="fa fa-ban sql-icon-lg"></i>
</button> </button>
</div> </div>
@ -88,7 +94,8 @@ try {
<button type="button" class="btn btn-sm btn-secondary btn-stop" id="btn-stop" <button type="button" class="btn btn-sm btn-secondary btn-stop" id="btn-stop"
accesskey="" accesskey=""
title="" title=""
tabindex="0"> tabindex="0"
disabled>
<i class="fa fa-stop-circle sql-icon-lg"></i> <i class="fa fa-stop-circle sql-icon-lg"></i>
</button> </button>
</div> </div>