Permalink
Browse files

[close][MW-1730][SQLED] Update using the form editor/resuls grid gene…

…rates a crash

move connection mutex lock into smaller scope in apply_changes
  • Loading branch information...
1 parent 12c7d09 commit d93ef66da1e9f9c1726834b2551551e31f2dfff5 Marcin Szalowicz committed Oct 12, 2016
Showing with 8 additions and 3 deletions.
  1. +8 −3 backend/wbprivate/sqlide/wb_sql_editor_form.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -2617,11 +2617,15 @@ void SqlEditorForm::apply_changes_to_recordset(Recordset::Ptr rs_ptr)
try
{
- RecMutexLock usr_dbc_conn_mutex= ensure_valid_usr_connection();
+ bool auto_commit = false;
+
// we need transaction to enforce atomicity of change set
// so if autocommit is currently enabled disable it temporarily
- bool auto_commit= _usr_dbc_conn->ref->getAutoCommit();
+ {
+ RecMutexLock usr_dbc_conn_mutex = ensure_valid_usr_connection();
+ auto_commit = _usr_dbc_conn->ref->getAutoCommit();
+ }
ScopeExitTrigger autocommit_mode_keeper;
int res= -2;
@@ -2640,6 +2644,7 @@ void SqlEditorForm::apply_changes_to_recordset(Recordset::Ptr rs_ptr)
autocommit_mode_keeper.slot= boost::bind(
&sql::Connection::setAutoCommit, _usr_dbc_conn->ref.get(),
auto_commit);
+ RecMutexLock usr_dbc_conn_mutex = ensure_valid_usr_connection();
_usr_dbc_conn->ref->setAutoCommit(false);
}

0 comments on commit d93ef66

Please sign in to comment.