[glom] DialogImageLoadProgress::get_image_data(): Give ownership of the GdaBinary.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] DialogImageLoadProgress::get_image_data(): Give ownership of the GdaBinary.
- Date: Thu, 25 Feb 2016 12:59:16 +0000 (UTC)
commit 66396788b4a66b4ba3517f8e9ccb5157a219f5b5
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Feb 25 13:57:13 2016 +0100
DialogImageLoadProgress::get_image_data(): Give ownership of the GdaBinary.
This seems to fix the crash when choosing an image repeatedly:
https://bugzilla.gnome.org/show_bug.cgi?id=761396#c13
glom/utility_widgets/dialog_image_load_progress.cc | 9 +++++----
glom/utility_widgets/dialog_image_load_progress.h | 4 ++--
2 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/glom/utility_widgets/dialog_image_load_progress.cc
b/glom/utility_widgets/dialog_image_load_progress.cc
index d83a15c..331eba1 100644
--- a/glom/utility_widgets/dialog_image_load_progress.cc
+++ b/glom/utility_widgets/dialog_image_load_progress.cc
@@ -52,7 +52,7 @@ DialogImageLoadProgress::DialogImageLoadProgress(BaseObjectType* cobject, const
DialogImageLoadProgress::~DialogImageLoadProgress()
{
- if(m_data.get())
+ if(m_data)
g_free(m_data->data);
// TODO: Cancel outstanding async operations in destructor?
@@ -63,7 +63,7 @@ void DialogImageLoadProgress::load(const Glib::ustring& uri)
// Can only load one file with data
g_assert(!m_data.get());
- m_data.reset(new GdaBinary);
+ m_data = std::make_unique<GdaBinary>();
m_data->data = nullptr;
m_data->binary_length = 0;
@@ -165,9 +165,10 @@ void DialogImageLoadProgress::error(const Glib::ustring& error_message)
response(Gtk::RESPONSE_REJECT);
}
-std::shared_ptr<GdaBinary> DialogImageLoadProgress::get_image_data()
+std::unique_ptr<GdaBinary> DialogImageLoadProgress::get_image_data()
{
- return m_data;
+ return std::move(m_data);
+ m_data.reset();
}
} // namespace Glom
diff --git a/glom/utility_widgets/dialog_image_load_progress.h
b/glom/utility_widgets/dialog_image_load_progress.h
index 38e7688..989a6d8 100644
--- a/glom/utility_widgets/dialog_image_load_progress.h
+++ b/glom/utility_widgets/dialog_image_load_progress.h
@@ -43,7 +43,7 @@ public:
void load(const Glib::ustring& uri);
- std::shared_ptr<GdaBinary> get_image_data();
+ std::unique_ptr<GdaBinary> get_image_data();
private:
void error(const Glib::ustring& error_message);
@@ -53,7 +53,7 @@ private:
void on_stream_read(const Glib::RefPtr<Gio::AsyncResult>& result, unsigned int offset);
void on_read_next(unsigned int at);
- std::shared_ptr<GdaBinary> m_data;
+ std::unique_ptr<GdaBinary> m_data;
Gtk::ProgressBar* m_progress_bar;
Glib::RefPtr<Gio::File> m_file;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]