From: Agnibho Mondal Date: Sun, 29 Oct 2023 15:32:00 +0000 (+0530) Subject: Background plugins can not modify prescription. X-Git-Tag: v0.4~7 X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=e02594c4a97990ee1f5e48e4cfdfcd7fa770e41f;p=medscript.git Background plugins can not modify prescription. --- diff --git a/README b/README index d75113a..361a4b4 100644 --- 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. diff --git a/plugin.py b/plugin.py index ceba95a..fad6270 100644 --- 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 . -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)