[gtksourceviewmm/gtksourceviewmm-2.0] Fixed passing empty strings to guess_language() method.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceviewmm/gtksourceviewmm-2.0] Fixed passing empty strings to guess_language() method.
- Date: Sun, 18 Jul 2010 20:25:37 +0000 (UTC)
commit 4da20f6cadce43d2466b86937edf4d51d9ccf935
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Sun Jul 18 22:20:01 2010 +0200
Fixed passing empty strings to guess_language() method.
* gtksourceview/src/sourcelanguagemanager.ccg:
* gtksourceview/src/sourcelanguagemanager.hg: In gtksourceview
2.10.x passing an empty string to
gtk_source_language_manager_guess_language() causes assertion fail.
And Glib::ustring::c_str() never returns NULL, but an empty string,
so that causes this method being useful only when passed an awkward
" " string instead of Glib::ustring() to unneeded parameter. Now
when passed Glib::ustring is empty, then NULL is passed to C
function.
gtksourceview/src/sourcelanguagemanager.ccg | 14 ++++++++++++++
gtksourceview/src/sourcelanguagemanager.hg | 5 +++--
2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/gtksourceview/src/sourcelanguagemanager.ccg b/gtksourceview/src/sourcelanguagemanager.ccg
index 042ee66..3dbab52 100644
--- a/gtksourceview/src/sourcelanguagemanager.ccg
+++ b/gtksourceview/src/sourcelanguagemanager.ccg
@@ -31,5 +31,19 @@ SourceLanguageManager::reset_search_path()
gtk_source_language_manager_set_search_path(gobj(), 0);
}
+Glib::RefPtr<SourceLanguage> SourceLanguageManager::guess_language(const Glib::ustring& filename, const Glib::ustring& content_type)
+{
+ Glib::RefPtr<SourceLanguage> retvalue = Glib::wrap(gtk_source_language_manager_guess_language(gobj(), filename.empty() ? 0 : filename.c_str(), content_type.empty() ? 0 : content_type.c_str()));
+ if(retvalue)
+ retvalue->reference(); //The function does not do a ref for us.
+ return retvalue;
+
+}
+
+Glib::RefPtr<const SourceLanguage> SourceLanguageManager::guess_language(const Glib::ustring& filename, const Glib::ustring& content_type) const
+{
+ return const_cast<SourceLanguageManager*>(this)->guess_language(filename, content_type);
+}
+
}//end namespace gtksourceview
diff --git a/gtksourceview/src/sourcelanguagemanager.hg b/gtksourceview/src/sourcelanguagemanager.hg
index 9f24377..baa7468 100644
--- a/gtksourceview/src/sourcelanguagemanager.hg
+++ b/gtksourceview/src/sourcelanguagemanager.hg
@@ -166,7 +166,8 @@ public:
* @return A SourceLanguage, or empty Glib::RefPtr if there is no suitable
* language for given @a filename and/or @a content_type.
*/
- _WRAP_METHOD(Glib::RefPtr<SourceLanguage> guess_language(const Glib::ustring& filename, const Glib::ustring& content_type), gtk_source_language_manager_guess_language, refreturn)
+ _IGNORE(gtk_source_language_manager_guess_language)
+ Glib::RefPtr<SourceLanguage> guess_language(const Glib::ustring& filename, const Glib::ustring& content_type);
/** Picks a SourceLanguage for given file name and content type,
* according to the information in lang files.
@@ -214,7 +215,7 @@ public:
* @return A SourceLanguage, or empty Glib::RefPtr if there is no suitable
* language for given @a filename and/or @a content_type.
*/
- _WRAP_METHOD(Glib::RefPtr<const SourceLanguage> guess_language(const Glib::ustring& filename, const Glib::ustring& content_type) const, gtk_source_language_manager_guess_language, refreturn, constversion)
+ Glib::RefPtr<const SourceLanguage> guess_language(const Glib::ustring& filename, const Glib::ustring& content_type) const;
};
} /* namespace gtksourceview */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]