Suppress Callbacks From Firing During Model Comparison

Hi all. I'm trying to figure out a way to surpress callbacks from firing during a model comparison? Or maybe a better question is if there is a way to check if a model comparison is being done.
Background: Our models have a callback (call it model resize) in them that finds the size of the primary monitor and will resize the model's window to an approprate size based on the monitor size, when the model is first opened. Well, when you use Matlab's comparison tool to compare the two different models, the model resize call back fires and overrides where the comparison tool puts the two model windows (upper right corner and lower right corner). I am hunting for a way to prevent this specific call back from firing. Any ideas? I can't really post a good example of it due to working restrictions.

8 Kommentare

perhaps have the callback check aa variable, perhaps an environment variable, to see if the resize should be skipped ? and have aa small routine that sets the variable and runs the comparison and resets afterwards ?
I would be open to this but I am not sure how to determine what's forcing the model update (which is driving the callback to be fired). If the user manually pushes the "Model Update" button then the call back needs to be fired. If something else causes the model update to be ran, then a different response is needed. I do not know enough how to differenciate between those situations from inside the call back or from a global aspect.
It sounds like the model resize function is put in the "InitFcn" callback. I think it could be put in the "PreLoadFcn" callback based on your description of the function. Of course, I don't know the reason why it needs to be called when the user mannually pushes the "Model Update" button.
You are right, Fangjun. I was half asleep and looking at the wrong item when I wrote that. It is part of a mask initialization & it fires when the model is first opened, regardless of what's causing the model to be opened.
%inside callback
% if isempty(getenv('SKIP_MODEL_RESIZE'))
.... do the resize
end
together with
function compare_models(model1, model2)
cleanMe = onCleanup(@() setenv('SKIP_MODEL_RESIZE', ''));
setenv('SKIP_MODEL_RESIZE', 'Y')
visdiff(model1, model2)
end
Walter, I might be wrong but won't that only work if I call it from the command line and nott from the actual GUI compare button?
Also, what do you think about looking at the call stack to figure out what's causing the function to fire?
Walter Roberson
Walter Roberson am 10 Dez. 2018
Bearbeitet: Walter Roberson am 14 Dez. 2018
...so don't use the gui compare button ? ;)
Looking at the call stack might work, but there is a tendency to lose the call stack for callbacks which are eval() automatically because of button presses in the MATLAB gui.
Ha! I wish I could dissable that button! I think I will have to look at the call stack info since I don't think there is an internal Matlab variable that is set that I can look at

Antworten (0)

Diese Frage ist geschlossen.

Produkte

Version

R2016b

Gefragt:

am 7 Dez. 2018

Geschlossen:

am 20 Aug. 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by