]> Softwares of Agnibho - medscript.git/commitdiff
Background plugins can not modify prescription.
authorAgnibho Mondal <mondal@agnibho.com>
Sun, 29 Oct 2023 15:32:00 +0000 (21:02 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Sun, 29 Oct 2023 15:32:00 +0000 (21:02 +0530)
README
plugin.py

diff --git a/README b/README
index d75113a5fdaeb808ac23d2a0af62e0c11831e434..361a4b489442a69a1742631bc7f12a0fc123f5d7 100644 (file)
--- a/README
+++ b/README
@@ -376,7 +376,8 @@ following functions:
 
 Plugin may run in the background by defining a global variable `background`
 with the value `True`. This may be useful for long running tasks without
-freezing the program. This is only available for the "run" function.
+freezing the program. This is only available for the "run" function. However,
+plugins running in the background can not modify the prescription object.
 
 The plugin may implement one or more functions mentioned above, it is not
 necessary to implement all.
index ceba95ab6fe763f43b80feecc21aefd1a410a96d..fad6270c2ec0b97586b7b3e4c6cc0bc76983134c 100644 (file)
--- a/plugin.py
+++ b/plugin.py
@@ -5,7 +5,7 @@
 # MedScript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 # You should have received a copy of the GNU General Public License along with MedScript. If not, see <https://www.gnu.org/licenses/>.
 
-import os, importlib, threading
+import os, importlib, threading, copy
 from PyQt6.QtWidgets import QMessageBox, QInputDialog, QFileDialog
 from glob import glob
 from config import config
@@ -38,7 +38,8 @@ class Plugin():
                 return(mod.__name__)
 
     def background(self, function, prescription):
-        msg=function(prescription)
+        prescription_copy=copy.deepcopy(prescription)
+        msg=function(prescription_copy)
         if(msg):
             QMessageBox.information(None, "Information", msg)