cleanup: make templateOptions and printOptions reference types

These two structs describe options used during printing.
They are passed through numerous classes as pointer. In this
case, reference semantics are preferred, as references:
 - can never be null
 - can not change during their lifetime
This not only helps the compiler, as it can optimize away null
checks, but also your fellow coder. Moreover, it prevents
unintentional creation of uninitialized references: one can't
create an instance of a class without initializing a reference
member. It does not prevent references from going dangling.
However, pointers have the same disadvantage.

Contains a few whitespace cleanups.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-12-12 13:28:36 +01:00 committed by Dirk Hohndel
parent 7bdd968e05
commit 0cbb448740
9 changed files with 97 additions and 111 deletions

View file

@ -64,14 +64,14 @@ class PrintOptions : public QWidget {
Q_OBJECT
public:
explicit PrintOptions(QWidget *parent, struct print_options *printOpt, struct template_options *templateOpt);
explicit PrintOptions(QWidget *parent, print_options &printOpt, template_options &templateOpt);
void setup();
QString getSelectedTemplate();
private:
Ui::PrintOptions ui;
struct print_options *printOptions = nullptr;
struct template_options *templateOptions = nullptr;
print_options &printOptions;
template_options &templateOptions;
bool hasSetupSlots;
QString lastImportExportTemplate;
void setupTemplates();