to new "Code Editor" tab in options dialog
These settings apply to more than just the Python console editors -
rather they apply to all code editors across QGIS (including expression
editors)
Before showing an interval of two hours would show you:
interval: 0.0833333 days
Now depending on the range of the interval you will see output
in days, minutes or seconds:
make_interval(years:=0.75)
<interval: 273.938 days>
make_interval(days:=2, hours:=3)
<interval: 2.125 days>
make_interval(hours:=3,days:=1)
<interval: 1.125 days>
make_interval(minutes:=30)
<interval: 30 minutes>
make_interval(minutes:=0.5,seconds:=5)
<interval: 35 seconds>
cppcheck sometimes detects this as a potential null pointer dereference.
This makes sense, although it is quite unlikely that the return a foo()
might change in between.
To avoid such warnings, and also repeated method calls which can have some
cost, I've run the following refactoring script to store the result of
foo() in a local variable.
```shell
for i in `find ../src -name "*.cpp"`; do python analyze.py $i > $i.tmp; diff $i.tmp $i >/dev/null || (echo "Paching $i"; mv $i.tmp $i); rm -f $i.tmp; done
```
with analyze.py being
```python
import re
import sys
lines = [l[0:-1] if l[-1] == '\n' else l for l in open(sys.argv[1], "rt").readlines()]
if_pattern = re.compile("(^[ ]*)if \( ([a-zA-Z0-9_\.]+)\(\) \)$")
i = 0
while i < len(lines):
line = lines[i]
modified = False
m = if_pattern.match(line)
if m:
next_line = lines[i+1]
indent = m.group(1)
s = m.group(2) + "()"
tmpVar = m.group(2).split('.')[-1]
tmpVar = 'l' + tmpVar[0].upper() + tmpVar[1:]
if next_line == indent + '{':
found = False
# Look in the block after the if() for a pattern where we dereference
# "foo()"
j = i + 1
while lines[j] != indent + '}':
if lines[j].find(s + '->') >= 0 or lines[j].find('*' + s) >= 0 or lines[j].find(s + '[') >= 0:
found = True
break
j += 1
if found:
print(indent + 'if ( auto *' + tmpVar + ' = ' + s + ' )')
j = i + 1
while lines[j] != indent + '}':
print(lines[j].replace(' ' + s, ' ' + tmpVar).replace('.' + s, '.' + tmpVar).replace('*' + s, '*' + tmpVar).replace('!' + s, '!' + tmpVar))
j += 1
print(lines[j])
modified = True
i = j
else:
if next_line.find(s) >= 0:
print(indent + 'if ( auto *' + tmpVar + ' = ' + s + ' )')
print(next_line.replace(' ' + s, ' ' + tmpVar).replace('.' + s, '.' + tmpVar).replace('*' + s, '*' + tmpVar).replace('!' + s, '!' + tmpVar))
modified = True
i += 1
if not modified:
print(line)
i += 1
```
class as a base class
Actually it should be completely folded into QgsCodeEditorPython
so that we have a single definitive Python code editor widget, but
this is a first step toward that...
Remove a bunch of duplicate default color definitions, and ensure
that all subclasses correctly respect any user defined color overrides,
yet that we still default to following the application theme's matching
color schemes.
Fixes#39025 by skipping the broken relations detection
for widget configuations that were created before weak
relations were introduced and add an extra check for
projects that were created before recent fixes in 3.15
with commit 7e8c7b3d0e09