Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old Prefs from OMNeT 5.6 QtEnv cause silent error in OMNeT++ 6 QTEnv #898

Open
edlongman opened this issue Oct 13, 2021 · 1 comment
Open
Assignees
Labels
new New issue that has not been yet acknowledged

Comments

@edlongman
Copy link
Contributor

Platform

  • OMNeT++ version: 5.6 & 6
  • OS: Windows 10

Describe the bug
Shared preferences between OMNeT versions can cause simulations to fail cryptically.

I receive the error:

<!> Error: Parse error in match expression: syntax error

Even in debug mode it does not trigger a debug breakpoint.

To Reproduce

  1. Run an OMNeT 5.6 QTEnv simulation
  2. Open Preference > Filtering > Animation
  3. Enter Filter: module(*.packetSource)
  4. Run OMNeT 6 Simulation

** Approximate error source **

omnetpp/src/qtenv/qtenv.cc

Lines 245 to 367 in 5997cd4

void Qtenv::restoreOptsFromPrefs()
{
auto pref = getPref("updatefreq_express_ms");
if (pref.isValid())
opt->updateFreqExpress = pref.toLongLong();
pref = getPref("event_banners");
if (pref.isValid())
opt->printEventBanners = pref.toBool();
pref = getPref("init_banners");
if (pref.isValid())
opt->printInitBanners = pref.toBool();
pref = getPref("short_banners");
if (pref.isValid())
opt->shortBanners = pref.toBool();
pref = getPref("allow_backward_arrows");
if (pref.isValid())
opt->allowBackwardArrowsForHops = pref.toBool();
pref = getPref("messagelog_digitgrouping");
if (pref.isValid())
opt->messageLogDigitGrouping = pref.toBool();
pref = getPref("no_logging_refreshdisplay");
if (pref.isValid())
opt->noLoggingRefreshDisplay = pref.toBool();
pref = getPref("animation_enabled");
if (pref.isValid())
opt->animationEnabled = pref.toBool();
pref = getPref("nexteventmarkers");
if (pref.isValid())
opt->showNextEventMarkers = pref.toBool();
pref = getPref("senddirect_arrows");
if (pref.isValid())
opt->showSendDirectArrows = pref.toBool();
pref = getPref("animation_methodcalls");
if (pref.isValid())
opt->animateMethodCalls = pref.toBool();
pref = getPref("methodcalls_duration");
if (pref.isValid())
opt->methodCallAnimDuration = pref.toInt();
pref = getPref("animation_msgnames");
if (pref.isValid())
opt->animationMsgNames = pref.toBool();
pref = getPref("animation_msgclassnames");
if (pref.isValid())
opt->animationMsgClassNames = pref.toBool();
pref = getPref("animation_msgcolors");
if (pref.isValid())
opt->animationMsgColors = pref.toBool();
pref = getPref("silent_event_filters");
if (pref.isValid())
setSilentEventFilters(pref.toString().toStdString().c_str());
pref = getPref("penguin_mode");
if (pref.isValid())
opt->penguinMode = pref.toBool();
pref = getPref("showlayouting");
if (pref.isValid())
opt->showLayouting = pref.toBool();
pref = getPref("layouterchoice");
if (pref.isValid()) {
QString layouterChoiceString = pref.toString();
if (layouterChoiceString == "fast") {
opt->layouterChoice = LAYOUTER_FAST;
}
else if (layouterChoiceString == "advanced") {
opt->layouterChoice = LAYOUTER_ADVANCED;
}
else if (layouterChoiceString == "auto") {
opt->layouterChoice = LAYOUTER_AUTO;
}
}
pref = getPref("arrangevectorconnections");
if (pref.isValid())
opt->arrangeVectorConnections = pref.toBool();
pref = getPref("bubbles");
if (pref.isValid())
opt->showBubbles = pref.toBool();
pref = getPref("expressmode_autoupdate");
if (pref.isValid())
opt->autoupdateInExpress = pref.toBool();
pref = getPref("stripnamespace");
if (pref.isValid()) {
QString stripNamespaceString = pref.toString();
if (stripNamespaceString == "none") {
opt->stripNamespace = STRIPNAMESPACE_NONE;
}
else if (stripNamespaceString == "omnetpp") {
opt->stripNamespace = STRIPNAMESPACE_OMNETPP;
}
else if (stripNamespaceString == "all") {
opt->stripNamespace = STRIPNAMESPACE_ALL;
}
}
// overriding opts from prefs, but using the current ones (factory defaults) as fallback if no pref was stored yet
opt->logFormat = getPref("logformat", opt->logFormat.c_str()).toString().toStdString();
try { // level is stored as string, so we have to convert there and back. also have to store in opt, also forward to cLog via setter
opt->logLevel = cLog::resolveLogLevel(getPref("loglevel", cLog::getLogLevelName(opt->logLevel)).toByteArray());
} catch (cRuntimeError &) { } // resolveLogLevel might throw, but we can ignore it, and not change the factory default
pref = getPref("logbuffer_maxnumevents");
if (pref.isValid())
logBuffer.setMaxNumEntries(pref.toInt());

@edlongman edlongman added the new New issue that has not been yet acknowledged label Oct 13, 2021
@rhornig
Copy link
Contributor

rhornig commented Oct 13, 2021

Indeed, we should not throw exception on recoverable errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new New issue that has not been yet acknowledged
Projects
None yet
Development

No branches or pull requests

3 participants