Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Benjamin Hennion <benjamin.hennion@wanadoo.fr>
  • Loading branch information
jhilmer and bhennion committed Apr 7, 2023
1 parent c809c0e commit e403742
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/core/control/tools/ImageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ImageHandler::~ImageHandler() = default;
auto ImageHandler::insertImage(double x, double y) -> bool {
xoj::util::GObjectSPtr<GFile> file(ImageOpenDlg::show(control->getGtkWindow(), control->getSettings()),
xoj::util::adopt);
if (file.get() == nullptr) {
if (!file) {
return false;
}
return insertImage(file.get(), x, y);
Expand Down
2 changes: 1 addition & 1 deletion src/core/control/xojfile/LoadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ void LoadHandler::parseAudio() {
GFileIOStream* fileStream = nullptr;
xoj::util::GObjectSPtr<GFile> tmpFile(g_file_new_tmp("xournal_audio_XXXXXX.tmp", &fileStream, nullptr),
xoj::util::adopt);
if (!tmpFile.get()) {
if (!tmpFile) {
g_warning("Unable to create temporary file for audio attachment.");
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void MainWindow::dragDataRecived(GtkWidget* widget, GdkDragContext* dragContext,
}

xoj::util::GObjectSPtr<GdkPixbuf> image(gtk_selection_data_get_pixbuf(data), xoj::util::adopt);
if (image.get()) {
if (image) {
win->control->clipboardPasteImage(image.get());

gtk_drag_finish(dragContext, true, false, time);
Expand Down Expand Up @@ -348,7 +348,7 @@ void MainWindow::dragDataRecived(GtkWidget* widget, GdkDragContext* dragContext,
continue;
}

if (pixbuf.get()) {
if (pixbuf) {
win->control->clipboardPasteImage(pixbuf.get());
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/core/model/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Document::~Document() {
}

void Document::freeTreeContentModel() {
if (this->contentsModel.get()) {
if (this->contentsModel) {
gtk_tree_model_foreach(this->contentsModel.get(),
reinterpret_cast<GtkTreeModelForeachFunc>(freeTreeContentEntry), this);

Expand Down Expand Up @@ -288,7 +288,7 @@ auto Document::fillPageLabels(GtkTreeModel* treeModel, GtkTreePath* path, GtkTre
}

void Document::updateIndexPageNumbers() {
if (this->contentsModel.get() != nullptr) {
if (this->contentsModel) {
gtk_tree_model_foreach(this->contentsModel.get(), reinterpret_cast<GtkTreeModelForeachFunc>(fillPageLabels),
this);
}
Expand Down
4 changes: 1 addition & 3 deletions src/core/model/TexImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ void TexImage::freeImageAndPdf() {
this->image = nullptr;
}

if (this->pdf.get()) {
this->pdf.reset();
}
this->pdf.reset();
}

auto TexImage::clone() const -> Element* {
Expand Down

0 comments on commit e403742

Please sign in to comment.