Commit 66396788 authored by Murray Cumming's avatar Murray Cumming
Browse files

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
parent e4734ce6
......@@ -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
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment